Changeset 203496 in webkit


Ignore:
Timestamp:
Jul 21, 2016 12:18:03 AM (8 years ago)
Author:
Carlos Garcia Campos
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):

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r203495 r203496  
     12016-07-21  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Web view background colors don't work in accelerated compositing mode
     4        https://bugs.webkit.org/show_bug.cgi?id=159455
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        In non AC mode it's the drawing area backing store the one drawing the background, and the web process just
     9        renders into a transparent bitmap. In AC mode we need to make the redirected window pixmap transparent for the
     10        web process to render there, and let the web view fill the background color before rendering the redirected
     11        window pixmap on top. To be able to make the redirected window surface transparent, we need to ensure the parent
     12        window has an RGBA visual, even when setting a fully opaque background, because we still need the web process
     13        to render on the transparent xwindow.
     14
     15        * UIProcess/API/gtk/WebKitWebView.cpp: Update documentation of webkit_web_view_set_background_color() since now
     16        it's required to set the RGBA visual even for opaque colors in case AC mode is enabled.
     17        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     18        (webkitWebViewRenderAcceleratedCompositingResults): When a background color has been set, fill it before
     19        rendering the redirected window surface.
     20        * UIProcess/gtk/RedirectedXCompositeWindow.cpp:
     21        (WebKit::RedirectedXCompositeWindow::RedirectedXCompositeWindow): Mark the surface as dirty after every damage
     22        event, since the web process has modified it.
     23        (WebKit::RedirectedXCompositeWindow::surface): Initialize the surface after creating it, to avoid flickering and
     24        rendering artifacts when waiting for the first damage event from the web process.
     25        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
     26        (WebKit::LayerTreeHostGtk::compositeLayersToContext): Use a fully transparent color to clear the context when the page
     27        is resized or when a view background color has been set.
     28
    1292016-07-20  Carlos Garcia Campos  <cgarcia@igalia.com>
    230
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp

    r202242 r203496  
    35163516 * specifies a background color, it will take precedence over the @rgba color.
    35173517 * By default the @web_view background color is opaque white.
    3518  * If the @rgba color is not fully opaque, the parent window must have a RGBA visual and
    3519  * #GtkWidget:app-paintable property set to %TRUE, for the transparencies to work.
     3518 * Note that the parent window must have a RGBA visual and
     3519 * #GtkWidget:app-paintable property set to %TRUE for backgrounds colors to work.
    35203520 *
    35213521 * <informalexample><programlisting>
     
    35243524 * {
    35253525 *     WebKitWebView *web_view;
    3526  *
    3527  *     if (rgba->alpha < 1) {
    3528  *         GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (window));
    3529  *         GdkVisual *rgba_visual = gdk_screen_get_rgba_visual (screen);
    3530  *
    3531  *         if (!rgba_visual)
    3532  *              return;
    3533  *
    3534  *         gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual);
    3535  *         gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
    3536  *     }
     3526 *     GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (window));
     3527 *     GdkVisual *rgba_visual = gdk_screen_get_rgba_visual (screen);
     3528 *
     3529 *     if (!rgba_visual)
     3530 *          return;
     3531 *
     3532 *     gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual);
     3533 *     gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
    35373534 *
    35383535 *     web_view = browser_window_get_web_view (window);
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r203495 r203496  
    593593    if (cairo_surface_t* surface = priv->redirectedWindow->surface()) {
    594594        cairo_save(cr);
     595
     596        if (!priv->pageProxy->drawsBackground()) {
     597            const WebCore::Color& color = priv->pageProxy->backgroundColor();
     598            if (color.hasAlpha()) {
     599                cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
     600                cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
     601                cairo_fill(cr);
     602            }
     603
     604            if (color.alpha() > 0) {
     605                setSourceRGBAFromColor(cr, color);
     606                cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
     607                cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
     608                cairo_fill(cr);
     609            }
     610        }
     611
    595612        cairo_rectangle(cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height);
    596613        cairo_set_source_surface(cr, surface, 0, 0);
    597         cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
     614        cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    598615        cairo_fill(cr);
     616
    599617        cairo_restore(cr);
    600618    }
  • trunk/Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp

    r203495 r203496  
    190190    XMapWindow(m_display, m_window.get());
    191191
    192     xDamageNotifier().add(m_window.get(), WTFMove(damageNotify));
     192    xDamageNotifier().add(m_window.get(), [this, damageNotify = WTFMove(damageNotify)] {
     193        // The surface has been modified by the web process, mark it as dirty.
     194        if (m_surface)
     195            cairo_surface_mark_dirty(m_surface.get());
     196        damageNotify();
     197    });
    193198
    194199    while (1) {
     
    270275
    271276    RefPtr<cairo_t> cr = adoptRef(cairo_create(newSurface.get()));
    272     cairo_set_source_rgb(cr.get(), 1, 1, 1);
     277    if (!m_webPage.drawsBackground())
     278        cairo_set_operator(cr.get(), CAIRO_OPERATOR_CLEAR);
     279    else
     280        setSourceRGBAFromColor(cr.get(), m_webPage.backgroundColor());
    273281    cairo_paint(cr.get());
    274282
     
    278286    // pixmap to the new one to properly initialize it.
    279287    if (m_surface) {
     288        cairo_set_operator(cr.get(), CAIRO_OPERATOR_OVER);
    280289        cairo_set_source_surface(cr.get(), m_surface.get(), 0, 0);
    281290        cairo_paint(cr.get());
  • trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp

    r202621 r203496  
    314314    IntSize contextSize = m_context->defaultFrameBufferSize();
    315315    glViewport(0, 0, contextSize.width(), contextSize.height());
    316 
    317     if (purpose == ForResize) {
    318         glClearColor(1, 1, 1, 0);
     316    if (purpose == ForResize || !m_webPage.drawsBackground()) {
     317        glClearColor(0, 0, 0, 0);
    319318        glClear(GL_COLOR_BUFFER_BIT);
    320319    }
  • trunk/Tools/ChangeLog

    r203489 r203496  
     12016-07-21  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Web view background colors don't work in accelerated compositing mode
     4        https://bugs.webkit.org/show_bug.cgi?id=159455
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Set always RGBA visual to the view widget when setting a background color.
     9
     10        * MiniBrowser/gtk/BrowserWindow.c:
     11        (browser_window_set_background_color):
     12
    1132016-07-20  Youenn Fablet  <youenn@apple.com>
    214
  • trunk/Tools/MiniBrowser/gtk/BrowserWindow.c

    r203271 r203496  
    10701070        return;
    10711071
    1072     if (rgba->alpha < 1) {
    1073         GdkVisual *rgbaVisual = gdk_screen_get_rgba_visual(gtk_window_get_screen(GTK_WINDOW(window)));
    1074         if (!rgbaVisual)
    1075             return;
    1076 
    1077         gtk_widget_set_visual(GTK_WIDGET(window), rgbaVisual);
    1078         gtk_widget_set_app_paintable(GTK_WIDGET(window), TRUE);
    1079     }
     1072    GdkVisual *rgbaVisual = gdk_screen_get_rgba_visual(gtk_window_get_screen(GTK_WINDOW(window)));
     1073    if (!rgbaVisual)
     1074        return;
     1075
     1076    gtk_widget_set_visual(GTK_WIDGET(window), rgbaVisual);
     1077    gtk_widget_set_app_paintable(GTK_WIDGET(window), TRUE);
    10801078
    10811079    webkit_web_view_set_background_color(webView, rgba);
Note: See TracChangeset for help on using the changeset viewer.