Changeset 122554 in webkit


Ignore:
Timestamp:
Jul 13, 2012 2:20:49 AM (12 years ago)
Author:
zeno.albisser@nokia.com
Message:

[Qt][WK2] Implement GraphicsSurface for Linux/GLX.
https://bugs.webkit.org/show_bug.cgi?id=90881

Source/WebCore:

Add a GLX based GraphicsSurface implementation for Linux.
Native X windows are being used for exchanging textures
with the UIProcess.

Reviewed by Noam Rosenthal.

  • Target.pri:
  • WebCore.pri:
  • platform/graphics/surfaces/GraphicsSurface.cpp:

(WebCore::GraphicsSurface::create):

Move creating GraphicsSurface instance into
platformCreate/platformImport functions to allow
platform specific creation based on the provided flags.

(WebCore::GraphicsSurface::GraphicsSurface):
(WebCore::GraphicsSurface::~GraphicsSurface):

Call platformDestroy when destroying a GraphicsSurface.

(WebCore):

  • platform/graphics/surfaces/GraphicsSurface.h:

Make platformCreate/platformImport functions static
to be able to call these from the static create function.
Add Destructor prototype and add GraphicsSurfacePrivate member.

(WebCore):
(GraphicsSurface):

  • platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:

(WebCore):
(WebCore::GraphicsSurface::platformCreate):
(WebCore::GraphicsSurface::platformImport):

Insert creation of GraphicsSurface instance.
This allows having a platform specific creation mechanism
for GLX.

  • platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp: Added.

(WebCore):
(OffScreenRootWindow):
(WebCore::OffScreenRootWindow::OffScreenRootWindow):
(WebCore::OffScreenRootWindow::get):
(WebCore::OffScreenRootWindow::~OffScreenRootWindow):

Add an OffScreenRootWindow singelton that is being used
as a parent for all native offscreen windows.

(GraphicsSurfacePrivate):

This class is used to manage all the X related resources
such as opening a display or creating XPixmaps etc.

(WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):

Open a connection to the X server and create a
QOpenGLContext that can be used to resolve GL functions.

(WebCore::GraphicsSurfacePrivate::~GraphicsSurfacePrivate):

Properly cleanup and release all the X resources again.

(WebCore::GraphicsSurfacePrivate::createSurface):

Create a surface that is placed off screen and can be
used as a rendering target by the WebProcess.

(WebCore::GraphicsSurfacePrivate::createPixmap):

Create a GLXPixmap from the XWindow that was previously
redirected by the WebProcess. This GLXPixmap can then be
bound to a texture and being painted on screen by the
UIProcess.

(WebCore::GraphicsSurfacePrivate::makeCurrent):
(WebCore::GraphicsSurfacePrivate::swapBuffers):
(WebCore::GraphicsSurfacePrivate::display):
(WebCore::GraphicsSurfacePrivate::glxPixmap):
(WebCore::GraphicsSurfacePrivate::size):
(WebCore::GraphicsSurfacePrivate::glContext):
(WebCore::resolveGLMethods):

Initialize all the function pointers for the GL functions used.

(WebCore::GraphicsSurface::platformExport):
(WebCore::GraphicsSurface::platformGetTextureID):

Bind the GLXPixmap to a texture.

(WebCore::GraphicsSurface::platformCopyToGLTexture):

Not beeing implemented for GLX.

(WebCore::GraphicsSurface::platformCopyFromFramebuffer):

Blit origin fbo onto the GraphicsSurface's backing.

(WebCore::GraphicsSurface::platformCreate):
(WebCore::GraphicsSurface::platformImport):
(WebCore::GraphicsSurface::platformLock):
(WebCore::GraphicsSurface::platformUnlock):
(WebCore::GraphicsSurface::platformDestroy):

Source/WebKit2:

Add a GLX based GraphicsSurface implementation for Linux.

Reviewed by Noam Rosenthal.

  • Shared/ShareableSurface.cpp:

(WebKit::ShareableSurface::create):

Only create a GraphicsSurface from a ShareableSurface::Handle
in case the Handle contains a valid GraphicsSurface token.
Otherwise fall back to creating a ShareableBitmap.

  • UIProcess/LayerTreeCoordinatorProxy.cpp:

