- Revision
- 203496
- Author
- [email protected]
- Date
- 2016-07-21 00:18:03 -0700 (Thu, 21 Jul 2016)
Log Message
[GTK] Web view background colors don't work in accelerated compositing mode
https://bugs.webkit.org/show_bug.cgi?id=159455
Reviewed by Michael Catanzaro.
Source/WebKit2:
In non AC mode it's the drawing area backing store the one drawing the background, and the web process just
renders into a transparent bitmap. In AC mode we need to make the redirected window pixmap transparent for the
web process to render there, and let the web view fill the background color before rendering the redirected
window pixmap on top. To be able to make the redirected window surface transparent, we need to ensure the parent
window has an RGBA visual, even when setting a fully opaque background, because we still need the web process
to render on the transparent xwindow.
* UIProcess/API/gtk/WebKitWebView.cpp: Update documentation of webkit_web_view_set_background_color() since now
it's required to set the RGBA visual even for opaque colors in case AC mode is enabled.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewRenderAcceleratedCompositingResults): When a background color has been set, fill it before
rendering the redirected window surface.
* UIProcess/gtk/RedirectedXCompositeWindow.cpp:
(WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow): Mark the surface as dirty after every damage
event, since the web process has modified it.
(WebKit::RedirectedXCompositeWindow::surface): Initialize the surface after creating it, to avoid flickering and
rendering artifacts when waiting for the first damage event from the web process.
* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::compositeLayersToContext): Use a fully transparent color to clear the context when the page
is resized or when a view background color has been set.
Tools:
Set always RGBA visual to the view widget when setting a background color.
* MiniBrowser/gtk/BrowserWindow.c:
(browser_window_set_background_color):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (203495 => 203496)
--- trunk/Source/WebKit2/ChangeLog 2016-07-21 07:04:59 UTC (rev 203495)
+++ trunk/Source/WebKit2/ChangeLog 2016-07-21 07:18:03 UTC (rev 203496)
@@ -1,3 +1,31 @@
+2016-07-21 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Web view background colors don't work in accelerated compositing mode
+ https://bugs.webkit.org/show_bug.cgi?id=159455
+
+ Reviewed by Michael Catanzaro.
+
+ In non AC mode it's the drawing area backing store the one drawing the background, and the web process just
+ renders into a transparent bitmap. In AC mode we need to make the redirected window pixmap transparent for the
+ web process to render there, and let the web view fill the background color before rendering the redirected
+ window pixmap on top. To be able to make the redirected window surface transparent, we need to ensure the parent
+ window has an RGBA visual, even when setting a fully opaque background, because we still need the web process
+ to render on the transparent xwindow.
+
+ * UIProcess/API/gtk/WebKitWebView.cpp: Update documentation of webkit_web_view_set_background_color() since now
+ it's required to set the RGBA visual even for opaque colors in case AC mode is enabled.
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewRenderAcceleratedCompositingResults): When a background color has been set, fill it before
+ rendering the redirected window surface.
+ * UIProcess/gtk/RedirectedXCompositeWindow.cpp:
+ (WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow): Mark the surface as dirty after every damage
+ event, since the web process has modified it.
+ (WebKit::RedirectedXCompositeWindow::surface): Initialize the surface after creating it, to avoid flickering and
+ rendering artifacts when waiting for the first damage event from the web process.
+ * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
+ (WebKit::LayerTreeHostGtk::compositeLayersToContext): Use a fully transparent color to clear the context when the page
+ is resized or when a view background color has been set.
+
2016-07-20 Carlos Garcia Campos <[email protected]>
[GTK] Avoid the redirected window resize when the view is realized in AC mode
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (203495 => 203496)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2016-07-21 07:04:59 UTC (rev 203495)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2016-07-21 07:18:03 UTC (rev 203496)
@@ -3515,8 +3515,8 @@
* the actual contents are rendered. Note that if the web page loaded in @web_view
* specifies a background color, it will take precedence over the @rgba color.
* By default the @web_view background color is opaque white.
- * If the @rgba color is not fully opaque, the parent window must have a RGBA visual and
- * #GtkWidget:app-paintable property set to %TRUE, for the transparencies to work.
+ * Note that the parent window must have a RGBA visual and
+ * #GtkWidget:app-paintable property set to %TRUE for backgrounds colors to work.
*
* <informalexample><programlisting>
* static void browser_window_set_background_color (BrowserWindow *window,
@@ -3523,18 +3523,15 @@
* const GdkRGBA *rgba)
* {
* WebKitWebView *web_view;
+ * GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (window));
+ * GdkVisual *rgba_visual = gdk_screen_get_rgba_visual (screen);
*
- * if (rgba->alpha < 1) {
- * GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (window));
- * GdkVisual *rgba_visual = gdk_screen_get_rgba_visual (screen);
+ * if (!rgba_visual)
+ * return;
*
- * if (!rgba_visual)
- * return;
+ * gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual);
+ * gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
*
- * gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual);
- * gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
- * }
- *
* web_view = browser_window_get_web_view (window);
* webkit_web_view_set_background_color (web_view, rgba);
* }
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (203495 => 203496)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2016-07-21 07:04:59 UTC (rev 203495)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp 2016-07-21 07:18:03 UTC (rev 203496)
@@ -592,10 +592,28 @@
webkitWebViewBaseResizeRedirectedWindow(webViewBase);
if (cairo_surface_t* surface = priv->redirectedWindow->surface()) {
cairo_save(cr);
+
+ if (!priv->pageProxy->drawsBackground()) {
+ const WebCore::Color& color = priv->pageProxy->backgroundColor();
+ if (color.hasAlpha()) {
+ cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
+ cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
+ cairo_fill(cr);
+ }
+
+ if (color.alpha() > 0) {
+ setSourceRGBAFromColor(cr, color);
+ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+ cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
+ cairo_fill(cr);
+ }
+ }
+
cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
cairo_set_source_surface(cr, surface, 0, 0);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+ cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_fill(cr);
+
cairo_restore(cr);
}
Modified: trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp (203495 => 203496)
--- trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp 2016-07-21 07:04:59 UTC (rev 203495)
+++ trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp 2016-07-21 07:18:03 UTC (rev 203496)
@@ -189,7 +189,12 @@
&windowAttributes);
XMapWindow(m_display, m_window.get());
- xDamageNotifier().add(m_window.get(), WTFMove(damageNotify));
+ xDamageNotifier().add(m_window.get(), [this, damageNotify = WTFMove(damageNotify)] {
+ // The surface has been modified by the web process, mark it as dirty.
+ if (m_surface)
+ cairo_surface_mark_dirty(m_surface.get());
+ damageNotify();
+ });
while (1) {
XEvent event;
@@ -269,7 +274,10 @@
cairoSurfaceSetDeviceScale(newSurface.get(), m_webPage.deviceScaleFactor(), m_webPage.deviceScaleFactor());
RefPtr<cairo_t> cr = adoptRef(cairo_create(newSurface.get()));
- cairo_set_source_rgb(cr.get(), 1, 1, 1);
+ if (!m_webPage.drawsBackground())
+ cairo_set_operator(cr.get(), CAIRO_OPERATOR_CLEAR);
+ else
+ setSourceRGBAFromColor(cr.get(), m_webPage.backgroundColor());
cairo_paint(cr.get());
// Nvidia drivers seem to prepare their redirected window pixmap asynchronously, so for a few fractions
@@ -277,6 +285,7 @@
// pixmap window-backings), the pixmap memory is uninitialized. To work around this issue, paint the old
// pixmap to the new one to properly initialize it.
if (m_surface) {
+ cairo_set_operator(cr.get(), CAIRO_OPERATOR_OVER);
cairo_set_source_surface(cr.get(), m_surface.get(), 0, 0);
cairo_paint(cr.get());
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp (203495 => 203496)
--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp 2016-07-21 07:04:59 UTC (rev 203495)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp 2016-07-21 07:18:03 UTC (rev 203496)
@@ -313,9 +313,8 @@
// we set the viewport parameters directly from the window size.
IntSize contextSize = m_context->defaultFrameBufferSize();
glViewport(0, 0, contextSize.width(), contextSize.height());
-
- if (purpose == ForResize) {
- glClearColor(1, 1, 1, 0);
+ if (purpose == ForResize || !m_webPage.drawsBackground()) {
+ glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
}
Modified: trunk/Tools/ChangeLog (203495 => 203496)
--- trunk/Tools/ChangeLog 2016-07-21 07:04:59 UTC (rev 203495)
+++ trunk/Tools/ChangeLog 2016-07-21 07:18:03 UTC (rev 203496)
@@ -1,3 +1,15 @@
+2016-07-21 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Web view background colors don't work in accelerated compositing mode
+ https://bugs.webkit.org/show_bug.cgi?id=159455
+
+ Reviewed by Michael Catanzaro.
+
+ Set always RGBA visual to the view widget when setting a background color.
+
+ * MiniBrowser/gtk/BrowserWindow.c:
+ (browser_window_set_background_color):
+
2016-07-20 Youenn Fablet <[email protected]>
Bots should run built-ins generator tests
Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.c (203495 => 203496)
--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.c 2016-07-21 07:04:59 UTC (rev 203495)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.c 2016-07-21 07:18:03 UTC (rev 203496)
@@ -1069,14 +1069,12 @@
if (gdk_rgba_equal(rgba, &viewRGBA))
return;
- if (rgba->alpha < 1) {
- GdkVisual *rgbaVisual = gdk_screen_get_rgba_visual(gtk_window_get_screen(GTK_WINDOW(window)));
- if (!rgbaVisual)
- return;
+ GdkVisual *rgbaVisual = gdk_screen_get_rgba_visual(gtk_window_get_screen(GTK_WINDOW(window)));
+ if (!rgbaVisual)
+ return;
- gtk_widget_set_visual(GTK_WIDGET(window), rgbaVisual);
- gtk_widget_set_app_paintable(GTK_WIDGET(window), TRUE);
- }
+ gtk_widget_set_visual(GTK_WIDGET(window), rgbaVisual);
+ gtk_widget_set_app_paintable(GTK_WIDGET(window), TRUE);
webkit_web_view_set_background_color(webView, rgba);
}