Changeset 206424 in webkit


Ignore:
Timestamp:
Sep 27, 2016 2:06:41 AM (8 years ago)
Author:
Gustavo Noronha Silva
Message:

[GTK] Should check whether GDK can use GL before asking it to
https://bugs.webkit.org/show_bug.cgi?id=162598

Reviewed by Michael Catanzaro.

gdk_cairo_draw_from_gl can fail even when WebKit itself has been able to use GL (its
context creation code might be buggy, GL may have been disabled using GDK_GL=disable, …).
Unfortunately it does not have any error reporting other than a warning printed to
stderr, so we cannot fallback from it. We have to first check if GL can be used by GDK
by trying to create a context.

See https://bugzilla.redhat.com/show_bug.cgi?id=1378987

  • UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:

(WebKit::AcceleratedBackingStoreWayland::canGdkUseGL): decide whether GDK can use GL by
trying to create a context for a GdkWindow.
(WebKit::AcceleratedBackingStoreWayland::paint): fallback to glReadPixels if GDK cannot
use GL.

  • UIProcess/gtk/AcceleratedBackingStoreWayland.h:
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r206413 r206424  
     12016-09-27  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
     2
     3        [GTK] Should check whether GDK can use GL before asking it to
     4        https://bugs.webkit.org/show_bug.cgi?id=162598
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        gdk_cairo_draw_from_gl can fail even when WebKit itself has been able to use GL (its
     9        context creation code might be buggy, GL may have been disabled using GDK_GL=disable, …).
     10        Unfortunately it does not have any error reporting other than a warning printed to
     11        stderr, so we cannot fallback from it. We have to first check if GL can be used by GDK
     12        by trying to create a context.
     13
     14        See https://bugzilla.redhat.com/show_bug.cgi?id=1378987
     15
     16        * UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:
     17        (WebKit::AcceleratedBackingStoreWayland::canGdkUseGL): decide whether GDK can use GL by
     18        trying to create a context for a GdkWindow.
     19        (WebKit::AcceleratedBackingStoreWayland::paint): fallback to glReadPixels if GDK cannot
     20        use GL.
     21        * UIProcess/gtk/AcceleratedBackingStoreWayland.h:
     22
    1232016-09-26  Tim Horton  <timothy_horton@apple.com>
    224
  • trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp

    r206216 r206424  
    6262}
    6363
     64#if GTK_CHECK_VERSION(3, 16, 0)
     65bool AcceleratedBackingStoreWayland::canGdkUseGL() const
     66{
     67    static bool initialized = false;
     68    static bool canCreateGLContext = false;
     69
     70    if (initialized)
     71        return canCreateGLContext;
     72
     73    initialized = true;
     74
     75    GUniqueOutPtr<GError> error;
     76    GdkWindow* gdkWindow = gtk_widget_get_window(m_webPage.viewWidget());
     77    GRefPtr<GdkGLContext> gdkContext(gdk_window_create_gl_context(gdkWindow, &error.outPtr()));
     78    if (!gdkContext) {
     79        g_warning("GDK is not able to create a GL context, falling back to glReadPixels (slow!): %s", error->message);
     80        return false;
     81    }
     82
     83    canCreateGLContext = true;
     84
     85    return true;
     86}
     87#endif
     88
    6489bool AcceleratedBackingStoreWayland::paint(cairo_t* cr, const IntRect& clipRect)
    6590{
     
    7398
    7499#if GTK_CHECK_VERSION(3, 16, 0)
    75     gdk_cairo_draw_from_gl(cr, gtk_widget_get_window(m_webPage.viewWidget()), texture, GL_TEXTURE, m_webPage.deviceScaleFactor(), 0, 0, textureSize.width(), textureSize.height());
    76 #else
     100    if (canGdkUseGL()) {
     101        gdk_cairo_draw_from_gl(cr, gtk_widget_get_window(m_webPage.viewWidget()), texture, GL_TEXTURE, m_webPage.deviceScaleFactor(), 0, 0, textureSize.width(), textureSize.height());
     102        cairo_restore(cr);
     103        return true;
     104    }
     105#endif
     106
    77107    if (!m_surface || cairo_image_surface_get_width(m_surface.get()) != textureSize.width() || cairo_image_surface_get_height(m_surface.get()) != textureSize.height())
    78108        m_surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, textureSize.width(), textureSize.height()));
     
    125155    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    126156    cairo_fill(cr);
    127 #endif
    128157
    129158    cairo_restore(cr);
  • trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.h

    r205116 r206424  
    3131
    3232#include <WebCore/RefPtrCairo.h>
     33#include <gtk/gtk.h>
    3334
    3435namespace WebKit {
     
    4142    static std::unique_ptr<AcceleratedBackingStoreWayland> create(WebPageProxy&);
    4243    ~AcceleratedBackingStoreWayland();
     44
     45#if GTK_CHECK_VERSION(3, 16, 0)
     46    bool canGdkUseGL() const;
     47#endif
    4348
    4449private:
Note: See TracChangeset for help on using the changeset viewer.