Title: [213070] releases/WebKitGTK/webkit-2.16/Source/WebKit2
Revision
213070
Author
carlo...@webkit.org
Date
2017-02-27 09:03:22 -0800 (Mon, 27 Feb 2017)

Log Message

Merge r213061 - [GTK] Rendering artifacts when resizing the window in X11 with AC mode enabled
https://bugs.webkit.org/show_bug.cgi?id=168728

Reviewed by Žan Doberšek.

This happens because the pixmap we create from the redirected window is uninitialized until the threaded
compositor renders into it. We should always initialize the pixmap right after it's created.

* WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp:
(WebKit::defaultVisual): Helper static method to get the default GdkVisual.
(WebKit::AcceleratedSurfaceX11::AcceleratedSurfaceX11): Use createPixmap().
(WebKit::AcceleratedSurfaceX11::createPixmap): Create and initialize the pixmap.
(WebKit::AcceleratedSurfaceX11::resize): Use createPixmap().
* WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.16/Source/WebKit2/ChangeLog (213069 => 213070)


--- releases/WebKitGTK/webkit-2.16/Source/WebKit2/ChangeLog	2017-02-27 16:59:53 UTC (rev 213069)
+++ releases/WebKitGTK/webkit-2.16/Source/WebKit2/ChangeLog	2017-02-27 17:03:22 UTC (rev 213070)
@@ -1,3 +1,20 @@
+2017-02-27  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] Rendering artifacts when resizing the window in X11 with AC mode enabled
+        https://bugs.webkit.org/show_bug.cgi?id=168728
+
+        Reviewed by Žan Doberšek.
+
+        This happens because the pixmap we create from the redirected window is uninitialized until the threaded
+        compositor renders into it. We should always initialize the pixmap right after it's created.
+
+        * WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp:
+        (WebKit::defaultVisual): Helper static method to get the default GdkVisual.
+        (WebKit::AcceleratedSurfaceX11::AcceleratedSurfaceX11): Use createPixmap().
+        (WebKit::AcceleratedSurfaceX11::createPixmap): Create and initialize the pixmap.
+        (WebKit::AcceleratedSurfaceX11::resize): Use createPixmap().
+        * WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h:
+
 2017-02-22  Carlos Garcia Campos  <cgar...@igalia.com>
 
         NetworkProcess: Stop disabling buffering when NETWORK_CACHE is disabled in build

Modified: releases/WebKitGTK/webkit-2.16/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp (213069 => 213070)


--- releases/WebKitGTK/webkit-2.16/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp	2017-02-27 16:59:53 UTC (rev 213069)
+++ releases/WebKitGTK/webkit-2.16/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp	2017-02-27 17:03:22 UTC (rev 213070)
@@ -30,8 +30,10 @@
 
 #include "WebPage.h"
 #include <WebCore/PlatformDisplayX11.h>
+#include <WebCore/RefPtrCairo.h>
 #include <X11/Xlib.h>
 #include <X11/extensions/Xcomposite.h>
+#include <cairo-xlib.h>
 #include <gdk/gdkx.h>
 #include <wtf/RunLoop.h>
 
@@ -46,6 +48,13 @@
     return std::unique_ptr<AcceleratedSurfaceX11>(new AcceleratedSurfaceX11(webPage));
 }
 
+static GdkVisual* defaultVisual()
+{
+    if (GdkVisual* visual = gdk_screen_get_rgba_visual(gdk_screen_get_default()))
+        return visual;
+    return gdk_screen_get_system_visual(gdk_screen_get_default());
+}
+
 AcceleratedSurfaceX11::AcceleratedSurfaceX11(WebPage& webPage)
     : AcceleratedSurface(webPage)
     , m_display(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native())
@@ -53,10 +62,8 @@
     Screen* screen = DefaultScreenOfDisplay(m_display);
 
     ASSERT(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native() == m_display);
-    GdkVisual* visual = gdk_screen_get_rgba_visual(gdk_screen_get_default());
-    if (!visual)
-        visual = gdk_screen_get_system_visual(gdk_screen_get_default());
 
+    GdkVisual* visual = defaultVisual();
     XUniqueColormap colormap(XCreateColormap(m_display, RootWindowOfScreen(screen), GDK_VISUAL_XVISUAL(visual), AllocNone));
 
     XSetWindowAttributes windowAttributes;
@@ -103,8 +110,7 @@
     }
     XSelectInput(m_display, m_window.get(), NoEventMask);
     XCompositeRedirectWindow(m_display, m_window.get(), CompositeRedirectManual);
-    m_pixmap = XCompositeNameWindowPixmap(m_display, m_window.get());
-    XSync(m_display, False);
+    createPixmap();
 }
 
 AcceleratedSurfaceX11::~AcceleratedSurfaceX11()
@@ -118,6 +124,16 @@
     m_parentWindow.reset();
 }
 
+void AcceleratedSurfaceX11::createPixmap()
+{
+    m_pixmap = XCompositeNameWindowPixmap(m_display, m_window.get());
+    RefPtr<cairo_surface_t> surface = adoptRef(cairo_xlib_surface_create(m_display, m_pixmap.get(), GDK_VISUAL_XVISUAL(defaultVisual()), m_size.width(), m_size.height()));
+    RefPtr<cairo_t> cr = adoptRef(cairo_create(surface.get()));
+    cairo_set_operator(cr.get(), CAIRO_OPERATOR_CLEAR);
+    cairo_paint(cr.get());
+    XSync(m_display, False);
+}
+
 bool AcceleratedSurfaceX11::resize(const IntSize& size)
 {
     if (!AcceleratedSurface::resize(size))
@@ -129,8 +145,7 @@
 
     // Release the previous pixmap later to give some time to the UI process to update.
     RunLoop::main().dispatchAfter(std::chrono::seconds(5), [pixmap = WTFMove(m_pixmap)] { });
-    m_pixmap = XCompositeNameWindowPixmap(m_display, m_window.get());
-    XSync(m_display, False);
+    createPixmap();
     return true;
 }
 

Modified: releases/WebKitGTK/webkit-2.16/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h (213069 => 213070)


--- releases/WebKitGTK/webkit-2.16/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h	2017-02-27 16:59:53 UTC (rev 213069)
+++ releases/WebKitGTK/webkit-2.16/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.h	2017-02-27 17:03:22 UTC (rev 213070)
@@ -52,6 +52,8 @@
 private:
     AcceleratedSurfaceX11(WebPage&);
 
+    void createPixmap();
+
     Display* m_display { nullptr };
     WebCore::XUniqueWindow m_window;
     WebCore::XUniqueWindow m_parentWindow;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to