[GTK] [WebKit2] Use XComposite window for accelerated compositing
authormrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Sep 2012 17:54:14 +0000 (17:54 +0000)
committermrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Sep 2012 17:54:14 +0000 (17:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94417

Reviewed by Carlos Garcia Campos.

Instead of rendering directly to the widget's native window, render to an
offscreen window redirected to a Pixmap with XComposite.

Source/WebCore:

No new tests. This will be covered by the existing accelerated compositing tests,
which should now give correct pixel results.

* platform/gtk/RedirectedXCompositeWindow.cpp:
(WebCore::RedirectedXCompositeWindow::resize): Add a call to XFlush which ensures
that pending X11 operations complete.
* platform/gtk/RedirectedXCompositeWindow.h:
(WebCore::RedirectedXCompositeWindow::windowId): Added this accessor.

Source/WebKit2:

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(_WebKitWebViewBasePrivate): Added a few members necessary to track the
offscreen window.
(webkit_web_view_base_init):
(renderAcceleratedCompositingResults): Added this helper functions which renders
the results of the accelerated compositing operations during the GTK+ draw loop.
(webkitWebViewBaseDraw): Call renderAcceleratedCompositingResults when appropriate.
(resizeWebKitWebViewBaseFromAllocation): Resize the offscreen window when appropriate.
(webkitWebViewBaseSizeAllocate): Do not call resizeWebKitWebViewBaseFromAllocation when
the actual size of the widget does not change. This prevents destroying and recreating
the offscreen window pixmap when it isn't necessary.
(webkitWebViewBaseMap): We no longer send the window id during map, instead it's sent
as soon as there is WebPageProxy.
(webkitWebViewBaseCreateWebPage): Send the window id of the redirected window to
the WebProcess.
(queueAnotherDrawOfAcceleratedCompositingResults): Added this helper which works
around the issue of slow updates of the pixmap backing the redirected XComposite window.
(webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults): Added this method which
is what the WebProcess uses to force a redraw on the UIProcess side.
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h: Added new method to the list of private methods.
* UIProcess/DrawingAreaProxyImpl.h:
(DrawingAreaProxyImpl):
(WebKit::DrawingAreaProxyImpl::isInAcceleratedCompositingMode): Exposed this method publically
so that it can be used from WebKitWebViewBase.
* UIProcess/WebPageProxy.h:
(WebPageProxy): Renamed widgetMapped to setAcceleratedCompositingWindowId.
* UIProcess/WebPageProxy.messages.in: Ditto.
* UIProcess/gtk/WebPageProxyGtk.cpp: Ditto.
(WebKit::WebPageProxy::setAcceleratedCompositingWindowId):
* WebProcess/WebPage/WebPage.h:
(WebPage): Ditto.
* WebProcess/WebPage/WebPage.messages.in: Ditto.
* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::sizeDidChange): Force a composite to the resized window right
away so that the new window pixmap is updated before the first draw.
(WebKit::LayerTreeHostGtk::compositeLayersToContext): If the composition is for a resize,
first clear the entire GL context so that we don't see black artifacts during resize.
* WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
(LayerTreeHostGtk): Update the signature of  compositeLayersToContext.
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::setAcceleratedCompositingWindowId): Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@128907 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp
Source/WebCore/platform/gtk/RedirectedXCompositeWindow.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp
Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h
Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp

index e854b22..0c9e705 100644 (file)
@@ -1,3 +1,22 @@
+2012-09-18  Martin Robinson  <mrobinson@igalia.com>
+
+        [GTK] [WebKit2] Use XComposite window for accelerated compositing
+        https://bugs.webkit.org/show_bug.cgi?id=94417
+
+        Reviewed by Carlos Garcia Campos.
+
+        Instead of rendering directly to the widget's native window, render to an
+        offscreen window redirected to a Pixmap with XComposite.
+
+        No new tests. This will be covered by the existing accelerated compositing tests,
+        which should now give correct pixel results.
+
+        * platform/gtk/RedirectedXCompositeWindow.cpp:
+        (WebCore::RedirectedXCompositeWindow::resize): Add a call to XFlush which ensures
+        that pending X11 operations complete.
+        * platform/gtk/RedirectedXCompositeWindow.h:
+        (WebCore::RedirectedXCompositeWindow::windowId): Added this accessor.
+
 2012-09-18  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Tables without any descendant and auto logical width should have a 0px logical width
