summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp')
-rw-r--r--Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
index beeb94b65..94958c94e 100644
--- a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
+++ b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
@@ -46,9 +46,10 @@
#include "ImageBuffer.h"
#include "ImageData.h"
#include "WebKit.h"
-#include "platform/WebKitPlatformSupport.h"
+#include "WebViewClient.h"
#include "WebViewImpl.h"
#include "platform/WebGraphicsContext3D.h"
+#include "platform/WebKitPlatformSupport.h"
#include <stdio.h>
#include <wtf/FastMalloc.h>
@@ -151,14 +152,17 @@ PassRefPtr<GraphicsContext3D> createGraphicsContext(GraphicsContext3D::Attribute
webAttributes.noExtensions = attrs.noExtensions;
webAttributes.shareResources = attrs.shareResources;
webAttributes.forUseOnAnotherThread = threadUsage == GraphicsContext3DPrivate::ForUseOnAnotherThread;
- OwnPtr<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::webKitPlatformSupport()->createGraphicsContext3D());
- if (!webContext)
- return 0;
Chrome* chrome = static_cast<Chrome*>(hostWindow);
WebKit::WebViewImpl* webViewImpl = chrome ? static_cast<WebKit::WebViewImpl*>(chrome->client()->webView()) : 0;
-
- if (!webContext->initialize(webAttributes, webViewImpl, renderDirectlyToHostWindow))
+ OwnPtr<WebKit::WebGraphicsContext3D> webContext;
+ if (!webViewImpl || !webViewImpl->client()) {
+ if (renderDirectlyToHostWindow)
+ return 0;
+ webContext = adoptPtr(WebKit::webKitPlatformSupport()->createOffscreenGraphicsContext3D(webAttributes));
+ } else
+ webContext = adoptPtr(webViewImpl->client()->createGraphicsContext3D(webAttributes, renderDirectlyToHostWindow));
+ if (!webContext)
return 0;
return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), attrs, hostWindow, renderStyle, threadUsage);
@@ -210,7 +214,7 @@ GrContext* GraphicsContext3DPrivate::grContext()
// Limit the number of textures we hold in the bitmap->texture cache.
static const int maxTextureCacheCount = 512;
// Limit the bytes allocated toward textures in the bitmap->texture cache.
- static const size_t maxTextureCacheBytes = 50 * 1024 * 1024;
+ static const size_t maxTextureCacheBytes = 96 * 1024 * 1024;
if (!m_grContext) {
SkAutoTUnref<GrGLInterface> interface(m_impl->createGrGLInterface());
@@ -1032,6 +1036,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes, HostWindow*,
GraphicsContext3D::~GraphicsContext3D()
{
m_private->setContextLostCallback(nullptr);
+ m_private->setErrorMessageCallback(nullptr);
m_private->setSwapBuffersCompleteCallbackCHROMIUM(nullptr);
}
@@ -1268,6 +1273,7 @@ DELEGATE_TO_INTERNAL_1(synthesizeGLError, GC3Denum)
DELEGATE_TO_INTERNAL_R(getExtensions, Extensions3D*)
DELEGATE_TO_INTERNAL_1(setContextLostCallback, PassOwnPtr<GraphicsContext3D::ContextLostCallback>)
+DELEGATE_TO_INTERNAL_1(setErrorMessageCallback, PassOwnPtr<GraphicsContext3D::ErrorMessageCallback>)
class GraphicsContextLostCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
public:
@@ -1296,6 +1302,33 @@ void GraphicsContext3DPrivate::setContextLostCallback(PassOwnPtr<GraphicsContext
m_impl->setContextLostCallback(m_contextLostCallbackAdapter.get());
}
+class GraphicsErrorMessageCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsErrorMessageCallback {
+public:
+ virtual void onErrorMessage(const WebKit::WebString&, WebKit::WGC3Dint);
+ static PassOwnPtr<GraphicsErrorMessageCallbackAdapter> create(PassOwnPtr<GraphicsContext3D::ErrorMessageCallback>);
+ virtual ~GraphicsErrorMessageCallbackAdapter() { }
+private:
+ GraphicsErrorMessageCallbackAdapter(PassOwnPtr<GraphicsContext3D::ErrorMessageCallback> cb) : m_errorMessageCallback(cb) { }
+ OwnPtr<GraphicsContext3D::ErrorMessageCallback> m_errorMessageCallback;
+};
+
+void GraphicsErrorMessageCallbackAdapter::onErrorMessage(const WebKit::WebString& message, WebKit::WGC3Dint id)
+{
+ if (m_errorMessageCallback)
+ m_errorMessageCallback->onErrorMessage(message, id);
+}
+
+PassOwnPtr<GraphicsErrorMessageCallbackAdapter> GraphicsErrorMessageCallbackAdapter::create(PassOwnPtr<GraphicsContext3D::ErrorMessageCallback> cb)
+{
+ return adoptPtr(cb.get() ? new GraphicsErrorMessageCallbackAdapter(cb) : 0);
+}
+
+void GraphicsContext3DPrivate::setErrorMessageCallback(PassOwnPtr<GraphicsContext3D::ErrorMessageCallback> cb)
+{
+ m_errorMessageCallbackAdapter = GraphicsErrorMessageCallbackAdapter::create(cb);
+ m_impl->setErrorMessageCallback(m_errorMessageCallbackAdapter.get());
+}
+
bool GraphicsContext3D::isGLES2Compliant() const
{
return m_private->isGLES2Compliant();