Changeset 193630 in webkit


Ignore:
Timestamp:
Dec 7, 2015 9:15:56 AM (8 years ago)
Author:
yoon@igalia.com
Message:

[ThreadedCompositor] Add support for PlatformLayer.
https://bugs.webkit.org/show_bug.cgi?id=143299

Reviewed by Žan Doberšek.

Source/WebCore:

This patch implements TextureMapperPlatformLayerProxy and TextureMapperPlatformLayerBuffer to
send a texture (actual texture or BitmapTexture) to the compositing thread directly.
Platform layer renderers should implement TextureMapperPlatformLayerProxyProvider to establish
a connection to the compositing thread. After the connection has been established, the renderer
can render its contents to the TextureMapperPlatformLayerBuffer and pass it to the compositing thread
via TextureMapperPlatformLayer proxy.
The buffer can be an unmanaged texture (a.k.a. platform texture) or BitmapTexture.
For the unmanaged texture, the renderer should manage its life cycle itself. For the BitmapTexture,
it will be managed by TextureMapperPlatformLayerProxy. In that case, used (swapped) buffer will be
recycled because the renderer will use same size and format until it changes its size.

No new tests needed.

  • PlatformGTK.cmake:

Adds TextureMapperPlatformLayerBuffer and TextureMapperPlaytformLayerProxy.

  • platform/graphics/GraphicsContext3DPrivate.cpp:
  • platform/graphics/GraphicsContext3DPrivate.h:
  • platform/graphics/cairo/ImageBufferCairo.cpp:
  • platform/graphics/cairo/ImageBufferDataCairo.h:

Adds mock implementation.

  • platform/graphics/PlatformLayer.h:

Adds TextureMapperPlatformLayerProxyProvider as a PlatformLayer for the Threaded Compositor

  • platform/graphics/texmap/BitmapTextureGL.h:

(WebCore::BitmapTextureGL::internalFormat): Adds a getter to check the
internal format of texture to check reusability.

  • platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
  • platform/graphics/texmap/GraphicsLayerTextureMapper.h:
  • platform/graphics/texmap/TextureMapperLayer.cpp:
  • platform/graphics/texmap/TextureMapperLayer.h:

Exclude GraphicsLayerTextureMapper from build when we are using Coordinated Graphics.

  • platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp: Added.
  • platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h: Added.
  • platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp: Added.
  • platform/graphics/texmap/TextureMapperPlatformLayerProxy.h: Added.
  • platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:

(WebCore::GraphicsLayer::create):
Because we removed GraphicsLayerTextureMapper from build, we need to add own factory function.

(WebCore::CoordinatedGraphicsLayer::setContentsToPlatformLayer):
(WebCore::CoordinatedGraphicsLayer::syncPlatformLayer):
(WebCore::CoordinatedGraphicsLayer::platformLayerWillBeDestroyed):
(WebCore::CoordinatedGraphicsLayer::setPlatformLayerNeedsDisplay):
Implements sync operations for TextureMapperPlatformLayerProxy

Source/WebKit2:

  • Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:

(WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext):
Swap pending buffers of TextureMapperPlatformLayerProxies before painting contents.
(WebKit::CoordinatedGraphicsScene::syncPlatformLayerIfNeeded):
In threaded compositor, CoordinatedGraphicsScence only cares about creation and deletion
of platform layers.

(WebKit::CoordinatedGraphicsScene::onNewBufferAvailable):
Whenever new buffer comes via TextureMapperPlatformLayerProxy, CoordinatedGraphicsScene will
update the scene if it is needed.