index 1572a59..480b53f 100644 (file)
@@ -137,6 +137,8 @@ void RedirectedXCompositeWindow::resize(const IntSize& size)
 
     Display* display = GLContextGLX::sharedDisplay();
     XResizeWindow(display, m_window, size.width(), size.height());
+
+    XFlush(display);
     glXWaitX();
 
     // This swap is based on code in Chromium. It tries to work-around a bug in the Intel drivers
index d6cd747..e5db0fa 100644 (file)
@@ -49,6 +49,7 @@ public:
     void resize(const IntSize& newSize);
     GLContext* context();
     cairo_surface_t* cairoSurfaceForWidget(GtkWidget*);
+    Window windowId() { return m_window; }
 
 private:
     RedirectedXCompositeWindow(const IntSize&);
index 1a70131..ff5a1c1 100644 (file)
@@ -1,3 +1,55 @@
+2012-09-18  Martin Robinson  <mrobinson@igalia.com>
+
+        [GTK] [WebKit2] Use XComposite window for accelerated compositing
+        https://bugs.webkit.org/show_bug.cgi?id=94417
+
+        Reviewed by Carlos Garcia Campos.
+
+        Instead of rendering directly to the widget's native window, render to an
+        offscreen window redirected to a Pixmap with XComposite.
+
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (_WebKitWebViewBasePrivate): Added a few members necessary to track the 
+        offscreen window.
+        (webkit_web_view_base_init):
+        (renderAcceleratedCompositingResults): Added this helper functions which renders
+        the results of the accelerated compositing operations during the GTK+ draw loop.
+        (webkitWebViewBaseDraw): Call renderAcceleratedCompositingResults when appropriate.
+        (resizeWebKitWebViewBaseFromAllocation): Resize the offscreen window when appropriate.
+        (webkitWebViewBaseSizeAllocate): Do not call resizeWebKitWebViewBaseFromAllocation when
+        the actual size of the widget does not change. This prevents destroying and recreating
+        the offscreen window pixmap when it isn't necessary.
+        (webkitWebViewBaseMap): We no longer send the window id during map, instead it's sent
+        as soon as there is WebPageProxy.
+        (webkitWebViewBaseCreateWebPage): Send the window id of the redirected window to
+        the WebProcess.
+        (queueAnotherDrawOfAcceleratedCompositingResults): Added this helper which works
+        around the issue of slow updates of the pixmap backing the redirected XComposite window.
+        (webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults): Added this method which
+        is what the WebProcess uses to force a redraw on the UIProcess side.
+        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h: Added new method to the list of private methods.
+        * UIProcess/DrawingAreaProxyImpl.h:
+        (DrawingAreaProxyImpl):
+        (WebKit::DrawingAreaProxyImpl::isInAcceleratedCompositingMode): Exposed this method publically
+        so that it can be used from WebKitWebViewBase.
+        * UIProcess/WebPageProxy.h:
+        (WebPageProxy): Renamed widgetMapped to setAcceleratedCompositingWindowId.
+        * UIProcess/WebPageProxy.messages.in: Ditto.
+        * UIProcess/gtk/WebPageProxyGtk.cpp: Ditto.
+        (WebKit::WebPageProxy::setAcceleratedCompositingWindowId):
+        * WebProcess/WebPage/WebPage.h:
+        (WebPage): Ditto.
+        * WebProcess/WebPage/WebPage.messages.in: Ditto.
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
+        (WebKit::LayerTreeHostGtk::sizeDidChange): Force a composite to the resized window right
+        away so that the new window pixmap is updated before the first draw.
+        (WebKit::LayerTreeHostGtk::compositeLayersToContext): If the composition is for a resize,
+        first clear the entire GL context so that we don't see black artifacts during resize.
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.h:
+        (LayerTreeHostGtk): Update the signature of  compositeLayersToContext.
+        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+        (WebKit::WebPage::setAcceleratedCompositingWindowId): Added.
+
 2012-09-18  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r128849.
