Diff
Modified: trunk/Source/WebCore/ChangeLog (119317 => 119318)
--- trunk/Source/WebCore/ChangeLog 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebCore/ChangeLog 2012-06-02 14:01:16 UTC (rev 119318)
@@ -1,3 +1,58 @@
+2012-06-02 Zeno Albisser <z...@webkit.org>
+
+ Fix and enable WebGL for WebKit2 on Qt.
+ https://bugs.webkit.org/show_bug.cgi?id=86214
+
+ Make GraphicsContext3DPrivate use GraphicsSurfaces
+ for WK2. The GraphicsContext3D then uses the existing
+ RenderBuffer for multisample rendering.
+ When WebGraphicsLayer::syncCompositingState is being
+ executed, the canvas is being synced as well. This means
+ that the RenderBuffer contents are being blit onto
+ a GraphicsSurface, and the GraphicsSurface token is
+ being sent to the UIProcess.
+ The WebLayerTreeRenderer then creates a
+ TextureMapperSurfaceBackingStore for the canvas and
+ passes the GraphicsSurface token as an argument.
+ The token can then be used to identify the GraphicsSurface
+ from the UIProcess side.
+
+ Reviewed by Noam Rosenthal.
+
+ * platform/graphics/GraphicsContext3D.h:
+ Added createGraphicsSurfaces function. This is currently only
+ being used by the Qt port.
+
+ * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+ (WebCore::GraphicsContext3D::reshape):
+ Calling the createGraphicsSurfaces function when the GraphicsContext3D
+ is reshaped. This is currently only relevant for the Qt port.
+
+ * platform/graphics/qt/GraphicsContext3DQt.cpp:
+ (GraphicsContext3DPrivate):
+ Added m_frontBufferGraphicsSurface, m_backBufferGraphicsSurface
+ and m_surfaceFlags members.
+ (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
+ In case of WK2, create a QOpenGLContext and two GraphicsSurface
+ for sharing the WebGL content with the UIProcess. One GraphicsSurface
+ is being used as the front, the other one as the backbuffer.
+ Creating a QOpenGLContext currently requires showing a QWindow.
+ For the moment we therefore create a minimal QWindow and place
+ it offscreen.
+ (WebCore::GraphicsContext3DPrivate::copyToGraphicsSurface):
+ This new function is called from the WebGraphicsLayer,
+ to blit the multisample framebuffer and copy its contents
+ onto the GraphicsSurface.
+ (WebCore::GraphicsContext3DPrivate::createGraphicsSurfaces):
+ Whenever the GraphicsContext3D is being reshaped,
+ new GraphicsSurfaces must be created with the updated dimensions.
+ (WebCore::GraphicsContext3D::createGraphicsSurfaces):
+
+ * platform/graphics/texmap/TextureMapperPlatformLayer.h:
+ Added a new virtual function copyToGraphicsSurface.
+ (TextureMapperPlatformLayer):
+ (WebCore::TextureMapperPlatformLayer::copyToGraphicsSurface):
+
2012-06-02 Tony Chang <t...@chromium.org>
Rename the flexbox CSS propery values from start to flex-start and end to flex-end
Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (119317 => 119318)
--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h 2012-06-02 14:01:16 UTC (rev 119318)
@@ -911,6 +911,9 @@
bool reshapeFBOs(const IntSize&);
void resolveMultisamplingIfNecessary(const IntRect& = IntRect());
+#if PLATFORM(QT) && USE(GRAPHICS_SURFACE)
+ void createGraphicsSurfaces(const IntSize&);
+#endif
int m_currentWidth, m_currentHeight;
bool isResourceSafe();
Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (119317 => 119318)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp 2012-06-02 14:01:16 UTC (rev 119318)
@@ -222,6 +222,11 @@
if (width == m_currentWidth && height == m_currentHeight)
return;
+#if PLATFORM(QT) && USE(GRAPHICS_SURFACE)
+ ::glFlush(); // Make sure all GL calls have been committed before resizing.
+ createGraphicsSurfaces(IntSize(width, height));
+#endif
+
m_currentWidth = width;
m_currentHeight = height;
Modified: trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp (119317 => 119318)
--- trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp 2012-06-02 14:01:16 UTC (rev 119318)
@@ -28,6 +28,7 @@
#include "Extensions3DOpenGL.h"
#endif
#include "GraphicsContext.h"
+#include "GraphicsSurface.h"
#include "HTMLCanvasElement.h"
#include "HostWindow.h"
#include "ImageBuffer.h"
@@ -36,6 +37,9 @@
#include "OpenGLShims.h"
#include "QWebPageClient.h"
#include "SharedBuffer.h"
+#if HAVE(QT5)
+#include <QWindow>
+#endif
#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
@@ -67,16 +71,25 @@
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
#endif
+#if USE(GRAPHICS_SURFACE)
+ virtual uint32_t copyToGraphicsSurface();
+#endif
QRectF boundingRect() const;
void blitMultisampleFramebuffer() const;
void blitMultisampleFramebufferAndRestoreContext() const;
bool makeCurrentIfNeeded() const;
+ void createGraphicsSurfaces(const IntSize&);
GraphicsContext3D* m_context;
HostWindow* m_hostWindow;
PlatformGraphicsSurface3D m_surface;
PlatformGraphicsContext3D m_platformContext;
+#if USE(GRAPHICS_SURFACE)
+ GraphicsSurface::Flags m_surfaceFlags;
+ RefPtr<GraphicsSurface> m_frontBufferGraphicsSurface;
+ RefPtr<GraphicsSurface> m_backBufferGraphicsSurface;
+#endif
};
bool GraphicsContext3D::isGLES2Compliant() const
@@ -94,13 +107,40 @@
, m_surface(0)
, m_platformContext(0)
{
- QWebPageClient* webPageClient = m_hostWindow->platformPageClient();
- if (!webPageClient)
+ if (m_hostWindow && m_hostWindow->platformPageClient()) {
+ // This is the WebKit1 code path.
+ QWebPageClient* webPageClient = m_hostWindow->platformPageClient();
+ webPageClient->createPlatformGraphicsContext3D(&m_platformContext, &m_surface);
+ if (!m_surface)
+ return;
+
+ makeCurrentIfNeeded();
return;
- webPageClient->createPlatformGraphicsContext3D(&m_platformContext, &m_surface);
- if (!m_surface)
+ }
+
+#if USE(GRAPHICS_SURFACE)
+ // FIXME: Find a way to create a QOpenGLContext without creating a QWindow at all.
+ // We need to create a surface in order to create a QOpenGLContext and make it current.
+ QWindow* window = new QWindow;
+ window->setSurfaceType(QSurface::OpenGLSurface);
+ window->setGeometry(-10, -10, 1, 1);
+ window->create();
+ m_surface = window;
+
+ m_platformContext = new QOpenGLContext(window);
+ if (!m_platformContext->create())
return;
+
makeCurrentIfNeeded();
+ IntSize surfaceSize(m_context->m_currentWidth, m_context->m_currentHeight);
+ m_surfaceFlags = GraphicsSurface::SupportsTextureTarget
+ | GraphicsSurface::SupportsSharing;
+
+ if (!surfaceSize.isEmpty()) {
+ m_frontBufferGraphicsSurface = GraphicsSurface::create(surfaceSize, m_surfaceFlags);
+ m_backBufferGraphicsSurface = GraphicsSurface::create(surfaceSize, m_surfaceFlags);
+ }
+#endif
}
GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
@@ -174,6 +214,20 @@
}
#endif // USE(ACCELERATED_COMPOSITING)
+#if USE(GRAPHICS_SURFACE)
+uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
+{
+ if (!m_frontBufferGraphicsSurface || !m_backBufferGraphicsSurface)
+ return 0;
+
+ blitMultisampleFramebufferAndRestoreContext();
+ makeCurrentIfNeeded();
+ m_backBufferGraphicsSurface->copyFromFramebuffer(m_context->m_fbo, IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight));
+ std::swap(m_frontBufferGraphicsSurface, m_backBufferGraphicsSurface);
+ return m_frontBufferGraphicsSurface->exportToken();
+}
+#endif
+
QRectF GraphicsContext3DPrivate::boundingRect() const
{
return QRectF(QPointF(0, 0), QSizeF(m_context->m_currentWidth, m_context->m_currentHeight));
@@ -235,6 +289,19 @@
#endif
}
+void GraphicsContext3DPrivate::createGraphicsSurfaces(const IntSize& size)
+{
+#if USE(GRAPHICS_SURFACE)
+ if (size.isEmpty()) {
+ m_frontBufferGraphicsSurface.clear();
+ m_backBufferGraphicsSurface.clear();
+ } else {
+ m_frontBufferGraphicsSurface = GraphicsSurface::create(size, m_surfaceFlags);
+ m_backBufferGraphicsSurface = GraphicsSurface::create(size, m_surfaceFlags);
+ }
+#endif
+}
+
PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
{
// This implementation doesn't currently support rendering directly to the HostWindow.
@@ -407,6 +474,13 @@
context->restore();
}
+#if USE(GRAPHICS_SURFACE)
+void GraphicsContext3D::createGraphicsSurfaces(const IntSize& size)
+{
+ m_private->createGraphicsSurfaces(size);
+}
+#endif
+
#if defined(QT_OPENGL_ES_2)
PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData(DrawingBuffer*)
{
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h (119317 => 119318)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h 2012-06-02 14:01:16 UTC (rev 119318)
@@ -32,6 +32,9 @@
virtual ~TextureMapperPlatformLayer() { }
virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0, BitmapTexture* mask = 0) = 0;
virtual void swapBuffers() { }
+#if USE(GRAPHICS_SURFACE)
+ virtual uint32_t copyToGraphicsSurface() { return 0; }
+#endif
};
};
Modified: trunk/Source/WebKit2/ChangeLog (119317 => 119318)
--- trunk/Source/WebKit2/ChangeLog 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/ChangeLog 2012-06-02 14:01:16 UTC (rev 119318)
@@ -1,3 +1,64 @@
+2012-06-02 Zeno Albisser <z...@webkit.org>
+
+ Fix and enable WebGL for WebKit2 on Qt.
+ https://bugs.webkit.org/show_bug.cgi?id=86214
+
+ Added glue code to make use of GraphicsSurface
+ as a backend for the webgl-canvas in case of WK2.
+
+ Reviewed by Noam Rosenthal.
+
+ * UIProcess/API/qt/qwebpreferences.cpp:
+ (QWebPreferencesPrivate::testAttribute):
+ (QWebPreferencesPrivate::setAttribute):
+ (QWebPreferences::webGLEnabled):
+ (QWebPreferences::setWebGLEnabled):
+ * UIProcess/API/qt/qwebpreferences_p.h:
+ * UIProcess/API/qt/qwebpreferences_p_p.h:
+ Added WebGLEnabled enum to allow enabling/disabling of
+ WebGL using QWebPreferences.
+
+ * UIProcess/LayerTreeHostProxy.cpp:
+ (WebKit::LayerTreeHostProxy::syncCanvas):
+ Dispatch syncCanvas calls to the apropriate
+ WebLayerTreeRenderer.
+
+ * UIProcess/LayerTreeHostProxy.h:
+ (LayerTreeHostProxy):
+ * UIProcess/LayerTreeHostProxy.messages.in:
+ * UIProcess/WebLayerTreeRenderer.h:
+ (WebLayerTreeRenderer):
+ * UIProcess/WebLayerTreeRenderer.cpp:
+ (WebKit::WebLayerTreeRenderer::syncCanvas):
+ (WebKit::WebLayerTreeRenderer::deleteLayer):
+ (WebKit::WebLayerTreeRenderer::purgeGLResources):
+ Create a TextureMapperSurfaceBackingStore for the canvas
+ if necessary and pass or update the graphicsSurfaceToken
+ for to be used with the backing store.
+
+ * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
+ (WebCore::WebGraphicsLayer::WebGraphicsLayer):
+ (WebCore):
+ (WebCore::WebGraphicsLayer::setContentsToCanvas):
+ (WebCore::WebGraphicsLayer::syncCanvas):
+ Copy the multisample framebuffer contents onto the GraphicsSurface.
+ Notify the UIProcess of the availability of a new texture.
+ (WebCore::WebGraphicsLayer::syncCompositingStateForThisLayerOnly):
+ Sync the canvas as well.
+
+ * WebProcess/WebCoreSupport/WebGraphicsLayer.h:
+ Added a pure virtual function syncCanvas.
+ This is guarded by PLATFORM(QT).
+ (WebGraphicsLayerClient):
+ (WebGraphicsLayer):
+
+ * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
+ (WebKit::LayerTreeHostQt::syncLayerChildren):
+ (WebKit):
+ (WebKit::LayerTreeHostQt::syncCanvas):
+ * WebProcess/WebPage/qt/LayerTreeHostQt.h:
+ (LayerTreeHostQt):
+
2012-06-01 Brady Eidson <beid...@apple.com>
<rdar://problem/11335622> and https://bugs.webkit.org/show_bug.cgi?id=88119
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp (119317 => 119318)
--- trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp 2012-06-02 14:01:16 UTC (rev 119318)
@@ -63,6 +63,10 @@
return WKPreferencesGetFrameFlatteningEnabled(preferencesRef());
case DeveloperExtrasEnabled:
return WKPreferencesGetDeveloperExtrasEnabled(preferencesRef());
+#if ENABLE(WEBGL)
+ case WebGLEnabled:
+ return WKPreferencesGetWebGLEnabled(preferencesRef());
+#endif
default:
ASSERT_NOT_REACHED();
return false;
@@ -106,6 +110,11 @@
case DeveloperExtrasEnabled:
WKPreferencesSetDeveloperExtrasEnabled(preferencesRef(), enable);
break;
+#if ENABLE(WEBGL)
+ case WebGLEnabled:
+ WKPreferencesSetWebGLEnabled(preferencesRef(), enable);
+ break;
+#endif
default:
ASSERT_NOT_REACHED();
}
@@ -476,6 +485,25 @@
emit defaultFixedFontSizeChanged();
}
+bool QWebPreferences::webGLEnabled() const
+{
+#if ENABLE(WEBGL)
+ return d->testAttribute(QWebPreferencesPrivate::WebGLEnabled);
+#else
+ return false;
+#endif
+}
+
+void QWebPreferences::setWebGLEnabled(bool enable)
+{
+#if ENABLE(WEBGL)
+ d->setAttribute(QWebPreferencesPrivate::WebGLEnabled, enable);
+ emit webGLEnabledChanged();
+#else
+ UNUSED_PARAM(enable);
+#endif
+}
+
WKPreferencesRef QWebPreferencesPrivate::preferencesRef() const
{
WKPageGroupRef pageGroupRef = toAPI(webViewPrivate->webPageProxy->pageGroup());
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h (119317 => 119318)
--- trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h 2012-06-02 14:01:16 UTC (rev 119318)
@@ -43,6 +43,7 @@
Q_PROPERTY(bool navigatorQtObjectEnabled READ navigatorQtObjectEnabled WRITE setNavigatorQtObjectEnabled NOTIFY navigatorQtObjectEnabledChanged FINAL)
Q_PROPERTY(bool frameFlatteningEnabled READ frameFlatteningEnabled WRITE setFrameFlatteningEnabled NOTIFY frameFlatteningEnabledChanged FINAL)
Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled NOTIFY developerExtrasEnabledChanged FINAL)
+ Q_PROPERTY(bool webGLEnabled READ webGLEnabled WRITE setWebGLEnabled NOTIFY webGLEnabledChanged FINAL)
Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily NOTIFY standardFontFamilyChanged FINAL)
Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily NOTIFY fixedFontFamilyChanged FINAL)
@@ -91,6 +92,9 @@
bool developerExtrasEnabled() const;
void setDeveloperExtrasEnabled(bool enable);
+ bool webGLEnabled() const;
+ void setWebGLEnabled(bool enable);
+
QString standardFontFamily() const;
void setStandardFontFamily(const QString& family);
@@ -131,6 +135,7 @@
void navigatorQtObjectEnabledChanged();
void frameFlatteningEnabledChanged();
void developerExtrasEnabledChanged();
+ void webGLEnabledChanged();
void standardFontFamilyChanged();
void fixedFontFamilyChanged();
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h (119317 => 119318)
--- trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h 2012-06-02 14:01:16 UTC (rev 119318)
@@ -38,7 +38,8 @@
FrameFlatteningEnabled,
PrivateBrowsingEnabled,
DnsPrefetchEnabled,
- DeveloperExtrasEnabled
+ DeveloperExtrasEnabled,
+ WebGLEnabled
};
enum FontFamily {
Modified: trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp (119317 => 119318)
--- trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp 2012-06-02 14:01:16 UTC (rev 119318)
@@ -150,6 +150,11 @@
dispatchUpdate(bind(&WebLayerTreeRenderer::didChangeScrollPosition, m_renderer.get(), position));
}
+void LayerTreeHostProxy::syncCanvas(uint32_t id, const IntSize& canvasSize, uint32_t graphicsSurfaceToken)
+{
+ dispatchUpdate(bind(&WebLayerTreeRenderer::syncCanvas, m_renderer.get(), id, canvasSize, graphicsSurfaceToken));
+}
+
void LayerTreeHostProxy::purgeBackingStores()
{
m_renderer->setActive(false);
Modified: trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.h (119317 => 119318)
--- trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.h 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.h 2012-06-02 14:01:16 UTC (rev 119318)
@@ -69,6 +69,7 @@
void updateViewport();
void renderNextFrame();
void didChangeScrollPosition(const WebCore::IntPoint& position);
+ void syncCanvas(uint32_t id, const WebCore::IntSize& canvasSize, uint32_t graphicsSurfaceToken);
void purgeBackingStores();
WebLayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); }
Modified: trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in (119317 => 119318)
--- trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in 2012-06-02 14:01:16 UTC (rev 119318)
@@ -33,5 +33,6 @@
DestroyDirectlyCompositedImage(int64_t key)
DidRenderFrame()
DidChangeScrollPosition(WebCore::IntPoint position)
+ SyncCanvas(uint32_t id, WebCore::IntSize canvasSize, uint32_t graphicsSurfaceToken)
}
#endif
Modified: trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp (119317 => 119318)
--- trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp 2012-06-02 14:01:16 UTC (rev 119318)
@@ -30,6 +30,7 @@
#include "ShareableBitmap.h"
#include "TextureMapper.h"
#include "TextureMapperBackingStore.h"
+#include "TextureMapperGL.h"
#include "TextureMapperLayer.h"
#include "UpdateInfo.h"
#include <OpenGLShims.h>
@@ -194,6 +195,28 @@
m_pendingRenderedContentsScrollPosition = boundedScrollPosition(position, m_visibleContentsRect, m_contentsSize);
}
+void WebLayerTreeRenderer::syncCanvas(WebLayerID id, const WebCore::IntSize& canvasSize, uint32_t graphicsSurfaceToken)
+{
+ if (canvasSize.isEmpty() || !m_textureMapper)
+ return;
+
+#if USE(GRAPHICS_SURFACE)
+ ensureLayer(id);
+ GraphicsLayer* layer = layerByID(id);
+
+ RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore;
+ SurfaceBackingStoreMap::iterator it = m_surfaceBackingStores.find(id);
+ if (it == m_surfaceBackingStores.end()) {
+ canvasBackingStore = TextureMapperSurfaceBackingStore::create();
+ m_surfaceBackingStores.set(id, canvasBackingStore);
+ } else
+ canvasBackingStore = it->second;
+
+ canvasBackingStore->setGraphicsSurface(graphicsSurfaceToken, canvasSize);
+ layer->setContentsToMedia(canvasBackingStore.get());
+#endif
+}
+
void WebLayerTreeRenderer::setLayerChildren(WebLayerID id, const Vector<WebLayerID>& childIDs)
{
ensureLayer(id);
@@ -271,6 +294,9 @@
layer->removeFromParent();
m_layers.remove(layerID);
m_fixedLayers.remove(layerID);
+#if USE(GRAPHICS_SURFACE)
+ m_surfaceBackingStores.remove(layerID);
+#endif
delete layer;
}
@@ -419,6 +445,9 @@
layer->clearBackingStoresRecursive();
m_directlyCompositedImages.clear();
+#if USE(GRAPHICS_SURFACE)
+ m_surfaceBackingStores.clear();
+#endif
m_rootLayer->removeAllChildren();
m_rootLayer.clear();
Modified: trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h (119317 => 119318)
--- trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h 2012-06-02 14:01:16 UTC (rev 119318)
@@ -22,6 +22,7 @@
#if USE(UI_SIDE_COMPOSITING)
#include "BackingStore.h"
+#include "GraphicsSurface.h"
#include "ShareableSurface.h"
#include "TextureMapper.h"
#include "TextureMapperBackingStore.h"
@@ -67,6 +68,7 @@
void setContentsSize(const WebCore::FloatSize&);
void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint& accurateVisibleContentsPosition);
void didChangeScrollPosition(const WebCore::IntPoint& position);
+ void syncCanvas(uint32_t id, const WebCore::IntSize& canvasSize, uint32_t graphicsSurfaceToken);
void detach();
void appendUpdate(const Function<void()>&);
@@ -118,6 +120,10 @@
HashMap<int64_t, RefPtr<WebCore::TextureMapperBackingStore> > m_directlyCompositedImages;
HashSet<RefPtr<LayerBackingStore> > m_backingStoresWithPendingBuffers;
#endif
+#if USE(GRAPHICS_SURFACE)
+ typedef HashMap<WebLayerID, RefPtr<WebCore::TextureMapperSurfaceBackingStore> > SurfaceBackingStoreMap;
+ SurfaceBackingStoreMap m_surfaceBackingStores;
+#endif
void scheduleWebViewUpdate();
void synchronizeViewport();
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp (119317 => 119318)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp 2012-06-02 14:01:16 UTC (rev 119318)
@@ -30,6 +30,7 @@
#include "GraphicsLayer.h"
#include "LayerTreeHostProxyMessages.h"
#include "Page.h"
+#include "TextureMapperPlatformLayer.h"
#include "TiledBackingStoreRemoteTile.h"
#include "WebPage.h"
#include <wtf/CurrentTime.h>
@@ -109,8 +110,10 @@
, m_shouldSyncLayerState(true)
, m_shouldSyncChildren(true)
, m_fixedToViewport(false)
+ , m_canvasNeedsDisplay(false)
, m_webGraphicsLayerClient(0)
, m_contentsScale(1)
+ , m_canvasPlatformLayer(0)
{
static WebLayerID nextLayerID = 1;
m_id = nextLayerID++;
@@ -316,8 +319,17 @@
RefPtr<Image> image = m_image;
setContentsToImage(0);
setContentsToImage(image.get());
+ m_canvasNeedsDisplay = true;
}
+void WebGraphicsLayer::setContentsToCanvas(PlatformLayer* platformLayer)
+{
+ m_canvasPlatformLayer = platformLayer;
+ m_canvasNeedsDisplay = true;
+ if (client())
+ client()->notifySyncRequired(this);
+}
+
#if ENABLE(CSS_FILTERS)
bool WebGraphicsLayer::setFilters(const FilterOperations& newFilters)
{
@@ -468,6 +480,21 @@
m_webGraphicsLayerClient->syncLayerState(m_id, m_layerInfo);
}
+void WebGraphicsLayer::syncCanvas()
+{
+ if (!m_canvasNeedsDisplay)
+ return;
+
+ if (!m_canvasPlatformLayer)
+ return;
+
+#if USE(GRAPHICS_SURFACE)
+ uint32_t graphicsSurfaceToken = m_canvasPlatformLayer->copyToGraphicsSurface();
+ m_webGraphicsLayerClient->syncCanvas(m_id, IntSize(size().width(), size().height()), graphicsSurfaceToken);
+#endif
+ m_canvasNeedsDisplay = false;
+}
+
void WebGraphicsLayer::ensureImageBackingStore()
{
if (!m_image)
@@ -475,6 +502,7 @@
if (!m_layerInfo.imageBackingStoreID)
m_layerInfo.imageBackingStoreID = m_webGraphicsLayerClient->adoptImageBackingStore(m_image.get());
}
+
void WebGraphicsLayer::syncCompositingStateForThisLayerOnly()
{
// The remote image might have been released by purgeBackingStores.
@@ -486,6 +514,7 @@
syncFilters();
#endif
updateContentBuffers();
+ syncCanvas();
}
void WebGraphicsLayer::tiledBackingStorePaintBegin()
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h (119317 => 119318)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h 2012-06-02 14:01:16 UTC (rev 119318)
@@ -60,6 +60,9 @@
#if ENABLE(CSS_FILTERS)
virtual void syncLayerFilters(WebLayerID, const WebCore::FilterOperations&) = 0;
#endif
+#if PLATFORM(QT)
+ virtual void syncCanvas(WebLayerID, const WebCore::IntSize& canvasSize, uint32_t graphicsSurfaceToken) = 0;
+#endif
virtual void attachLayer(WebCore::WebGraphicsLayer*) = 0;
virtual void detachLayer(WebCore::WebGraphicsLayer*) = 0;
virtual void syncFixedLayers() = 0;
@@ -98,6 +101,7 @@
void setOpacity(float);
void setContentsRect(const IntRect&);
void setContentsToImage(Image*);
+ void setContentsToCanvas(PlatformLayer*);
void setMaskLayer(GraphicsLayer*);
void setReplicatedByLayer(GraphicsLayer*);
void setNeedsDisplay();
@@ -147,6 +151,7 @@
#if ENABLE(CSS_FILTERS)
void syncFilters();
#endif
+ void syncCanvas();
void ensureImageBackingStore();
void adjustVisibleRect();
@@ -168,6 +173,7 @@
bool m_shouldSyncChildren: 1;
bool m_shouldSyncFilters: 1;
bool m_fixedToViewport : 1;
+ bool m_canvasNeedsDisplay : 1;
void notifyChange();
void didChangeGeometry();
@@ -191,6 +197,7 @@
OwnPtr<WebCore::TiledBackingStore> m_mainBackingStore;
OwnPtr<WebCore::TiledBackingStore> m_previousBackingStore;
float m_contentsScale;
+ PlatformLayer* m_canvasPlatformLayer;
};
WebGraphicsLayer* toWebGraphicsLayer(GraphicsLayer*);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp (119317 => 119318)
--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp 2012-06-02 14:01:16 UTC (rev 119318)
@@ -256,6 +256,12 @@
m_webPage->send(Messages::LayerTreeHostProxy::SetCompositingLayerChildren(id, children));
}
+void LayerTreeHostQt::syncCanvas(WebLayerID id, const IntSize& canvasSize, uint32_t graphicsSurfaceToken)
+{
+ m_shouldSyncFrame = true;
+ m_webPage->send(Messages::LayerTreeHostProxy::SyncCanvas(id, canvasSize, graphicsSurfaceToken));
+}
+
#if ENABLE(CSS_FILTERS)
void LayerTreeHostQt::syncLayerFilters(WebLayerID id, const FilterOperations& filters)
{
Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h (119317 => 119318)
--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h 2012-06-02 14:01:16 UTC (rev 119318)
@@ -79,6 +79,7 @@
#if ENABLE(CSS_FILTERS)
virtual void syncLayerFilters(WebLayerID, const WebCore::FilterOperations&);
#endif
+ virtual void syncCanvas(WebLayerID, const WebCore::IntSize& canvasSize, uint32_t graphicsSurfaceToken) OVERRIDE;
virtual void attachLayer(WebCore::WebGraphicsLayer*);
virtual void detachLayer(WebCore::WebGraphicsLayer*);
virtual void syncFixedLayers();
Modified: trunk/Tools/ChangeLog (119317 => 119318)
--- trunk/Tools/ChangeLog 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Tools/ChangeLog 2012-06-02 14:01:16 UTC (rev 119318)
@@ -1,3 +1,14 @@
+2012-06-02 Zeno Albisser <z...@webkit.org>
+
+ Fix and enable WebGL for WebKit2 on Qt.
+ https://bugs.webkit.org/show_bug.cgi?id=86214
+
+ Enable WebGL by default for Qt MiniBrowser.
+
+ Reviewed by Noam Rosenthal.
+
+ * MiniBrowser/qt/qml/BrowserWindow.qml:
+
2012-06-02 Ryosuke Niwa <rn...@webkit.org>
Teach svn-apply how to apply changes in test_expectations.txt to TestExpectations
Modified: trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml (119317 => 119318)
--- trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml 2012-06-02 09:46:15 UTC (rev 119317)
+++ trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml 2012-06-02 14:01:16 UTC (rev 119318)
@@ -335,6 +335,7 @@
experimental.devicePixelRatio: 1.5
experimental.preferences.fullScreenEnabled: true
+ experimental.preferences.webGLEnabled: true
experimental.preferredMinimumContentsWidth: 980
experimental.itemSelector: ItemSelector { }
experimental.alertDialog: AlertDialog { }