(WebKit::createLayerTileUniqueKey):

Create a unique key for a surface based on tileID and layerID.

(WebKit::LayerTreeCoordinatorProxy::updateTileForLayer):

Even when GraphicsSurface is enabled, not all ShareableSurfaces
will necessarily be backed by a GraphicsSurface. In case of
a ShareableSurface being backed by a ShareableBitmap instead,
the GraphicsSurface token will always be null.
So instead of using the GraphicsSurface token as a key for
storing surfaces in a map, we create a unique key from
layerID and tileID.

  • UIProcess/LayerTreeCoordinatorProxy.h:

(LayerTreeCoordinatorProxy):

Tools:

Enable GraphicsSurface for Linux based platforms
whenever the Xcomposite extension is available.

Reviewed by Noam Rosenthal.

  • qmake/config.tests/libXcomposite/libXcomposite.cpp: Added.

(main):

  • qmake/config.tests/libXcomposite/libXcomposite.pro: Added. Add a configure test to detect Xcomposite extension and activate GraphicsSurface on linux in case the extension is available.
  • qmake/configure.pri:
  • qmake/mkspecs/features/features.prf:
Location:
trunk
Files:
4 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122553 r122554  
     12012-07-13  Zeno Albisser  <zeno@webkit.org>
     2
     3        [Qt][WK2] Implement GraphicsSurface for Linux/GLX.
     4        https://bugs.webkit.org/show_bug.cgi?id=90881
     5
     6        Add a GLX based GraphicsSurface implementation for Linux.
     7        Native X windows are being used for exchanging textures
     8        with the UIProcess.
     9
     10        Reviewed by Noam Rosenthal.
     11
     12        * Target.pri:
     13        * WebCore.pri:
     14        * platform/graphics/surfaces/GraphicsSurface.cpp:
     15        (WebCore::GraphicsSurface::create):
     16            Move creating GraphicsSurface instance into
     17            platformCreate/platformImport functions to allow
     18            platform specific creation based on the provided flags.
     19        (WebCore::GraphicsSurface::GraphicsSurface):
     20        (WebCore::GraphicsSurface::~GraphicsSurface):
     21            Call platformDestroy when destroying a GraphicsSurface.
     22        (WebCore):
     23        * platform/graphics/surfaces/GraphicsSurface.h:
     24            Make platformCreate/platformImport functions static
     25            to be able to call these from the static create function.
     26            Add Destructor prototype and add GraphicsSurfacePrivate member.
     27        (WebCore):
     28        (GraphicsSurface):
     29        * platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
     30        (WebCore):
     31        (WebCore::GraphicsSurface::platformCreate):
     32        (WebCore::GraphicsSurface::platformImport):
     33            Insert creation of GraphicsSurface instance.
     34            This allows having a platform specific creation mechanism
     35            for GLX.
     36        * platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp: Added.
     37        (WebCore):
     38        (OffScreenRootWindow):
     39        (WebCore::OffScreenRootWindow::OffScreenRootWindow):
     40        (WebCore::OffScreenRootWindow::get):
     41        (WebCore::OffScreenRootWindow::~OffScreenRootWindow):
     42            Add an OffScreenRootWindow singelton that is being used
     43            as a parent for all native offscreen windows.
     44        (GraphicsSurfacePrivate):
     45            This class is used to manage all the X related resources
     46            such as opening a display or creating XPixmaps etc.
     47        (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
     48            Open a connection to the X server and create a
     49            QOpenGLContext that can be used to resolve GL functions.
     50        (WebCore::GraphicsSurfacePrivate::~GraphicsSurfacePrivate):
     51            Properly cleanup and release all the X resources again.
     52        (WebCore::GraphicsSurfacePrivate::createSurface):
     53            Create a surface that is placed off screen and can be
     54            used as a rendering target by the WebProcess.
     55        (WebCore::GraphicsSurfacePrivate::createPixmap):
     56            Create a GLXPixmap from the XWindow that was previously
     57            redirected by the WebProcess. This GLXPixmap can then be
     58            bound to a texture and being painted on screen by the
     59            UIProcess.
     60        (WebCore::GraphicsSurfacePrivate::makeCurrent):
     61        (WebCore::GraphicsSurfacePrivate::swapBuffers):
     62        (WebCore::GraphicsSurfacePrivate::display):
     63        (WebCore::GraphicsSurfacePrivate::glxPixmap):
     64        (WebCore::GraphicsSurfacePrivate::size):
     65        (WebCore::GraphicsSurfacePrivate::glContext):
     66        (WebCore::resolveGLMethods):
     67            Initialize all the function pointers for the GL functions used.
     68        (WebCore::GraphicsSurface::platformExport):
     69        (WebCore::GraphicsSurface::platformGetTextureID):
     70            Bind the GLXPixmap to a texture.
     71        (WebCore::GraphicsSurface::platformCopyToGLTexture):
     72            Not beeing implemented for GLX.
     73        (WebCore::GraphicsSurface::platformCopyFromFramebuffer):
     74            Blit origin fbo onto the GraphicsSurface's backing.
     75        (WebCore::GraphicsSurface::platformCreate):
     76        (WebCore::GraphicsSurface::platformImport):
     77        (WebCore::GraphicsSurface::platformLock):
     78        (WebCore::GraphicsSurface::platformUnlock):
     79        (WebCore::GraphicsSurface::platformDestroy):
     80
    1812012-07-13  Dongwoo Im  <dw.im@samsung.com>
    282
  • trunk/Source/WebCore/Target.pri

    r122484 r122554  
    41804180        INCLUDEPATH += /System/Library/Frameworks/CoreFoundation.framework/Headers
    41814181    }
     4182    contains(DEFINES, HAVE_XCOMPOSITE=1)  {
     4183        SOURCES += platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
     4184    }
    41824185}
    41834186
  • trunk/Source/WebCore/WebCore.pri

    r122445 r122554  
    99
    1010QT *= network sql
    11 haveQt(5): QT *= gui-private
     11haveQt(5): QT *= core-private gui-private
    1212
    1313WEBCORE_GENERATED_SOURCES_DIR = $${ROOT_BUILD_DIR}/Source/WebCore/$${GENERATED_SOURCES_DESTDIR}
     
    205205    contains(QT_CONFIG, opengles2): LIBS += -lEGL
    206206    mac: LIBS += -framework IOSurface -framework CoreFoundation
     207    linux-*:contains(DEFINES, HAVE_XCOMPOSITE=1): LIBS += -lXcomposite
    207208    # Only WebKit1 needs the opengl module, so it's optional for Qt5.
    208209    haveQt(4)|contains(QT_CONFIG, opengl): QT *= opengl
  • trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp

    r118987 r122554  
    2828PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, Flags flags, uint32_t token)
    2929{
    30     RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
    31     if (!surface->platformImport(token))
    32         return PassRefPtr<GraphicsSurface>();
    33     return surface;
     30    return platformImport(size, flags, token);
    3431}
    3532
    3633PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, GraphicsSurface::Flags flags)
    3734{
    38     RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
    39     if (!surface->platformCreate(size, flags))
    40         return PassRefPtr<GraphicsSurface>();
    41     return surface;
     35    return platformCreate(size, flags);
    4236}
    4337
     
    7165
    7266GraphicsSurface::GraphicsSurface(const IntSize& size, Flags flags)
    73     : m_size(size)
    74     , m_flags(flags)
     67    : m_flags(flags)
     68    , m_size(size)
    7569    , m_platformSurface(0)
    7670    , m_texture(0)
    7771    , m_fbo(0)
     72    , m_private(0)
    7873{
     74}
     75
     76GraphicsSurface::~GraphicsSurface()
     77{
     78    platformDestroy();
    7979}
    8080
  • trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h

    r120076 r122554  
    3333typedef struct __IOSurface* IOSurfaceRef;
    3434typedef IOSurfaceRef PlatformGraphicsSurface;
     35#else
     36typedef uint32_t PlatformGraphicsSurface;
    3537#endif
    3638
    3739namespace WebCore {
     40
     41struct GraphicsSurfacePrivate;
    3842
    3943class GraphicsSurface : public RefCounted<GraphicsSurface> {
     
    7074    PassOwnPtr<GraphicsContext> beginPaint(const IntRect&, LockOptions);
    7175    PassRefPtr<Image> createReadOnlyImage(const IntRect&);
     76    ~GraphicsSurface();
    7277
    7378protected:
    74     bool platformCreate(const IntSize&, Flags);
    75     bool platformImport(uint32_t);
     79    static PassRefPtr<GraphicsSurface> platformCreate(const IntSize&, Flags);
     80    static PassRefPtr<GraphicsSurface> platformImport(const IntSize&, Flags, uint32_t);
    7681    uint32_t platformExport();
    7782    void platformDestroy();
     
    101106    uint32_t m_texture;
    102107    uint32_t m_fbo;
     108    GraphicsSurfacePrivate* m_private;
    103109};
    104110
  • trunk/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp

    r121250 r122554  
    3030
    3131namespace WebCore {
     32
     33struct GraphicsSurfacePrivate { };
    3234
    3335uint32_t GraphicsSurface::platformExport()
     
    119121}
    120122
    121 bool GraphicsSurface::platformCreate(const IntSize& size, Flags flags)
     123PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags)
    122124{
    123125    unsigned pixelFormat = 'BGRA';
     
    155157        CFRelease(values[i]);
    156158
    157     m_platformSurface = IOSurfaceCreate(dict);
    158     return !!m_platformSurface;
    159 }
    160 
    161 bool GraphicsSurface::platformImport(uint32_t token)
    162 {
    163     m_platformSurface = IOSurfaceLookup(token);
    164     return !!m_platformSurface;
     159    RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
     160    surface->m_platformSurface = IOSurfaceCreate(dict);
     161    if (!surface->m_platformSurface)
     162        return PassRefPtr<GraphicsSurface>();
     163    return surface;
     164}
     165
     166PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, uint32_t token)
     167{
     168    RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
     169    surface->m_platformSurface = IOSurfaceLookup(token);
     170    if (!surface->m_platformSurface)
     171        return PassRefPtr<GraphicsSurface>();
     172    return surface;
    165173}
    166174
  • trunk/Source/WebKit2/ChangeLog

    r122547 r122554  
     12012-07-13  Zeno Albisser  <zeno@webkit.org>
     2
     3        [Qt][WK2] Implement GraphicsSurface for Linux/GLX.
     4        https://bugs.webkit.org/show_bug.cgi?id=90881
     5
     6        Add a GLX based GraphicsSurface implementation for Linux.
     7
     8        Reviewed by Noam Rosenthal.
     9
     10        * Shared/ShareableSurface.cpp:
     11        (WebKit::ShareableSurface::create):
     12            Only create a GraphicsSurface from a ShareableSurface::Handle
     13            in case the Handle contains a valid GraphicsSurface token.
     14            Otherwise fall back to creating a ShareableBitmap.
     15        * UIProcess/LayerTreeCoordinatorProxy.cpp:
     16        (WebKit::createLayerTileUniqueKey):
     17            Create a unique key for a surface based on tileID and layerID.
     18        (WebKit::LayerTreeCoordinatorProxy::updateTileForLayer):
     19            Even when GraphicsSurface is enabled, not all ShareableSurfaces
     20            will necessarily be backed by a GraphicsSurface. In case of
     21            a ShareableSurface being backed by a ShareableBitmap instead,
     22            the GraphicsSurface token will always be null.
     23            So instead of using the GraphicsSurface token as a key for
     24            storing surfaces in a map, we create a unique key from
     25            layerID and tileID.
     26        * UIProcess/LayerTreeCoordinatorProxy.h:
     27        (LayerTreeCoordinatorProxy):
     28
    1292012-07-12  Carlos Garcia Campos  <cgarcia@igalia.com>
    230
  • trunk/Source/WebKit2/Shared/ShareableSurface.cpp

    r113773 r122554  
    150150{
    151151#if USE(GRAPHICS_SURFACE)
     152    if (handle.graphicsSurfaceToken()) {
    152153        RefPtr<GraphicsSurface> surface = GraphicsSurface::create(handle.m_size, handle.m_flags, handle.m_graphicsSurfaceToken);
    153154        if (surface)
    154155            return adoptRef(new ShareableSurface(handle.m_size, handle.m_flags, PassRefPtr<GraphicsSurface>(surface)));
     156    }
    155157#endif
    156158
  • trunk/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.cpp

    r121221 r122554  
    6262}
    6363
     64static inline uint64_t createLayerTileUniqueKey(int layerID, int tileID)
     65{
     66    uint64_t key = layerID;
     67    key <<= 32;
     68    key |= tileID;
     69    return key;
     70}
     71
    6472void LayerTreeCoordinatorProxy::updateTileForLayer(int layerID, int tileID, const IntRect& targetRect, const WebKit::SurfaceUpdateInfo& updateInfo)
    6573{
    6674    RefPtr<ShareableSurface> surface;
    6775#if USE(GRAPHICS_SURFACE)
    68     uint32_t token = updateInfo.surfaceHandle.graphicsSurfaceToken();
    69     HashMap<uint32_t, RefPtr<ShareableSurface> >::iterator it = m_surfaces.find(token);
     76    uint64_t key = createLayerTileUniqueKey(layerID, tileID);
     77
     78    HashMap<uint64_t, RefPtr<ShareableSurface> >::iterator it = m_surfaces.find(key);
    7079    if (it == m_surfaces.end()) {
    7180        surface = ShareableSurface::create(updateInfo.surfaceHandle);
    72         m_surfaces.add(token, surface);
     81        m_surfaces.add(key, surface);
    7382    } else
    7483        surface = it->second;
  • trunk/Source/WebKit2/UIProcess/LayerTreeCoordinatorProxy.h

    r121221 r122554  
    8080    RefPtr<WebLayerTreeRenderer> m_renderer;
    8181#if USE(GRAPHICS_SURFACE)
    82     HashMap<uint32_t, RefPtr<ShareableSurface> > m_surfaces;
     82    HashMap<uint64_t, RefPtr<ShareableSurface> > m_surfaces;
    8383#endif
    8484};
  • trunk/Tools/ChangeLog

    r122551 r122554  
     12012-07-13  Zeno Albisser  <zeno@webkit.org>
     2
     3        [Qt][WK2] Implement GraphicsSurface for Linux/GLX.
     4        https://bugs.webkit.org/show_bug.cgi?id=90881
     5
     6        Enable GraphicsSurface for Linux based platforms
     7        whenever the Xcomposite extension is available.
     8
     9        Reviewed by Noam Rosenthal.
     10
     11        * qmake/config.tests/libXcomposite/libXcomposite.cpp: Added.
     12        (main):
     13        * qmake/config.tests/libXcomposite/libXcomposite.pro: Added.
     14          Add a configure test to detect Xcomposite extension and
     15          activate GraphicsSurface on linux in case the extension is available.
     16        * qmake/configure.pri:
     17        * qmake/mkspecs/features/features.prf:
     18
    1192012-07-13  David Grogan  <dgrogan@chromium.org>
    220
  • trunk/Tools/qmake/configure.pri

    r121963 r122554  
    1616        libjpeg \
    1717        libwebp \
     18        libXcomposite \
    1819        libxml2 \
    1920        libxslt \
  • trunk/Tools/qmake/mkspecs/features/features.prf

    r122219 r122554  
    171171}
    172172
     173# Xcomposite Support
     174haveQt(5):linux-*:config_libXcomposite: DEFINES += HAVE_XCOMPOSITE=1
     175
     176# Support for Graphics Surface
    173177!contains(DEFINES, WTF_USE_GRAPHICS_SURFACE=.) {
    174     haveQt(5):mac: DEFINES += WTF_USE_GRAPHICS_SURFACE=1
     178    haveQt(5) {
     179        mac: DEFINES += WTF_USE_GRAPHICS_SURFACE=1
     180        # On linux we require libXcomposite to enable graphics surface.
     181        linux-*:contains(DEFINES, HAVE_XCOMPOSITE=1): DEFINES += WTF_USE_GRAPHICS_SURFACE=1
     182    }
    175183}
    176184
Note: See TracChangeset for help on using the changeset viewer.