index 0482b34..23b02f6 100644 (file)
@@ -67,7 +67,7 @@
 #endif
 
 #if USE(TEXTURE_MAPPER_GL) && defined(GDK_WINDOWING_X11)
-#include <gdk/gdkx.h>
+#include <WebCore/RedirectedXCompositeWindow.h>
 #endif
 
 using namespace WebKit;
@@ -90,14 +90,20 @@ struct _WebKitWebViewBasePrivate {
     IntSize resizerSize;
     GRefPtr<AtkObject> accessible;
     bool needsResizeOnMap;
-#if ENABLE(FULLSCREEN_API)
-    bool fullScreenModeActive;
-    WebFullScreenClientGtk fullScreenClient;
-#endif
     GtkWidget* inspectorView;
     unsigned inspectorViewHeight;
     GOwnPtr<GdkEvent> contextMenuEvent;
     WebContextMenuProxyGtk* activeContextMenuProxy;
+
+#if ENABLE(FULLSCREEN_API)
+    bool fullScreenModeActive;
+    WebFullScreenClientGtk fullScreenClient;
+#endif
+
+#if USE(TEXTURE_MAPPER_GL)
+    OwnPtr<RedirectedXCompositeWindow> redirectedWindow;
+    bool readyToRenderAcceleratedCompositingResults;
+#endif
 };
 
 G_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
@@ -162,9 +168,6 @@ static void webkitWebViewBaseRealize(GtkWidget* widget)
     gint attributesMask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
 
     GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributesMask);
-#if USE(TEXTURE_MAPPER_GL)
-    gdk_window_ensure_native(window);
-#endif
     gtk_widget_set_window(widget, window);
     gdk_window_set_user_data(window, widget);
 
@@ -264,7 +267,6 @@ static void webkit_web_view_base_init(WebKitWebViewBase* webkitWebViewBase)
     priv->shouldForwardNextKeyEvent = FALSE;
 
     GtkWidget* viewWidget = GTK_WIDGET(webkitWebViewBase);
-    gtk_widget_set_double_buffered(viewWidget, FALSE);
     gtk_widget_set_can_focus(viewWidget, TRUE);
     priv->imContext = adoptGRef(gtk_im_multicontext_new());
 
@@ -275,11 +277,38 @@ static void webkit_web_view_base_init(WebKitWebViewBase* webkitWebViewBase)
     gtk_drag_dest_set(viewWidget, static_cast<GtkDestDefaults>(0), 0, 0,
                       static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE));
     gtk_drag_dest_set_target_list(viewWidget, PasteboardHelper::defaultPasteboardHelper()->targetList());
+
+#if USE(TEXTURE_MAPPER_GL)
+    priv->redirectedWindow = RedirectedXCompositeWindow::create(IntSize(1, 1));
+    priv->readyToRenderAcceleratedCompositingResults = false;
+#endif
+}
+
+#if USE(TEXTURE_MAPPER_GL)
+static bool webkitWebViewRenderAcceleratedCompositingResults(WebKitWebViewBase* webViewBase, DrawingAreaProxyImpl* drawingArea, cairo_t* cr, GdkRectangle* clipRect)
+{
+    if (!drawingArea->isInAcceleratedCompositingMode())
+        return false;
+
+    // To avoid flashes when initializing accelerated compositing for the first
+    // time, we wait until we know there's a frame ready before rendering.
+    WebKitWebViewBasePrivate* priv = webViewBase->priv;
+    if (!priv->readyToRenderAcceleratedCompositingResults)
+        return false;
+
+    ASSERT(priv->redirectedWindow);
+    cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
+    cairo_surface_t* surface = priv->redirectedWindow->cairoSurfaceForWidget(GTK_WIDGET(webViewBase));
+    cairo_set_source_surface(cr, surface, 0, 0);
+    cairo_fill(cr);
+    return true;
 }
+#endif
 
 static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr)
 {
-    DrawingAreaProxy* drawingArea = WEBKIT_WEB_VIEW_BASE(widget)->priv->pageProxy->drawingArea();
+    WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+    DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(webViewBase->priv->pageProxy->drawingArea());
     if (!drawingArea)
         return FALSE;
 
@@ -287,8 +316,13 @@ static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr)
     if (!gdk_cairo_get_clip_rectangle(cr, &clipRect))
         return FALSE;
 
