Changeset 170071 in webkit


Ignore:
Timestamp:
Jun 17, 2014 2:06:12 PM (10 years ago)
Author:
Simon Fraser
Message:

[UI-side compositing] fix reflections on composited layers
https://bugs.webkit.org/show_bug.cgi?id=133942

Reviewed by Tim Horton.

Source/WebCore:

Fix reflections on composited layers. There are two main set of changes.

First, a PlatformCALayerRemote which is a clone has to track the layer
it is a clone of, so it knows where to grab the contents from in the UI process.
This layer may be told that its contents need updating out of order during
recursiveBuildTransaction(), so we need some small changes in RemoteLayerTreeContext
to allow a layer to add itself to the set of layers requiring commit.

In the UI process, a new step is added to RemoteLayerTreeHost::updateLayerTree()
to go through clones, and copy their contents from the origin layer.

The second set of changes makes platformCALayerLayerDidDisplay() work for
UI-side compositing by not taking a PlatformLayer*, but instead a PlatformCALayer*.
PlatformCALayer::setContentsChanged() changed to copyContentsFromLayer() so we know
what the origin layer is.

Test: compositing/reflections/repaint-with-reflection.html

  • WebCore.exp.in:
  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::layerDidDisplay): Deleted.

  • platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:

(WebCore::LayerClient::platformCALayerLayerDidDisplay): Deleted.

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayerCA::layerDidDisplay):
(WebCore::GraphicsLayerCA::findOrMakeClone):

  • platform/graphics/ca/GraphicsLayerCA.h:
  • platform/graphics/ca/PlatformCALayer.h:
  • platform/graphics/ca/PlatformCALayerClient.h:

(WebCore::PlatformCALayerClient::platformCALayerLayerDidDisplay):

  • platform/graphics/ca/mac/PlatformCALayerMac.h:
  • platform/graphics/ca/mac/PlatformCALayerMac.mm:

(PlatformCALayerMac::copyContentsFromLayer):
(PlatformCALayerMac::superlayer):
(PlatformCALayerMac::setContentsChanged): Deleted.

  • platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:

(PlatformCALayerWinInternal::displayCallback):

  • platform/graphics/mac/WebLayer.mm:

(-[WebSimpleLayer display]):

Source/WebKit2:

Fix reflections on composited layers. There are two main set of changes.

First, a PlatformCALayerRemote which is a clone has to track the layer
it is a clone of, so it knows where to grab the contents from in the UI process.
This layer may be told that its contents need updating out of order during
recursiveBuildTransaction(), so we need some small changes in RemoteLayerTreeContext
to allow a layer to add itself to the set of layers requiring commit.

In the UI process, a new step is added to RemoteLayerTreeHost::updateLayerTree()
to go through clones, and copy their contents from the origin layer.

The second set of changes makes platformCALayerLayerDidDisplay() work for
UI-side compositing by not taking a PlatformLayer*, but instead a PlatformCALayer*.
PlatformCALayer::setContentsChanged() changed to copyContentsFromLayer() so we know
what the origin layer is.

  • Shared/mac/RemoteLayerBackingStore.mm:

(WebKit::RemoteLayerBackingStore::display): Remove the early return so we can always
call platformCALayerLayerDidDisplay().

  • Shared/mac/RemoteLayerTreeTransaction.h:
  • Shared/mac/RemoteLayerTreeTransaction.mm:

(WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
(WebKit::dumpChangedLayers):

  • UIProcess/mac/RemoteLayerTreeHost.mm:

(WebKit::RemoteLayerTreeHost::updateLayerTree):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:

(WebKit::PlatformCALayerRemote::clone):
(WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
(WebKit::PlatformCALayerRemote::copyContentsFromLayer):
(WebKit::PlatformCALayerRemote::setClonedLayer):
(WebKit::PlatformCALayerRemote::setContentsChanged): Deleted.

  • WebProcess/WebPage/mac/PlatformCALayerRemote.h:

(WebKit::PlatformCALayerRemote::properties):
(WebKit::PlatformCALayerRemote::context):

LayoutTests:

Test with a reflected div, that repaints on a timer to test backing
store updating on the clone.

  • compositing/reflections/repaint-with-reflection-expected.html: Added.
  • compositing/reflections/repaint-with-reflection.html: Added.
Location:
trunk
Files:
2 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r170068 r170071  
     12014-06-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [UI-side compositing] fix reflections on composited layers
     4        https://bugs.webkit.org/show_bug.cgi?id=133942
     5
     6        Reviewed by Tim Horton.
     7       
     8        Test with a reflected div, that repaints on a timer to test backing
     9        store updating on the clone.
     10
     11        * compositing/reflections/repaint-with-reflection-expected.html: Added.
     12        * compositing/reflections/repaint-with-reflection.html: Added.
     13
    1142014-06-17  Commit Queue  <commit-queue@webkit.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r170070 r170071  
     12014-06-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [UI-side compositing] fix reflections on composited layers
     4        https://bugs.webkit.org/show_bug.cgi?id=133942
     5
     6        Reviewed by Tim Horton.
     7
     8        Fix reflections on composited layers. There are two main set of changes.
     9       
     10        First, a PlatformCALayerRemote which is a clone has to track the layer
     11        it is a clone of, so it knows where to grab the contents from in the UI process.
     12        This layer may be told that its contents need updating out of order during
     13        recursiveBuildTransaction(), so we need some small changes in RemoteLayerTreeContext
     14        to allow a layer to add itself to the set of layers requiring commit.
     15       
     16        In the UI process, a new step is added to RemoteLayerTreeHost::updateLayerTree()
     17        to go through clones, and copy their contents from the origin layer.
     18       
     19        The second set of changes makes platformCALayerLayerDidDisplay() work for
     20        UI-side compositing by not taking a PlatformLayer*, but instead a PlatformCALayer*.
     21        PlatformCALayer::setContentsChanged() changed to copyContentsFromLayer() so we know
     22        what the origin layer is.
     23
     24        Test: compositing/reflections/repaint-with-reflection.html
     25
     26        * WebCore.exp.in:
     27        * platform/graphics/GraphicsLayer.h:
     28        (WebCore::GraphicsLayer::layerDidDisplay): Deleted.
     29        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
     30        (WebCore::LayerClient::platformCALayerLayerDidDisplay): Deleted.
     31        * platform/graphics/ca/GraphicsLayerCA.cpp:
     32        (WebCore::GraphicsLayerCA::layerDidDisplay):
     33        (WebCore::GraphicsLayerCA::findOrMakeClone):
     34        * platform/graphics/ca/GraphicsLayerCA.h:
     35        * platform/graphics/ca/PlatformCALayer.h:
     36        * platform/graphics/ca/PlatformCALayerClient.h:
     37        (WebCore::PlatformCALayerClient::platformCALayerLayerDidDisplay):
     38        * platform/graphics/ca/mac/PlatformCALayerMac.h:
     39        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
     40        (PlatformCALayerMac::copyContentsFromLayer):
     41        (PlatformCALayerMac::superlayer):
     42        (PlatformCALayerMac::setContentsChanged): Deleted.
     43        * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
     44        (PlatformCALayerWinInternal::displayCallback):
     45        * platform/graphics/mac/WebLayer.mm:
     46        (-[WebSimpleLayer display]):
     47
    1482014-06-17  Anders Carlsson  <andersca@apple.com>
    249
  • trunk/Source/WebCore/WebCore.exp.in

    r170029 r170071  
    550550__ZN7WebCore15GraphicsLayerCA14setPreserves3DEb
    551551__ZN7WebCore15GraphicsLayerCA15addChildAtIndexEPNS_13GraphicsLayerEi
    552 __ZN7WebCore15GraphicsLayerCA15layerDidDisplayEP7CALayer
     552__ZN7WebCore15GraphicsLayerCA15layerDidDisplayEPNS_15PlatformCALayerE
    553553__ZN7WebCore15GraphicsLayerCA15removeAnimationERKN3WTF6StringE
    554554__ZN7WebCore15GraphicsLayerCA15setBoundsOriginERKNS_10FloatPointE
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r169972 r170071  
    420420    // Callback from the underlying graphics system to draw layer contents.
    421421    void paintGraphicsLayerContents(GraphicsContext&, const FloatRect& clip);
    422     // Callback from the underlying graphics system when the layer has been displayed
    423     virtual void layerDidDisplay(PlatformLayer*) { }
    424422   
    425423    // For hosting this GraphicsLayer in a native layer hierarchy.
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp

    r169568 r170071  
    194194    virtual bool platformCALayerContentsOpaque() const { return false; }
    195195    virtual bool platformCALayerDrawsContent() const { return false; }
    196     virtual void platformCALayerLayerDidDisplay(PlatformLayer*) { }
    197196    virtual float platformCALayerDeviceScaleFactor() const { return 1; }
    198197
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r170037 r170071  
    950950}
    951951   
    952 void GraphicsLayerCA::layerDidDisplay(PlatformLayer* layer)
    953 {
    954     PlatformCALayer* currentLayer = PlatformCALayer::platformCALayer(layer);
    955     PlatformCALayer* sourceLayer;
     952void GraphicsLayerCA::layerDidDisplay(PlatformCALayer* layer)
     953{
    956954    LayerMap* layerCloneMap;
    957955
    958     if (currentLayer == m_layer) {
    959         sourceLayer = m_layer.get();
     956    if (layer == m_layer)
    960957        layerCloneMap = m_layerClones.get();
    961     } else if (currentLayer == m_contentsLayer) {
    962         sourceLayer = m_contentsLayer.get();
     958    else if (layer == m_contentsLayer)
    963959        layerCloneMap = m_contentsLayerClones.get();
    964     } else
     960    else
    965961        return;
    966962
     
    972968                continue;
    973969
    974             if (currClone->contents() != sourceLayer->contents())
    975                 currClone->setContents(sourceLayer->contents());
    976             else
    977                 currClone->setContentsChanged();
     970            currClone->copyContentsFromLayer(layer);
    978971        }
    979972    }
     
    31023095        resultLayer = cloneLayer(sourceLayer, cloneLevel);
    31033096#ifndef NDEBUG
    3104         resultLayer->setName(String::format("Clone %d of layer %p", cloneID[0U], sourceLayer->platformLayer()));
     3097        resultLayer->setName(String::format("Clone %d of layer %llu", cloneID[0U], sourceLayer->layerID()));
    31053098#endif
    31063099        addResult.iterator->value = resultLayer;
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r169690 r170071  
    145145    virtual void setCustomBehavior(CustomBehavior) override;
    146146
    147     virtual void layerDidDisplay(PlatformLayer*) override;
    148 
    149147    virtual void deviceOrPageScaleFactorChanged() override;
    150148
     
    189187    virtual bool platformCALayerContentsOpaque() const override { return contentsOpaque(); }
    190188    virtual bool platformCALayerDrawsContent() const override { return drawsContent(); }
    191     virtual void platformCALayerLayerDidDisplay(PlatformLayer* layer) override { return layerDidDisplay(layer); }
     189    virtual void platformCALayerLayerDidDisplay(PlatformCALayer* layer) override { return layerDidDisplay(layer); }
    192190    virtual void platformCALayerSetNeedsToRevalidateTiles() override;
    193191    virtual float platformCALayerDeviceScaleFactor() const override;
     
    202200    virtual bool shouldRepaintOnSizeChange() const override;
    203201
     202    void layerDidDisplay(PlatformCALayer*);
    204203    void updateOpacityOnLayer();
    205204   
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h

    r170037 r170071  
    103103    virtual void setNeedsDisplay(const FloatRect* dirtyRect = 0) = 0;
    104104
    105     virtual void setContentsChanged() = 0;
     105    virtual void copyContentsFromLayer(PlatformCALayer*) = 0;
    106106
    107107    LayerType layerType() const { return m_layerType; }
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h

    r166997 r170071  
    4949    virtual bool platformCALayerContentsOpaque() const = 0;
    5050    virtual bool platformCALayerDrawsContent() const = 0;
    51     virtual void platformCALayerLayerDidDisplay(PlatformLayer*)  { }
     51    virtual void platformCALayerLayerDidDisplay(PlatformCALayer*)  { }
    5252
    5353    virtual void platformCALayerSetNeedsToRevalidateTiles() { }
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h

    r170037 r170071  
    4747    virtual void setNeedsDisplay(const FloatRect* dirtyRect = 0) override;
    4848
    49     virtual void setContentsChanged() override;
     49    virtual void copyContentsFromLayer(PlatformCALayer*) override;
    5050
    5151    virtual PlatformCALayer* superlayer() const override;
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm

    r170037 r170071  
    324324    END_BLOCK_OBJC_EXCEPTIONS
    325325}
    326    
    327 void PlatformCALayerMac::setContentsChanged()
    328 {
    329     BEGIN_BLOCK_OBJC_EXCEPTIONS
    330     [m_layer.get() setContentsChanged];
     326
     327void PlatformCALayerMac::copyContentsFromLayer(PlatformCALayer* layer)
     328{
     329    BEGIN_BLOCK_OBJC_EXCEPTIONS
     330    CALayer* caLayer = layer->m_layer.get();
     331    if ([m_layer contents] != [caLayer contents])
     332        [m_layer setContents:[caLayer contents]];
     333    else
     334        [m_layer setContentsChanged];
    331335    END_BLOCK_OBJC_EXCEPTIONS
    332336}
     
    334338PlatformCALayer* PlatformCALayerMac::superlayer() const
    335339{
    336     return platformCALayer([m_layer.get() superlayer]);
     340    return platformCALayer([m_layer superlayer]);
    337341}
    338342
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp

    r170037 r170071  
    221221}
    222222
    223 void PlatformCALayerWin::setContentsChanged()
    224 {
    225     // FIXME: There is no equivalent of setContentsChanged in CACF. For now I will
    226     // set contents to 0 and then back to its original value to see if that
    227     // kicks CACF into redisplaying.
    228     RetainPtr<CFTypeRef> contents = CACFLayerGetContents(m_layer.get());
    229     CACFLayerSetContents(m_layer.get(), 0);
    230     CACFLayerSetContents(m_layer.get(), contents.get());
     223void PlatformCALayerWin::copyContentsFromLayer(PlatformCALayer* source)
     224{
     225    if (source) {
     226        RetainPtr<CFTypeRef> contents = CACFLayerGetContents(source->platformLayer());
     227        CACFLayerSetContents(m_layer.get(), contents.get());
     228    } else
     229        CACFLayerSetContents(m_layer.get(), nullptr);
     230
    231231    setNeedsCommit();
    232232}
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h

    r170037 r170071  
    4040    virtual void setNeedsDisplay(const FloatRect* dirtyRect = 0) override;
    4141
    42     virtual void setContentsChanged() override;
     42    virtual void copyContentsFromLayer(PlatformCALayer*) override;
    4343
    4444    virtual PlatformCALayer* superlayer() const override;
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp

    r170037 r170071  
    149149    CGContextRestoreGState(context);
    150150
    151     owner()->owner()->platformCALayerLayerDidDisplay(caLayer);
     151    owner()->owner()->platformCALayerLayerDidDisplay(owner());
    152152}
    153153
  • trunk/Source/WebCore/platform/graphics/mac/WebLayer.mm

    r169960 r170071  
    111111    PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
    112112    if (layer && layer->owner())
    113         layer->owner()->platformCALayerLayerDidDisplay(self);
     113        layer->owner()->platformCALayerLayerDidDisplay(layer);
    114114}
    115115
  • trunk/Source/WebKit2/ChangeLog

    r170069 r170071  
     12014-06-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [UI-side compositing] fix reflections on composited layers
     4        https://bugs.webkit.org/show_bug.cgi?id=133942
     5
     6        Reviewed by Tim Horton.
     7       
     8        Fix reflections on composited layers. There are two main set of changes.
     9       
     10        First, a PlatformCALayerRemote which is a clone has to track the layer
     11        it is a clone of, so it knows where to grab the contents from in the UI process.
     12        This layer may be told that its contents need updating out of order during
     13        recursiveBuildTransaction(), so we need some small changes in RemoteLayerTreeContext
     14        to allow a layer to add itself to the set of layers requiring commit.
     15       
     16        In the UI process, a new step is added to RemoteLayerTreeHost::updateLayerTree()
     17        to go through clones, and copy their contents from the origin layer.
     18       
     19        The second set of changes makes platformCALayerLayerDidDisplay() work for
     20        UI-side compositing by not taking a PlatformLayer*, but instead a PlatformCALayer*.
     21        PlatformCALayer::setContentsChanged() changed to copyContentsFromLayer() so we know
     22        what the origin layer is.
     23
     24        * Shared/mac/RemoteLayerBackingStore.mm:
     25        (WebKit::RemoteLayerBackingStore::display): Remove the early return so we can always
     26        call platformCALayerLayerDidDisplay().
     27        * Shared/mac/RemoteLayerTreeTransaction.h:
     28        * Shared/mac/RemoteLayerTreeTransaction.mm:
     29        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
     30        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
     31        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
     32        (WebKit::dumpChangedLayers):
     33        * UIProcess/mac/RemoteLayerTreeHost.mm:
     34        (WebKit::RemoteLayerTreeHost::updateLayerTree):
     35        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
     36        (WebKit::PlatformCALayerRemote::clone):
     37        (WebKit::PlatformCALayerRemote::recursiveBuildTransaction):
     38        (WebKit::PlatformCALayerRemote::copyContentsFromLayer):
     39        (WebKit::PlatformCALayerRemote::setClonedLayer):
     40        (WebKit::PlatformCALayerRemote::setContentsChanged): Deleted.
     41        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
     42        (WebKit::PlatformCALayerRemote::properties):
     43        (WebKit::PlatformCALayerRemote::context):
     44
    1452014-06-17  Anders Carlsson  <andersca@apple.com>
    246
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm

    r169961 r170071  
    241241
    242242        m_frontBuffer.surface->releaseGraphicsContext();
    243 
    244         return true;
    245     }
    246 #endif
    247 
    248     ASSERT(!m_acceleratesDrawing);
    249     std::unique_ptr<GraphicsContext> context = m_frontBuffer.bitmap->createGraphicsContext();
    250 
    251     RetainPtr<CGImageRef> backImage;
    252     if (m_backBuffer.bitmap && !willPaintEntireBackingStore)
    253         backImage = m_backBuffer.bitmap->makeCGImage();
    254 
    255     drawInContext(*context, backImage.get());
     243    } else
     244#endif
     245    {
     246        ASSERT(!m_acceleratesDrawing);
     247        std::unique_ptr<GraphicsContext> context = m_frontBuffer.bitmap->createGraphicsContext();
     248
     249        RetainPtr<CGImageRef> backImage;
     250        if (m_backBuffer.bitmap && !willPaintEntireBackingStore)
     251            backImage = m_backBuffer.bitmap->makeCGImage();
     252
     253        drawInContext(*context, backImage.get());
     254    }
     255   
     256    m_layer->owner()->platformCALayerLayerDidDisplay(m_layer);
    256257   
    257258    return true;
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h

    r170035 r170071  
    6969        OpaqueChanged = 1 << 16,
    7070        MaskLayerChanged = 1 << 17,
    71         ContentsRectChanged = 1 << 18,
    72         ContentsScaleChanged = 1 << 19,
    73         MinificationFilterChanged = 1 << 20,
    74         MagnificationFilterChanged = 1 << 21,
    75         BlendModeChanged = 1 << 22,
    76         SpeedChanged = 1 << 23,
    77         TimeOffsetChanged = 1 << 24,
    78         BackingStoreChanged = 1 << 25,
    79         FiltersChanged = 1 << 26,
    80         AnimationsChanged = 1 << 27,
    81         EdgeAntialiasingMaskChanged = 1 << 28,
    82         CustomAppearanceChanged = 1 << 29,
    83         CustomBehaviorChanged = 1 << 30
     71        ClonedContentsChanged = 1 << 18,
     72        ContentsRectChanged = 1 << 19,
     73        ContentsScaleChanged = 1 << 20,
     74        MinificationFilterChanged = 1 << 21,
     75        MagnificationFilterChanged = 1 << 22,
     76        BlendModeChanged = 1 << 23,
     77        SpeedChanged = 1 << 24,
     78        TimeOffsetChanged = 1 << 25,
     79        BackingStoreChanged = 1 << 26,
     80        FiltersChanged = 1 << 27,
     81        AnimationsChanged = 1 << 28,
     82        EdgeAntialiasingMaskChanged = 1 << 29,
     83        CustomAppearanceChanged = 1 << 30,
     84        CustomBehaviorChanged = 1 << 31
    8485    };
    8586    typedef unsigned LayerChange;
     
    133134        std::unique_ptr<WebCore::FilterOperations> filters;
    134135        WebCore::GraphicsLayer::PlatformLayerID maskLayerID;
     136        WebCore::GraphicsLayer::PlatformLayerID clonedLayerID;
    135137        double timeOffset;
    136138        float speed;
     
    161163    WebCore::GraphicsLayer::PlatformLayerID rootLayerID() const { return m_rootLayerID; }
    162164    void setRootLayerID(WebCore::GraphicsLayer::PlatformLayerID);
    163     void layerPropertiesChanged(PlatformCALayerRemote*, LayerProperties&);
     165    void layerPropertiesChanged(PlatformCALayerRemote*);
    164166    void setCreatedLayers(Vector<LayerCreationProperties>);
    165167    void setDestroyedLayerIDs(Vector<WebCore::GraphicsLayer::PlatformLayerID>);
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

    r170035 r170071  
    8282    , contentsRect(FloatPoint(), FloatSize(1, 1))
    8383    , maskLayerID(0)
     84    , clonedLayerID(0)
    8485    , timeOffset(0)
    8586    , speed(1)
     
    115116    , contentsRect(other.contentsRect)
    116117    , maskLayerID(other.maskLayerID)
     118    , clonedLayerID(other.clonedLayerID)
    117119    , timeOffset(other.timeOffset)
    118120    , speed(other.speed)
     
    207209        encoder << maskLayerID;
    208210
     211    if (changedProperties & ClonedContentsChanged)
     212        encoder << clonedLayerID;
     213
    209214    if (changedProperties & ContentsRectChanged)
    210215        encoder << contentsRect;
     
    354359    if (result.changedProperties & MaskLayerChanged) {
    355360        if (!decoder.decode(result.maskLayerID))
     361            return false;
     362    }
     363
     364    if (result.changedProperties & ClonedContentsChanged) {
     365        if (!decoder.decode(result.clonedLayerID))
    356366            return false;
    357367    }
     
    550560}
    551561
    552 void RemoteLayerTreeTransaction::layerPropertiesChanged(PlatformCALayerRemote* remoteLayer, RemoteLayerTreeTransaction::LayerProperties& properties)
     562void RemoteLayerTreeTransaction::layerPropertiesChanged(PlatformCALayerRemote* remoteLayer)
    553563{
    554564    m_changedLayers.append(remoteLayer);
     
    10581068        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged)
    10591069            dumpProperty(ts, "maskLayer", layerProperties.maskLayerID);
     1070
     1071        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ClonedContentsChanged)
     1072            dumpProperty(ts, "clonedLayer", layerProperties.clonedLayerID);
    10601073
    10611074        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::ContentsRectChanged)
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm

    r169957 r170071  
    7272    }
    7373
     74    typedef std::pair<GraphicsLayer::PlatformLayerID, GraphicsLayer::PlatformLayerID> LayerIDPair;
     75    Vector<LayerIDPair> clonesToUpdate;
     76   
    7477    for (auto& changedLayer : transaction.changedLayerProperties()) {
    7578        auto layerID = changedLayer.key;
     
    8891            relatedLayers.set(properties.maskLayerID, getLayer(properties.maskLayerID));
    8992
     93        if (properties.changedProperties & RemoteLayerTreeTransaction::ClonedContentsChanged && properties.clonedLayerID)
     94            clonesToUpdate.append(LayerIDPair(layerID, properties.clonedLayerID));
     95
    9096        if (m_isDebugLayerTreeHost) {
    9197            RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers);
     
    96102        } else
    97103            RemoteLayerTreePropertyApplier::applyProperties(layer, this, properties, relatedLayers);
     104    }
     105   
     106    for (const auto& layerPair : clonesToUpdate) {
     107        LayerOrView *layer = getLayer(layerPair.first);
     108        LayerOrView *clonedLayer = getLayer(layerPair.second);
     109        asLayer(layer).contents = asLayer(clonedLayer).contents;
    98110    }
    99111
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

    r168901 r170071  
    105105    clone->m_properties.notePropertiesChanged(static_cast<RemoteLayerTreeTransaction::LayerChange>(m_properties.everChangedProperties & ~RemoteLayerTreeTransaction::BackingStoreChanged));
    106106
     107    clone->setClonedLayer(this);
    107108    return clone.release();
    108109}
     
    142143        }
    143144
    144         transaction.layerPropertiesChanged(this, m_properties);
     145        transaction.layerPropertiesChanged(this);
    145146    }
    146147
     
    193194}
    194195
    195 void PlatformCALayerRemote::setContentsChanged()
    196 {
     196void PlatformCALayerRemote::copyContentsFromLayer(PlatformCALayer* layer)
     197{
     198    ASSERT(m_properties.clonedLayerID == layer->layerID());
     199   
     200    if (!m_properties.changedProperties)
     201        m_context->layerPropertyChangedWhileBuildingTransaction(this);
     202
     203    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ClonedContentsChanged);
    197204}
    198205
     
    338345}
    339346
     347void PlatformCALayerRemote::setClonedLayer(const PlatformCALayer* layer)
     348{
     349    if (layer)
     350        m_properties.clonedLayerID = layer->layerID();
     351    else
     352        m_properties.clonedLayerID = 0;
     353
     354    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ClonedContentsChanged);
     355}
     356
    340357bool PlatformCALayerRemote::isOpaque() const
    341358{
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

    r170037 r170071  
    5050    virtual void setNeedsDisplay(const WebCore::FloatRect* dirtyRect = 0) override;
    5151
    52     virtual void setContentsChanged() override;
     52    virtual void copyContentsFromLayer(PlatformCALayer*) override;
    5353
    5454    virtual WebCore::PlatformCALayer* superlayer() const override;
     
    154154    virtual uint32_t hostingContextID();
    155155
     156    void setClonedLayer(const PlatformCALayer*);
     157
    156158    RemoteLayerTreeTransaction::LayerProperties& properties() { return m_properties; }
     159    const RemoteLayerTreeTransaction::LayerProperties& properties() const { return m_properties; }
    157160
    158161    void didCommit();
     
    163166    PlatformCALayerRemote(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext* context);
    164167    PlatformCALayerRemote(const PlatformCALayerRemote&, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
     168
     169    RemoteLayerTreeContext* context() const { return m_context; }
    165170
    166171private:
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.h

    r169370 r170071  
    5757    void buildTransaction(RemoteLayerTreeTransaction&, WebCore::PlatformCALayer& rootLayer);
    5858
     59    void layerPropertyChangedWhileBuildingTransaction(PlatformCALayerRemote*);
     60
    5961    // From the UI process
    6062    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, const String& key, double startTime);
     
    7779
    7880    RemoteLayerBackingStoreCollection m_backingStoreCollection;
     81   
     82    RemoteLayerTreeTransaction* m_currentTransaction;
    7983};
    8084
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm

    r169370 r170071  
    4545    : m_webPage(webPage)
    4646    , m_backingStoreCollection(this)
     47    , m_currentTransaction(nullptr)
    4748{
    4849}
     
    102103    transaction.setRootLayerID(rootLayerRemote.layerID());
    103104
     105    m_currentTransaction = &transaction;
    104106    rootLayerRemote.recursiveBuildTransaction(transaction);
     107    m_currentTransaction = nullptr;
    105108
    106109    transaction.setCreatedLayers(std::move(m_createdLayers));
    107110    transaction.setDestroyedLayerIDs(std::move(m_destroyedLayers));
     111}
     112
     113void RemoteLayerTreeContext::layerPropertyChangedWhileBuildingTransaction(PlatformCALayerRemote* layer)
     114{
     115    if (m_currentTransaction)
     116        m_currentTransaction->layerPropertiesChanged(layer);
    108117}
    109118
Note: See TracChangeset for help on using the changeset viewer.