Location:
trunk/Source
Files:
4 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r193621 r193630  
     12015-12-07  Gwang Yoon Hwang  <yoon@igalia.com>
     2
     3        [ThreadedCompositor] Add support for PlatformLayer.
     4        https://bugs.webkit.org/show_bug.cgi?id=143299
     5
     6        Reviewed by Žan Doberšek.
     7
     8        This patch implements TextureMapperPlatformLayerProxy and TextureMapperPlatformLayerBuffer to
     9        send a texture (actual texture or BitmapTexture) to the compositing thread directly.
     10        Platform layer renderers should implement TextureMapperPlatformLayerProxyProvider to establish
     11        a connection to the compositing thread. After the connection has been established, the renderer
     12        can render its contents to the TextureMapperPlatformLayerBuffer and pass it to the compositing thread
     13        via TextureMapperPlatformLayer proxy.
     14        The buffer can be an unmanaged texture (a.k.a. platform texture) or BitmapTexture.
     15        For the unmanaged texture, the renderer should manage its life cycle itself. For the BitmapTexture,
     16        it will be managed by TextureMapperPlatformLayerProxy. In that case, used (swapped) buffer will be
     17        recycled because the renderer will use same size and format until it changes its size.
     18
     19        No new tests needed.
     20
     21        * PlatformGTK.cmake:
     22        Adds TextureMapperPlatformLayerBuffer and TextureMapperPlaytformLayerProxy.
     23
     24        * platform/graphics/GraphicsContext3DPrivate.cpp:
     25        * platform/graphics/GraphicsContext3DPrivate.h:
     26        * platform/graphics/cairo/ImageBufferCairo.cpp:
     27        * platform/graphics/cairo/ImageBufferDataCairo.h:
     28        Adds mock implementation.
     29
     30        * platform/graphics/PlatformLayer.h:
     31        Adds TextureMapperPlatformLayerProxyProvider as a PlatformLayer for the Threaded Compositor
     32
     33        * platform/graphics/texmap/BitmapTextureGL.h:
     34        (WebCore::BitmapTextureGL::internalFormat): Adds a getter to check the
     35        internal format of texture to check reusability.
     36
     37        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
     38        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
     39        * platform/graphics/texmap/TextureMapperLayer.cpp:
     40        * platform/graphics/texmap/TextureMapperLayer.h:
     41        Exclude GraphicsLayerTextureMapper from build when we are using Coordinated Graphics.
     42
     43        * platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp: Added.
     44        * platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h: Added.
     45        * platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp: Added.
     46        * platform/graphics/texmap/TextureMapperPlatformLayerProxy.h: Added.
     47
     48        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
     49        (WebCore::GraphicsLayer::create):
     50        Because we removed GraphicsLayerTextureMapper from build, we need to add own factory function.
     51
     52        (WebCore::CoordinatedGraphicsLayer::setContentsToPlatformLayer):
     53        (WebCore::CoordinatedGraphicsLayer::syncPlatformLayer):
     54        (WebCore::CoordinatedGraphicsLayer::platformLayerWillBeDestroyed):
     55        (WebCore::CoordinatedGraphicsLayer::setPlatformLayerNeedsDisplay):
     56        Implements sync operations for TextureMapperPlatformLayerProxy
     57
    1582015-12-07  Gwang Yoon Hwang  <yoon@igalia.com>
    259
  • trunk/Source/WebCore/PlatformGTK.cmake

    r192602 r193630  
    443443        page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp
    444444
     445        platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp
     446        platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp
    445447        platform/graphics/texmap/coordinated/AreaAllocator.cpp
    446448        platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp

    r183807 r193630  
    6464GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
    6565{
    66 #if USE(TEXTURE_MAPPER)
     66#if USE(TEXTURE_MAPPER) && !USE(COORDINATED_GRAPHICS_THREADED)
    6767    if (client())
    6868        client()->platformLayerWillBeDestroyed();
     
    8080}
    8181
    82 #if USE(TEXTURE_MAPPER)
     82#if USE(COORDINATED_GRAPHICS_THREADED)
     83RefPtr<TextureMapperPlatformLayerProxy> GraphicsContext3DPrivate::proxy() const
     84{
     85    notImplemented();
     86    return nullptr;
     87}
     88#elif USE(TEXTURE_MAPPER)
    8389void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
    8490{
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h

    r177786 r193630  
    2424#include "GraphicsContext3D.h"
    2525
    26 #if USE(TEXTURE_MAPPER)
     26#if USE(COORDINATED_GRAPHICS_THREADED)
     27#include "TextureMapperPlatformLayerProxy.h"
     28#elif USE(TEXTURE_MAPPER)
    2729#include "TextureMapperPlatformLayer.h"
    2830#endif
     
    3133
    3234class GraphicsContext3DPrivate
    33 #if USE(TEXTURE_MAPPER)
     35#if USE(COORDINATED_GRAPHICS_THREADED)
     36    : public TextureMapperPlatformLayerProxyProvider
     37#elif USE(TEXTURE_MAPPER)
    3438    : public TextureMapperPlatformLayer
    3539#endif
     
    4347    GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
    4448
    45 #if USE(TEXTURE_MAPPER)
     49#if USE(COORDINATED_GRAPHICS_THREADED)
     50    virtual RefPtr<TextureMapperPlatformLayerProxy> proxy() const override;
     51    virtual void swapBuffersIfNeeded() override { };
     52#elif USE(TEXTURE_MAPPER)
    4653    virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity);
    4754#endif
  • trunk/Source/WebCore/platform/graphics/PlatformLayer.h

    r165676 r193630  
    3232#elif PLATFORM(WIN) && USE(CA)
    3333typedef struct _CACFLayer PlatformLayer;
     34#elif USE(COORDINATED_GRAPHICS_THREADED)
     35namespace WebCore {
     36class TextureMapperPlatformLayerProxyProvider;
     37typedef TextureMapperPlatformLayerProxyProvider PlatformLayer;
     38};
    3439#elif USE(TEXTURE_MAPPER)
    3540namespace WebCore {
  • trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp

    r192140 r193630  
    5353#include "TextureMapperGL.h"
    5454#include <cairo-gl.h>
     55#if USE(COORDINATED_GRAPHICS_THREADED)
     56#include "TextureMapperPlatformLayerProxy.h"
     57#endif
    5558#endif
    5659
     
    410413
    411414#if ENABLE(ACCELERATED_2D_CANVAS)
     415#if USE(COORDINATED_GRAPHICS_THREADED)
     416RefPtr<TextureMapperPlatformLayerProxy> ImageBufferData::proxy() const
     417{
     418    notImplemented();
     419    return nullptr;
     420}
     421#else
    412422void ImageBufferData::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
    413423{
     
    421431    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_texture, TextureMapperGL::ShouldBlend, m_size, targetRect, matrix, opacity);
    422432}
     433#endif
    423434#endif
    424435
  • trunk/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h

    r183265 r193630  
    3434#if ENABLE(ACCELERATED_2D_CANVAS)
    3535#include "TextureMapper.h"
     36#if USE(COORDINATED_GRAPHICS_THREADED)
     37#include "TextureMapperPlatformLayerProxy.h"
     38#else
    3639#include "TextureMapperPlatformLayer.h"
     40#endif
    3741#endif
    3842
     
    4347class ImageBufferData
    4448#if ENABLE(ACCELERATED_2D_CANVAS)
     49#if USE(COORDINATED_GRAPHICS_THREADED)
     50    : public TextureMapperPlatformLayerProxyProvider
     51#else
    4552    : public TextureMapperPlatformLayer
     53#endif
    4654#endif
    4755{
     
    5563
    5664#if ENABLE(ACCELERATED_2D_CANVAS)
     65#if USE(COORDINATED_GRAPHICS_THREADED)
     66    virtual RefPtr<TextureMapperPlatformLayerProxy> proxy() const override;
     67    virtual void swapBuffersIfNeeded() override { };
     68#else
    5769    virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity);
     70#endif
    5871    uint32_t m_texture;
    5972#endif
  • trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h

    r191541 r193630  
    7070    TextureMapperGL::ClipStack& clipStack() { return m_clipStack; }
    7171
     72    GC3Dint internalFormat() const { return m_internalFormat; }
     73
    7274private:
    7375
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp

    r190344 r193630  
    2727#include <wtf/CurrentTime.h>
    2828
    29 #if USE(TEXTURE_MAPPER)
     29#if USE(TEXTURE_MAPPER) && !USE(COORDINATED_GRAPHICS)
    3030
    3131namespace WebCore {
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h

    r186156 r193630  
    2121#define GraphicsLayerTextureMapper_h
    2222
    23 #if USE(TEXTURE_MAPPER)
     23#if USE(TEXTURE_MAPPER) && !USE(COORDINATED_GRAPHICS)
    2424
    2525#include "GraphicsLayer.h"
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

    r192900 r193630  
    446446}
    447447
     448#if !USE(COORDINATED_GRAPHICS)
    448449void TextureMapperLayer::setChildren(const Vector<GraphicsLayer*>& newChildren)
    449450{
     
    452453        addChild(&downcast<GraphicsLayerTextureMapper>(child)->layer());
    453454}
     455#endif
    454456
    455457void TextureMapperLayer::setChildren(const Vector<TextureMapperLayer*>& newChildren)
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h

    r187002 r193630  
    7979    void setTextureMapper(TextureMapper* texmap) { m_textureMapper = texmap; }
    8080
     81#if !USE(COORDINATED_GRAPHICS)
    8182    void setChildren(const Vector<GraphicsLayer*>&);
     83#endif
    8284    void setChildren(const Vector<TextureMapperLayer*>&);
    8385    void setMaskLayer(TextureMapperLayer*);
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

    r192900 r193630  
    3131#include "GraphicsContext.h"
    3232#include "GraphicsLayer.h"
     33#include "GraphicsLayerFactory.h"
    3334#include "Page.h"
    3435#include "ScrollableArea.h"
    35 #include "TextureMapperPlatformLayer.h"
    3636#include <wtf/CurrentTime.h>
    3737#include <wtf/HashMap.h>
     
    4242
    4343namespace WebCore {
     44
     45std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
     46{
     47    if (!factory)
     48        return std::make_unique<CoordinatedGraphicsLayer>(layerType, client);
     49
     50    return factory->createGraphicsLayer(layerType, client);
     51}
    4452
    4553static CoordinatedLayerID toCoordinatedLayerID(GraphicsLayer* layer)
     
    122130    , m_pendingPlatformLayerOperation(None)
    123131#endif
     132#if USE(COORDINATED_GRAPHICS_THREADED)
     133    , m_shouldSyncPlatformLayer(false)
     134#endif
    124135    , m_coordinator(0)
    125136    , m_compositedNativeImagePtr(0)
     
    407418
    408419    notifyFlushRequired();
     420#elif USE(COORDINATED_GRAPHICS_THREADED)
     421    if (m_platformLayer != platformLayer)
     422        m_shouldSyncPlatformLayer = true;
     423
     424    m_platformLayer = platformLayer;
     425    notifyFlushRequired();
    409426#else
    410427    UNUSED_PARAM(platformLayer);
     
    695712}
    696713
     714void CoordinatedGraphicsLayer::syncPlatformLayer()
     715{
    697716#if USE(GRAPHICS_SURFACE)
    698 void CoordinatedGraphicsLayer::syncPlatformLayer()
    699 {
    700717    destroyPlatformLayerIfNeeded();
    701718    createPlatformLayerIfNeeded();
     
    712729    m_layerState.platformLayerFrontBuffer = m_platformLayer->copyToGraphicsSurface();
    713730    m_layerState.platformLayerShouldSwapBuffers = true;
    714 }
    715 
     731#elif USE(COORDINATED_GRAPHICS_THREADED)
     732    if (!m_shouldSyncPlatformLayer)
     733        return;
     734
     735    m_shouldSyncPlatformLayer = false;
     736    m_layerState.platformLayerChanged = true;
     737    if (m_platformLayer) {
     738        m_platformLayer->swapBuffersIfNeeded();
     739        m_layerState.platformLayerProxy = m_platformLayer->proxy();
     740    }
     741#endif
     742}
     743
     744#if USE(GRAPHICS_SURFACE)
    716745void CoordinatedGraphicsLayer::destroyPlatformLayerIfNeeded()
    717746{
     
    764793    syncChildren();
    765794    syncFilters();
    766 #if USE(GRAPHICS_SURFACE)
    767795    syncPlatformLayer();
    768 #endif
    769796
    770797    // Only unset m_movingVisibleRect after we have updated the visible rect after the animation stopped.
     
    11901217    client().notifyAnimationStarted(this, "", m_lastAnimationStartTime);
    11911218}
     1219
     1220#if USE(COORDINATED_GRAPHICS_THREADED)
     1221void CoordinatedGraphicsLayer::platformLayerWillBeDestroyed()
     1222{
     1223}
     1224
     1225void CoordinatedGraphicsLayer::setPlatformLayerNeedsDisplay()
     1226{
     1227}
     1228#endif
     1229
    11921230} // namespace WebCore
     1231
    11931232#endif // USE(COORDINATED_GRAPHICS)
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h

    r190095 r193630  
    3030#include "IntSize.h"
    3131#include "TextureMapperAnimation.h"
     32#include "TextureMapperPlatformLayer.h"
    3233#include "TiledBackingStore.h"
    3334#include "TiledBackingStoreClient.h"
     
    5859class CoordinatedGraphicsLayer : public GraphicsLayer
    5960    , public TiledBackingStoreClient
     61#if USE(COORDINATED_GRAPHICS_THREADED)
     62    , public TextureMapperPlatformLayer::Client
     63#endif
    6064    , public CoordinatedImageBacking::Host {
    6165public:
     
    156160    };
    157161
    158     void syncPlatformLayer();
    159162    void destroyPlatformLayerIfNeeded();
    160163    void createPlatformLayerIfNeeded();
     164#endif
     165    void syncPlatformLayer();
     166#if USE(COORDINATED_GRAPHICS_THREADED)
     167    void platformLayerWillBeDestroyed();
     168    void setPlatformLayerNeedsDisplay();
    161169#endif
    162170
     
    224232    unsigned m_pendingPlatformLayerOperation : 3;
    225233#endif
     234#if USE(COORDINATED_GRAPHICS_THREADED)
     235    bool m_shouldSyncPlatformLayer : 1;
     236#endif
    226237
    227238    CoordinatedGraphicsLayerClient* m_coordinator;
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h

    r180580 r193630  
    4343#include "GraphicsSurface.h"
    4444#include "GraphicsSurfaceToken.h"
     45#endif
     46
     47#if USE(COORDINATED_GRAPHICS_THREADED)
     48#include "TextureMapperPlatformLayerProxy.h"
    4549#endif
    4650
     
    131135        , platformLayerFrontBuffer(0)
    132136#endif
     137#if USE(COORDINATED_GRAPHICS_THREADED)
     138        , platformLayerProxy(0)
     139#endif
    133140    {
    134141    }
     
    165172#endif
    166173
     174#if USE(COORDINATED_GRAPHICS_THREADED)
     175    RefPtr<TextureMapperPlatformLayerProxy> platformLayerProxy;
     176#endif
     177
    167178    IntSize committedScrollOffset;
    168179
  • trunk/Source/WebKit2/ChangeLog

    r193626 r193630  
     12015-12-07  Gwang Yoon Hwang  <yoon@igalia.com>
     2
     3        [ThreadedCompositor] Add support for PlatformLayer.
     4        https://bugs.webkit.org/show_bug.cgi?id=143299
     5
     6        Reviewed by Žan Doberšek.
     7
     8        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
     9        (WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext):
     10        Swap pending buffers of TextureMapperPlatformLayerProxies before painting contents.
     11        (WebKit::CoordinatedGraphicsScene::syncPlatformLayerIfNeeded):
     12        In threaded compositor, CoordinatedGraphicsScence only cares about creation and deletion
     13        of platform layers.
     14
     15        (WebKit::CoordinatedGraphicsScene::onNewBufferAvailable):
     16        Whenever new buffer comes via TextureMapperPlatformLayerProxy, CoordinatedGraphicsScene will
     17        update the scene if it is needed.
     18
    1192015-12-07  Mario Sanchez Prada  <mario@endlessm.com>
    220
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp

    r188594 r193630  
    8383    if (!currentRootLayer)
    8484        return;
     85
     86#if USE(COORDINATED_GRAPHICS_THREADED)
     87    for (auto& proxy : m_platformLayerProxies.values())
     88        proxy->swapBuffer();
     89#endif
    8590
    8691    currentRootLayer->setTextureMapper(m_textureMapper.get());
     
    165170}
    166171
     172void CoordinatedGraphicsScene::syncPlatformLayerIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
     173{
    167174#if USE(GRAPHICS_SURFACE)
    168 void CoordinatedGraphicsScene::createPlatformLayerIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
    169 {
    170     if (!state.platformLayerToken.isValid())
    171         return;
    172 
    173     RefPtr<TextureMapperSurfaceBackingStore> platformLayerBackingStore(TextureMapperSurfaceBackingStore::create());
    174     m_surfaceBackingStores.set(layer, platformLayerBackingStore);
    175     platformLayerBackingStore->setGraphicsSurface(GraphicsSurface::create(state.platformLayerSize, state.platformLayerSurfaceFlags, state.platformLayerToken));
    176     layer->setContentsLayer(platformLayerBackingStore.get());
    177 }
    178 
    179 void CoordinatedGraphicsScene::syncPlatformLayerIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
    180 {
    181175    ASSERT(m_textureMapper);
    182176
     
    192186        platformLayerBackingStore->swapBuffersIfNeeded(state.platformLayerFrontBuffer);
    193187    }
     188#elif USE(COORDINATED_GRAPHICS_THREADED)
     189    if (!state.platformLayerChanged)
     190        return;
     191
     192    if (state.platformLayerProxy) {
     193        m_platformLayerProxies.set(layer, state.platformLayerProxy);
     194        state.platformLayerProxy->activateOnCompositingThread(this, layer);
     195    } else
     196        m_platformLayerProxies.remove(layer);
     197#else
     198    UNUSED_PARAM(layer);
     199    UNUSED_PARAM(state);
     200#endif
     201}
     202
     203#if USE(COORDINATED_GRAPHICS_THREADED)
     204void CoordinatedGraphicsScene::onNewBufferAvailable()
     205{
     206    RefPtr<CoordinatedGraphicsScene> protector(this);
     207    dispatchOnClientRunLoop([=] {
     208        protector->updateViewport();
     209    });
     210}
     211#endif
     212
     213#if USE(GRAPHICS_SURFACE)
     214void CoordinatedGraphicsScene::createPlatformLayerIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
     215{
     216    if (!state.platformLayerToken.isValid())
     217        return;
     218
     219    RefPtr<TextureMapperSurfaceBackingStore> platformLayerBackingStore(TextureMapperSurfaceBackingStore::create());
     220    m_surfaceBackingStores.set(layer, platformLayerBackingStore);
     221    platformLayerBackingStore->setGraphicsSurface(GraphicsSurface::create(state.platformLayerSize, state.platformLayerSurfaceFlags, state.platformLayerToken));
     222    layer->setContentsLayer(platformLayerBackingStore.get());
    194223}
    195224
     
    314343    setLayerFiltersIfNeeded(layer, layerState);
    315344    setLayerAnimationsIfNeeded(layer, layerState);
    316 #if USE(GRAPHICS_SURFACE)
    317345    syncPlatformLayerIfNeeded(layer, layerState);
    318 #endif
    319346    setLayerRepaintCountIfNeeded(layer, layerState);
    320347}
     
    354381#if USE(GRAPHICS_SURFACE)
    355382    m_surfaceBackingStores.remove(layer.get());
     383#endif
     384#if USE(COORDINATED_GRAPHICS_THREADED)
     385    if (auto platformLayerProxy = m_platformLayerProxies.take(layer.get()))
     386        platformLayerProxy->invalidate();
    356387#endif
    357388}
     
    632663#if USE(GRAPHICS_SURFACE)
    633664    m_surfaceBackingStores.clear();
     665#endif
     666#if USE(COORDINATED_GRAPHICS_THREADED)
     667    m_platformLayerProxies.clear();
    634668#endif
    635669    m_surfaces.clear();
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h

    r188594 r193630  
    4646#endif
    4747
     48#if USE(COORDINATED_GRAPHICS_THREADED)
     49#include <WebCore/TextureMapperPlatformLayerProxy.h>
     50#endif
     51
    4852namespace WebKit {
    4953
     
    5963};
    6064
    61 class CoordinatedGraphicsScene : public ThreadSafeRefCounted<CoordinatedGraphicsScene>, public WebCore::TextureMapperLayer::ScrollingClient {
     65class CoordinatedGraphicsScene : public ThreadSafeRefCounted<CoordinatedGraphicsScene>, public WebCore::TextureMapperLayer::ScrollingClient
     66#if USE(COORDINATED_GRAPHICS_THREADED)
     67    , public WebCore::TextureMapperPlatformLayerProxy::Compositor
     68#endif
     69{
    6270public:
    6371    explicit CoordinatedGraphicsScene(CoordinatedGraphicsSceneClient*);
     
    95103    void setLayerFiltersIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
    96104    void setLayerAnimationsIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
     105    void syncPlatformLayerIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
    97106#if USE(GRAPHICS_SURFACE)
    98107    void createPlatformLayerIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
    99     void syncPlatformLayerIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
    100108    void destroyPlatformLayerIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&);
    101109#endif
     
    145153    void dispatchCommitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset);
    146154
     155#if USE(COORDINATED_GRAPHICS_THREADED)
     156    virtual void onNewBufferAvailable() override;
     157#endif
     158
    147159    // Render queue can be accessed ony from main thread or updatePaintNode call stack!
    148160    Vector<std::function<void()>> m_renderQueue;
     
    163175    typedef HashMap<WebCore::TextureMapperLayer*, RefPtr<WebCore::TextureMapperSurfaceBackingStore>> SurfaceBackingStoreMap;
    164176    SurfaceBackingStoreMap m_surfaceBackingStores;
     177#endif
     178
     179#if USE(COORDINATED_GRAPHICS_THREADED)
     180    typedef HashMap<WebCore::TextureMapperLayer*, RefPtr<WebCore::TextureMapperPlatformLayerProxy>> PlatformLayerProxyMap;
     181    PlatformLayerProxyMap m_platformLayerProxies;
    165182#endif
    166183
Note: See TracChangeset for help on using the changeset viewer.