+#if USE(TEXTURE_MAPPER_GL)
+    if (webkitWebViewRenderAcceleratedCompositingResults(webViewBase, drawingArea, cr, &clipRect))
+        return FALSE;
+#endif
+
     WebCore::Region unpaintedRegion; // This is simply unused.
-    static_cast<DrawingAreaProxyImpl*>(drawingArea)->paint(cr, clipRect, unpaintedRegion);
+    drawingArea->paint(cr, clipRect, unpaintedRegion);
 
     return FALSE;
 }
@@ -309,7 +343,7 @@ static void webkitWebViewBaseChildAllocate(GtkWidget* child, gpointer userData)
     priv->children.set(child, IntRect());
 }
 
-static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase, GtkAllocation* allocation)
+static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase, GtkAllocation* allocation, bool sizeChanged)
 {
     gtk_container_foreach(GTK_CONTAINER(webViewBase), webkitWebViewBaseChildAllocate, webViewBase);
 
@@ -324,6 +358,11 @@ static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase
         viewRect.setHeight(allocation->height - priv->inspectorViewHeight);
     }
 
+#if USE(TEXTURE_MAPPER_GL)
+    if (sizeChanged)
+        webViewBase->priv->redirectedWindow->resize(viewRect.size());
+#endif
+
     if (priv->pageProxy->drawingArea())
         priv->pageProxy->drawingArea()->setSize(viewRect.size(), IntSize());
 
@@ -334,14 +373,18 @@ static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase
 
 static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, GtkAllocation* allocation)
 {
+    bool sizeChanged = gtk_widget_get_allocated_width(widget) != allocation->width
+                       || gtk_widget_get_allocated_height(widget) != allocation->height;
+
     GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->size_allocate(widget, allocation);
 
     WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
-    if (!gtk_widget_get_mapped(GTK_WIDGET(webViewBase)) && !webViewBase->priv->pageProxy->drawingArea()->size().isEmpty()) {
+    if (sizeChanged && !gtk_widget_get_mapped(widget) && !webViewBase->priv->pageProxy->drawingArea()->size().isEmpty()) {
         webViewBase->priv->needsResizeOnMap = true;
         return;
     }
-    resizeWebKitWebViewBaseFromAllocation(webViewBase, allocation);
+
+    resizeWebKitWebViewBaseFromAllocation(webViewBase, allocation, sizeChanged);
 }
 
 static void webkitWebViewBaseMap(GtkWidget* widget)
@@ -349,19 +392,12 @@ static void webkitWebViewBaseMap(GtkWidget* widget)
     GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->map(widget);
 
     WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
-#if USE(TEXTURE_MAPPER_GL) && defined(GDK_WINDOWING_X11)
-    GdkWindow* gdkWindow = gtk_widget_get_window(widget);
-    ASSERT(gdkWindow);
-    if (gdk_window_has_native(gdkWindow))
-        webViewBase->priv->pageProxy->widgetMapped(GDK_WINDOW_XID(gdkWindow));
-#endif
-
     if (!webViewBase->priv->needsResizeOnMap)
         return;
 
     GtkAllocation allocation;
     gtk_widget_get_allocation(widget, &allocation);
-    resizeWebKitWebViewBaseFromAllocation(webViewBase, &allocation);
+    resizeWebKitWebViewBaseFromAllocation(webViewBase, &allocation, true /* sizeChanged */);
     webViewBase->priv->needsResizeOnMap = false;
 }
 
@@ -680,6 +716,10 @@ void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WKCont
 #if ENABLE(FULLSCREEN_API)
     priv->pageProxy->fullScreenManager()->setWebView(webkitWebViewBase);
 #endif
+
+#if USE(TEXTURE_MAPPER_GL)
+    priv->pageProxy->setAcceleratedCompositingWindowId(priv->redirectedWindow->windowId());
+#endif
 }
 
 void webkitWebViewBaseSetTooltipText(WebKitWebViewBase* webViewBase, const char* tooltip)
