Changeset 120262 in webkit


Ignore:
Timestamp:
Jun 13, 2012 5:13:48 PM (12 years ago)
Author:
Martin Robinson
Message:

[GTK] Add an accelerated compositing implementation for WebKit2
https://bugs.webkit.org/show_bug.cgi?id=86037

Reviewed by Alejandro G. Castro.

Source/WebCore:

No new tests. These changes are covered by the compositing tests, which
we will gradually try to turn on for the bots.

Add a new GLContext method for getting to current default framebuffer size, which
is quite useful for preventing composited content quivering while resizing.

  • platform/graphics/cairo/GLContext.h:
  • platform/graphics/glx/GLContextGLX.cpp:

(WebCore::GLContextGLX::defaultFrameBufferSize): Added this implementation for X11
which asks the X server for the window size.

  • platform/graphics/glx/GLContextGLX.h:

Source/WebKit2:

Add an implementation of LayerTreeHost for GTK+ that uses TextureMapperGL.
Later this implementation will fall back to using the ImageBuffer TextureMapper.

  • GNUmakefile.am: Add new files to the compilation.
  • Shared/LayerTreeContext.h:

(LayerTreeContext): The GTK+ version of the LayerTreeContext just holds window handle.

  • Shared/gtk/LayerTreeContextGtk.cpp: Copied from Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp.
  • WebProcess/WebPage/gtk/LayerTreeHostGtk.h: Added.
  • WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp: Added.

Add this LayerTreeHost implementation that just creates a GL context from the widget X11 window ID.
Later implementations might find a more cross-platform solution.

  • WebProcess/WebPage/gtk/WebPageGtk.cpp:

(WebKit::WebPage::platformInitialize): Initialize the native window handle to be zero.
(WebKit::WebPage::widgetMapped): When mapping the widget, try to get the native window
handle and send it to the WebProcess.