@@ -803,3 +843,38 @@ GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase* webkitWebView
 {
     return webkitWebViewBase->priv->contextMenuEvent.release();
 }
+
+#if USE(TEXTURE_MAPPER_GL)
+static gboolean queueAnotherDrawOfAcceleratedCompositingResults(gpointer* webViewBasePointer)
+{
+    // The WebViewBase may have been destroyed in the time since we queued this
+    // draw and the time we are actually executing.
+    if (!*webViewBasePointer) {
+        fastFree(webViewBasePointer);
+        return FALSE;
+    }
+
+    WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(*webViewBasePointer);
+    gtk_widget_queue_draw(GTK_WIDGET(webViewBase));
+    webViewBase->priv->readyToRenderAcceleratedCompositingResults = true;
+
+    g_object_remove_weak_pointer(G_OBJECT(webViewBase), webViewBasePointer);
+    fastFree(webViewBasePointer);
+
+    return FALSE;
+}
+
+void webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults(WebKitWebViewBase* webViewBase)
+{
+    gtk_widget_queue_draw(GTK_WIDGET(webViewBase));
+
+    // Redraw again, one frame later, as it might take some time for the new GL frame to be available.
+    // This prevents the display from always being one frame behind in the case GL hasn't yet finished
+    // rendering to the window.
+    // TODO: Add XDamage support to RedirectedXCompositeWindow to accomplish this.
+    gpointer* webViewBasePointer = static_cast<gpointer*>(fastMalloc(sizeof(gpointer)));
+    g_object_add_weak_pointer(G_OBJECT(webViewBase), webViewBasePointer);
+    *webViewBasePointer = webViewBase;
+    g_timeout_add(1000 / 60, reinterpret_cast<GSourceFunc>(queueAnotherDrawOfAcceleratedCompositingResults), webViewBasePointer);
+}
+#endif
index 1295f3d..031e5d5 100644 (file)
@@ -52,4 +52,8 @@ void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase*, WebContextMe
 WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase*);
 GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase*);
 
+#if USE(TEXTURE_MAPPER_GL)
+void webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults(WebKitWebViewBase*);
+#endif
+
 #endif // WebKitWebViewBasePrivate_h
index 0c9f04f..762e35c 100644 (file)
@@ -48,6 +48,10 @@ public:
 
     void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, WebCore::Region& unpaintedRegion);
 
+#if USE(ACCELERATED_COMPOSITING)
+    bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }
+#endif
+
 private:
     explicit DrawingAreaProxyImpl(WebPageProxy*);
 
@@ -78,9 +82,6 @@ private:
     void enterAcceleratedCompositingMode(const LayerTreeContext&);
     void exitAcceleratedCompositingMode();
     void updateAcceleratedCompositingMode(const LayerTreeContext&);
-
-    bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }
-
 #if USE(COORDINATED_GRAPHICS)
     virtual void setVisibleContentsRect(const WebCore::FloatRect& visibleContentsRect, float scale, const WebCore::FloatPoint& trajectory);
     void didReceiveLayerTreeCoordinatorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
index c4d2743..28c5da9 100644 (file)
@@ -714,7 +714,8 @@ public:
     virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent();
 
 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
-    void widgetMapped(uint64_t nativeWindowId);
+    void setAcceleratedCompositingWindowId(uint64_t nativeWindowId);
+    void invalidateWidget();
 #endif
 
     void setSuppressVisibilityUpdates(bool flag) { m_suppressVisibilityUpdates = flag; }
index c541d2c..a4a3c57 100644 (file)
@@ -177,6 +177,10 @@ messages -> WebPageProxy {
     BindAccessibilityTree(WTF::String plugID)
 #endif
 
+#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
+    InvalidateWidget()
+#endif
+
     # BackForward messages
     BackForwardAddItem(uint64_t itemID)
     BackForwardGoToItem(uint64_t itemID) -> (WebKit::SandboxExtension::Handle sandboxExtensionHandle)
index ac26c0c..1117a25 100644 (file)
@@ -110,9 +110,14 @@ void WebPageProxy::windowedPluginGeometryDidChange(const WebCore::IntRect& frame
 }
 
 #if USE(TEXTURE_MAPPER_GL)
-void WebPageProxy::widgetMapped(uint64_t nativeWindowId)
+void WebPageProxy::setAcceleratedCompositingWindowId(uint64_t nativeWindowId)
 {
-    process()->send(Messages::WebPage::WidgetMapped(nativeWindowId), m_pageID);
+    process()->send(Messages::WebPage::SetAcceleratedCompositingWindowId(nativeWindowId), m_pageID);
+}
+
+void WebPageProxy::invalidateWidget()
+{
+    webkitWebViewBaseQueueDrawOfAcceleratedCompositingResults(WEBKIT_WEB_VIEW_BASE(static_cast<PageClientImpl*>(m_pageClient)->viewWidget()));
 }
 #endif
 
index 96cb6e1..775b827 100644 (file)
@@ -458,7 +458,8 @@ public:
     void updateAccessibilityTree();
     bool handleMousePressedEvent(const WebCore::PlatformMouseEvent&);
 #if USE(TEXTURE_MAPPER_GL)
-    void widgetMapped(int64_t nativeWindowHandle);
+    void setAcceleratedCompositingWindowId(int64_t nativeWindowHandle);
+    void invalidateWidget();
 #endif
 #endif
 
index b6bcace..59362bc 100644 (file)
@@ -299,6 +299,6 @@ messages -> WebPage {
 #endif
 
 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
-    WidgetMapped(int64_t id)
+    SetAcceleratedCompositingWindowId(int64_t id)
 #endif
 }
index ee483ae..098a4c7 100644 (file)
@@ -203,6 +203,8 @@ void LayerTreeHostGtk::sizeDidChange(const IntSize& newSize)
 
     if (m_pageOverlayLayer)
         m_pageOverlayLayer->setSize(newSize);
+
+    compositeLayersToContext(ForResize);
 }
 
 void LayerTreeHostGtk::deviceScaleFactorDidChange()
@@ -293,7 +295,7 @@ bool LayerTreeHostGtk::flushPendingLayerChanges()
     return m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();
 }
 
-void LayerTreeHostGtk::compositeLayersToContext()
+void LayerTreeHostGtk::compositeLayersToContext(CompositePurpose purpose)
 {
     GLContext* context = glContext();
     if (!context || !context->makeContextCurrent())
@@ -305,11 +307,17 @@ void LayerTreeHostGtk::compositeLayersToContext()
     IntSize contextSize = m_context->defaultFrameBufferSize();
     glViewport(0, 0, contextSize.width(), contextSize.height());
 
+    if (purpose == ForResize) {
+        glClearColor(1, 1, 1, 0);
+        glClear(GL_COLOR_BUFFER_BIT);
+    }
+
     m_textureMapper->beginPainting();
     toTextureMapperLayer(m_rootLayer.get())->paint();
     m_textureMapper->endPainting();
 
     context->swapBuffers();
+    m_webPage->invalidateWidget();
 }
 
 void LayerTreeHostGtk::flushAndRenderLayers()
index 060570b..d9a816c 100644 (file)
@@ -83,7 +83,10 @@ private:
 
     void createPageOverlayLayer();
     void destroyPageOverlayLayer();
-    void compositeLayersToContext();
+
+    enum CompositePurpose { ForResize, NotForResize };
+    void compositeLayersToContext(CompositePurpose = NotForResize);
+
     void flushAndRenderLayers();
     void cancelPendingLayerFlush();
 
index 30aaa40..d9dde81 100644 (file)
@@ -156,10 +156,15 @@ PassRefPtr<SharedBuffer> WebPage::cachedResponseDataForURL(const KURL&)
 }
 
 #if USE(TEXTURE_MAPPER_GL)
-void WebPage::widgetMapped(int64_t nativeWindowHandle)
+void WebPage::setAcceleratedCompositingWindowId(int64_t nativeWindowHandle)
 {
     m_nativeWindowHandle = nativeWindowHandle;
 }
+
+void WebPage::invalidateWidget()
+{
+    send(Messages::WebPageProxy::InvalidateWidget());
+}
 #endif
 
 bool WebPage::handleMousePressedEvent(const PlatformMouseEvent& platformMouseEvent)