Location:
trunk/Source
Files:
2 added
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r120261 r120262  
     12012-06-13  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [GTK] Add an accelerated compositing implementation for WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=86037
     5
     6        Reviewed by Alejandro G. Castro.
     7
     8        No new tests. These changes are covered by the compositing tests, which
     9        we will gradually try to turn on for the bots.
     10
     11        Add a new GLContext method for getting to current default framebuffer size, which
     12        is quite useful for preventing composited content quivering while resizing.
     13
     14        * platform/graphics/cairo/GLContext.h:
     15        * platform/graphics/glx/GLContextGLX.cpp:
     16        (WebCore::GLContextGLX::defaultFrameBufferSize): Added this implementation for X11
     17        which asks the X server for the window size.
     18        * platform/graphics/glx/GLContextGLX.h:
     19
    1202012-06-13  Shawn Singh  <shawnsingh@chromium.org>
    221
  • trunk/Source/WebCore/platform/graphics/cairo/GLContext.h

    r117612 r120262  
    4141    virtual void swapBuffers() = 0;
    4242    virtual bool canRenderToDefaultFramebuffer() = 0;
     43    virtual IntSize defaultFrameBufferSize() = 0;
    4344
    4445#if ENABLE(WEBGL)
  • trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp

    r117612 r120262  
    263263}
    264264
     265IntSize GLContextGLX::defaultFrameBufferSize()
     266{
     267    if (!canRenderToDefaultFramebuffer() || !m_window)
     268        return IntSize();
     269
     270    int x, y;
     271    Window rootWindow;
     272    unsigned int width, height, borderWidth, depth;
     273    if (!XGetGeometry(sharedDisplay(), m_window, &rootWindow, &x, &y, &width, &height, &borderWidth, &depth))
     274        return IntSize();
     275
     276    return IntSize(width, height);
     277}
     278
    265279bool GLContextGLX::makeContextCurrent()
    266280{
  • trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h

    r117612 r120262  
    4747    virtual void swapBuffers();
    4848    virtual bool canRenderToDefaultFramebuffer();
     49    virtual IntSize defaultFrameBufferSize();
    4950
    5051#if ENABLE(WEBGL)
  • trunk/Source/WebKit2/ChangeLog

    r120233 r120262  
     12012-06-13  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [GTK] Add an accelerated compositing implementation for WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=86037
     5
     6        Reviewed by Alejandro G. Castro.
     7
     8        Add an implementation of LayerTreeHost for GTK+ that uses TextureMapperGL.
     9        Later this implementation will fall back to using the ImageBuffer TextureMapper.
     10
     11        * GNUmakefile.am: Add new files to the compilation.
     12        * Shared/LayerTreeContext.h:
     13        (LayerTreeContext): The GTK+ version of the LayerTreeContext just holds window handle.
     14        * Shared/gtk/LayerTreeContextGtk.cpp: Copied from Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp.
     15        * WebProcess/WebPage/gtk/LayerTreeHostGtk.h: Added.
     16        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp: Added.
     17        Add this LayerTreeHost implementation that just creates a GL context from the widget X11 window ID.
     18        Later implementations might find a more cross-platform solution.
     19        * WebProcess/WebPage/gtk/WebPageGtk.cpp:
     20        (WebKit::WebPage::platformInitialize): Initialize the native window handle to be zero.
     21        (WebKit::WebPage::widgetMapped): When mapping the widget, try to get the native window
     22        handle and send it to the WebProcess.
     23
    1242012-06-13  Andras Becsi  <andras.becsi@nokia.com>
    225
  • trunk/Source/WebKit2/GNUmakefile.list.am

    r120215 r120262  
    345345        Source/WebKit2/Shared/FontSmoothingLevel.h \
    346346        Source/WebKit2/Shared/ProcessExecutablePath.h \
    347         Source/WebKit2/Shared/cairo/LayerTreeContextCairo.cpp \
    348347        Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp \
    349348        Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h \
    350349        Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp \
     350        Source/WebKit2/Shared/gtk/LayerTreeContextGtk.cpp \
    351351        Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp \
    352352        Source/WebKit2/Shared/gtk/NativeWebMouseEventGtk.cpp \
     
    10601060        Source/WebKit2/WebProcess/WebProcess.h
    10611061
     1062if USE_TEXTURE_MAPPER_GL
     1063webkit2_sources += \
     1064   Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp \
     1065   Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.h
     1066endif # END USE_TEXTURE_MAPPER_GL
     1067
    10621068if ENABLE_PLUGIN_PROCESS
    10631069
  • trunk/Source/WebKit2/Shared/LayerTreeContext.h

    r109804 r120262  
    5757#elif PLATFORM(QT)
    5858    uint32_t webLayerID;
     59#elif PLATFORM(GTK)
     60    uint64_t windowHandle;
    5961#endif
    6062};
  • trunk/Source/WebKit2/Shared/gtk/LayerTreeContextGtk.cpp

    r120261 r120262  
    2525
    2626#include "config.h"
    27 #include "LayerTreeHost.h"
     27#include "LayerTreeContext.h"
    2828
    29 #if USE(CA)
    30 #if PLATFORM(MAC)
    31 #include "LayerTreeHostCAMac.h"
    32 #elif PLATFORM(WIN)
    33 #include "LayerTreeHostCAWin.h"
    34 #endif
    35 #endif
    36 
    37 #if PLATFORM(QT)
    38 #include "qt/LayerTreeHostQt.h"
    39 #endif
    40 
    41 using namespace WebCore;
     29#include "ArgumentDecoder.h"
     30#include "ArgumentEncoder.h"
    4231
    4332namespace WebKit {
    4433
    45 PassRefPtr<LayerTreeHost> LayerTreeHost::create(WebPage* webPage)
    46 {
    47 #if PLATFORM(MAC)
    48     return LayerTreeHostCAMac::create(webPage);
    49 #elif PLATFORM(WIN) && HAVE(WKQCA)
    50     return LayerTreeHostCAWin::create(webPage);
    51 #elif PLATFORM(QT)
    52     return LayerTreeHostQt::create(webPage);
    53 #else
    54     return 0;
    55 #endif
    56 }
    57 
    58 LayerTreeHost::LayerTreeHost(WebPage* webPage)
    59     : m_webPage(webPage)
     34LayerTreeContext::LayerTreeContext()
     35    : windowHandle(0)
    6036{
    6137}
    6238
    63 LayerTreeHost::~LayerTreeHost()
     39LayerTreeContext::~LayerTreeContext()
    6440{
    6541}
    6642
     43void LayerTreeContext::encode(CoreIPC::ArgumentEncoder* encoder) const
     44{
     45    encoder->encode(windowHandle);
     46}
     47
     48bool LayerTreeContext::decode(CoreIPC::ArgumentDecoder* decoder, LayerTreeContext& context)
     49{
     50    return decoder->decode(context.windowHandle);
     51}
     52
     53bool LayerTreeContext::isEmpty() const
     54{
     55    return !windowHandle;
     56}
     57
     58bool operator==(const LayerTreeContext& a, const LayerTreeContext& b)
     59{
     60    return a.windowHandle == b.windowHandle;
     61}
     62
    6763} // namespace WebKit
     64
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r119063 r120262  
    6666#endif
    6767
     68#if USE(TEXTURE_MAPPER_GL) && defined(GDK_WINDOWING_X11)
     69#include <gdk/gdkx.h>
     70#endif
     71
    6872using namespace WebKit;
    6973using namespace WebCore;
     
    155159
    156160    GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributesMask);
     161#if USE(TEXTURE_MAPPER_GL)
     162    gdk_window_ensure_native(window);
     163#endif
    157164    gtk_widget_set_window(widget, window);
    158165    gdk_window_set_user_data(window, widget);
     
    340347
    341348    WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
     349#if USE(TEXTURE_MAPPER_GL) && defined(GDK_WINDOWING_X11)
     350    GdkWindow* gdkWindow = gtk_widget_get_window(widget);
     351    ASSERT(gdkWindow);
     352    if (gdk_window_has_native(gdkWindow))
     353        webViewBase->priv->pageProxy->widgetMapped(GDK_WINDOW_XID(gdkWindow));
     354#endif
     355
    342356    if (!webViewBase->priv->needsResizeOnMap)
    343357        return;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r120215 r120262  
    668668    // WebPopupMenuProxy::Client
    669669    virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent();
     670
     671#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
     672    void widgetMapped(uint64_t nativeWindowId);
     673#endif
    670674
    671675private:
  • trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp

    r115300 r120262  
    3232#include "PageClientImpl.h"
    3333#include "WebKitWebViewBasePrivate.h"
     34#include "WebPageMessages.h"
     35#include "WebProcessProxy.h"
    3436#include <gtk/gtkx.h>
    3537
     
    108110}
    109111
     112#if USE(TEXTURE_MAPPER_GL)
     113void WebPageProxy::widgetMapped(uint64_t nativeWindowId)
     114{
     115    process()->send(Messages::WebPage::WidgetMapped(nativeWindowId), m_pageID);
     116}
     117#endif
     118
    110119} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.cpp

    r109302 r120262  
    3939#endif
    4040
     41#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
     42#include "LayerTreeHostGtk.h"
     43#endif
     44
    4145using namespace WebCore;
    4246
     
    5155#elif PLATFORM(QT)
    5256    return LayerTreeHostQt::create(webPage);
     57#elif PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
     58    return LayerTreeHostGtk::create(webPage);
    5359#else
    5460    return 0;
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r119687 r120262  
    433433#elif PLATFORM(GTK)
    434434    void updateAccessibilityTree();
     435#if USE(TEXTURE_MAPPER_GL)
     436    void widgetMapped(int64_t nativeWindowHandle);
     437#endif
    435438#endif
    436439
     
    538541#if ENABLE(PAGE_VISIBILITY_API)
    539542    void setVisibilityState(int visibilityState, bool isInitialState);
     543#endif
     544
     545#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
     546    uint64_t nativeWindowHandle() { return m_nativeWindowHandle; }
    540547#endif
    541548
     
    754761#elif PLATFORM(GTK)
    755762    WebPageAccessibilityObject* m_accessibilityObject;
     763
     764#if USE(TEXTURE_MAPPER_GL)
     765    // Our view's window in the UI process.
     766    uint64_t m_nativeWindowHandle;
     767#endif
    756768#endif
    757769   
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r119687 r120262  
    274274    SetVisibilityState(int visibilityState, bool isInitialState);
    275275#endif
     276
     277#if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
     278    WidgetMapped(int64_t id)
     279#endif
    276280}
  • trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp

    r105503 r120262  
    5555    GOwnPtr<gchar> plugID(atk_plug_get_id(ATK_PLUG(m_accessibilityObject)));
    5656    send(Messages::WebPageProxy::BindAccessibilityTree(String(plugID.get())));
     57
     58    m_nativeWindowHandle = 0;
    5759}
    5860
     
    151153}
    152154
     155#if USE(TEXTURE_MAPPER_GL)
     156void WebPage::widgetMapped(int64_t nativeWindowHandle)
     157{
     158    m_nativeWindowHandle = nativeWindowHandle;
     159}
     160
     161#endif
     162
    153163} // namespace WebKit
Note: See TracChangeset for help on using the changeset viewer.