Changeset 164405 in webkit


Ignore:
Timestamp:
Feb 19, 2014, 6:03:37 PM (12 years ago)
Author:
Simon Fraser
Message:

[UI-Side Compositing] 6% of main thread time spent copying LayerProperties when adding to hash table
https://bugs.webkit.org/show_bug.cgi?id=129074

Reviewed by Tim Horton.

Make RemoteLayerTreeTransaction::LayerProperties smaller and not copied by
value everywhere.

Put some big members into unique_ptrs, and store unique_ptrs
in the hash of layerID to properties.

Clean up member variable order of LayerProperties to improve packing.

Also have applyPropertiesToLayer() take references to things to avoid
copies.

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

(WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):

  • Shared/mac/RemoteLayerTreeTransaction.h:

(WebKit::RemoteLayerTreeTransaction::changedLayers):

  • Shared/mac/RemoteLayerTreeTransaction.mm:

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

  • UIProcess/mac/RemoteLayerTreeHost.h:
  • UIProcess/mac/RemoteLayerTreeHost.mm:

(WebKit::RemoteLayerTreeHost::updateLayerTree):
(WebKit::RemoteLayerTreeHost::createLayer):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:

(PlatformCALayerRemote::create):
(PlatformCALayerRemote::PlatformCALayerRemote):
(PlatformCALayerRemote::clone):
(PlatformCALayerRemote::recursiveBuildTransaction):
(PlatformCALayerRemote::ensureBackingStore):
(PlatformCALayerRemote::setNeedsDisplay):
(PlatformCALayerRemote::transform):
(PlatformCALayerRemote::setTransform):
(PlatformCALayerRemote::sublayerTransform):
(PlatformCALayerRemote::setSublayerTransform):
(PlatformCALayerRemote::setFilters):
(PlatformCALayerRemote::enumerateRectsBeingDrawn):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.h:
Location:
trunk/Source/WebKit2
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r164402 r164405  
     12014-02-19  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [UI-Side Compositing] 6% of main thread time spent copying LayerProperties when adding to hash table
     4        https://bugs.webkit.org/show_bug.cgi?id=129074
     5
     6        Reviewed by Tim Horton.
     7       
     8        Make RemoteLayerTreeTransaction::LayerProperties smaller and not copied by
     9        value everywhere.
     10       
     11        Put some big members into unique_ptrs, and store unique_ptrs
     12        in the hash of layerID to properties.
     13       
     14        Clean up member variable order of LayerProperties to improve packing.
     15       
     16        Also have applyPropertiesToLayer() take references to things to avoid
     17        copies.
     18       
     19        * Shared/mac/RemoteLayerTreePropertyApplier.h:
     20        * Shared/mac/RemoteLayerTreePropertyApplier.mm:
     21        (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):
     22        * Shared/mac/RemoteLayerTreeTransaction.h:
     23        (WebKit::RemoteLayerTreeTransaction::changedLayers):
     24        * Shared/mac/RemoteLayerTreeTransaction.mm:
     25        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
     26        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
     27        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
     28        (WebKit::RemoteLayerTreeTransaction::encode):
     29        (WebKit::RemoteLayerTreeTransaction::decode):
     30        (WebKit::RemoteLayerTreeTransaction::layerPropertiesChanged):
     31        (WebKit::dumpChangedLayers):
     32        * UIProcess/mac/RemoteLayerTreeHost.h:
     33        * UIProcess/mac/RemoteLayerTreeHost.mm:
     34        (WebKit::RemoteLayerTreeHost::updateLayerTree):
     35        (WebKit::RemoteLayerTreeHost::createLayer):
     36        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
     37        (PlatformCALayerRemote::create):
     38        (PlatformCALayerRemote::PlatformCALayerRemote):
     39        (PlatformCALayerRemote::clone):
     40        (PlatformCALayerRemote::recursiveBuildTransaction):
     41        (PlatformCALayerRemote::ensureBackingStore):
     42        (PlatformCALayerRemote::setNeedsDisplay):
     43        (PlatformCALayerRemote::transform):
     44        (PlatformCALayerRemote::setTransform):
     45        (PlatformCALayerRemote::sublayerTransform):
     46        (PlatformCALayerRemote::setSublayerTransform):
     47        (PlatformCALayerRemote::setFilters):
     48        (PlatformCALayerRemote::enumerateRectsBeingDrawn):
     49        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
     50
    1512014-02-19  Benjamin Poulain  <bpoulain@apple.com>
    252
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.h

    r162453 r164405  
    3535public:
    3636    typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, CALayer *> RelatedLayerMap;
    37     static void applyPropertiesToLayer(CALayer *, RemoteLayerTreeTransaction::LayerProperties, RelatedLayerMap);
     37    static void applyPropertiesToLayer(CALayer *, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
    3838};
    3939
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm

    r163959 r164405  
    8080}
    8181
    82 void RemoteLayerTreePropertyApplier::applyPropertiesToLayer(CALayer *layer, RemoteLayerTreeTransaction::LayerProperties properties, RelatedLayerMap relatedLayers)
     82void RemoteLayerTreePropertyApplier::applyPropertiesToLayer(CALayer *layer, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
    8383{
    8484    if (properties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
     
    118118
    119119    if (properties.changedProperties & RemoteLayerTreeTransaction::TransformChanged)
    120         layer.transform = properties.transform;
     120        layer.transform = properties.transform ? (CATransform3D)*properties.transform.get() : CATransform3DIdentity;
    121121
    122122    if (properties.changedProperties & RemoteLayerTreeTransaction::SublayerTransformChanged)
    123         layer.sublayerTransform = properties.sublayerTransform;
     123        layer.sublayerTransform = properties.sublayerTransform ? (CATransform3D)*properties.sublayerTransform.get() : CATransform3DIdentity;
    124124
    125125    if (properties.changedProperties & RemoteLayerTreeTransaction::HiddenChanged)
     
    169169    if (properties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged) {
    170170#if USE(IOSURFACE)
    171         if (properties.backingStore.acceleratesDrawing())
    172             layer.contents = (id)properties.backingStore.surface().get();
     171        if (properties.backingStore->acceleratesDrawing())
     172            layer.contents = (id)properties.backingStore->surface().get();
    173173        else
    174174#else
    175             ASSERT(!properties.backingStore.acceleratesDrawing());
     175            ASSERT(!properties.backingStore || !properties.backingStore->acceleratesDrawing());
    176176#endif
    177         layer.contents = (id)properties.backingStore.image().get();
     177        layer.contents = properties.backingStore ? (id)properties.backingStore->image().get() : nil;
    178178    }
    179179
    180180    if (properties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
    181         PlatformCAFilters::setFiltersOnLayer(layer, properties.filters);
     181        PlatformCAFilters::setFiltersOnLayer(layer, properties.filters ? *properties.filters : FilterOperations());
    182182
    183183    if (properties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h

    r163666 r164405  
    9393    struct LayerProperties {
    9494        LayerProperties();
     95        LayerProperties(const LayerProperties& other);
    9596
    9697        void encode(IPC::ArgumentEncoder&) const;
     
    107108
    108109        String name;
     110        std::unique_ptr<WebCore::TransformationMatrix> transform;
     111        std::unique_ptr<WebCore::TransformationMatrix> sublayerTransform;
    109112        Vector<WebCore::GraphicsLayer::PlatformLayerID> children;
    110113        WebCore::FloatPoint3D position;
     114        WebCore::FloatPoint3D anchorPoint;
    111115        WebCore::FloatSize size;
     116        WebCore::FloatRect contentsRect;
     117        std::unique_ptr<RemoteLayerBackingStore> backingStore;
     118        std::unique_ptr<WebCore::FilterOperations> filters;
     119        WebCore::GraphicsLayer::PlatformLayerID maskLayerID;
     120        double timeOffset;
     121        float speed;
     122        float contentsScale;
     123        float borderWidth;
     124        float opacity;
    112125        WebCore::Color backgroundColor;
    113         WebCore::FloatPoint3D anchorPoint;
    114         float borderWidth;
    115126        WebCore::Color borderColor;
    116         float opacity;
    117         WebCore::TransformationMatrix transform;
    118         WebCore::TransformationMatrix sublayerTransform;
     127        unsigned edgeAntialiasingMask;
     128        WebCore::GraphicsLayer::CustomAppearance customAppearance;
     129        WebCore::PlatformCALayer::FilterType minificationFilter;
     130        WebCore::PlatformCALayer::FilterType magnificationFilter;
    119131        bool hidden;
    120132        bool geometryFlipped;
     
    122134        bool masksToBounds;
    123135        bool opaque;
    124         WebCore::GraphicsLayer::PlatformLayerID maskLayerID;
    125         WebCore::FloatRect contentsRect;
    126         float contentsScale;
    127         WebCore::PlatformCALayer::FilterType minificationFilter;
    128         WebCore::PlatformCALayer::FilterType magnificationFilter;
    129         float speed;
    130         double timeOffset;
    131         RemoteLayerBackingStore backingStore;
    132         WebCore::FilterOperations filters;
    133         unsigned edgeAntialiasingMask;
    134         WebCore::GraphicsLayer::CustomAppearance customAppearance;
    135136    };
    136137
     
    152153#endif
    153154
     155    typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, std::unique_ptr<LayerProperties>> LayerPropertiesMap;
     156   
    154157    Vector<LayerCreationProperties> createdLayers() const { return m_createdLayers; }
    155     HashMap<WebCore::GraphicsLayer::PlatformLayerID, LayerProperties> changedLayers() const { return m_changedLayerProperties; }
     158    const LayerPropertiesMap& changedLayers() const { return m_changedLayerProperties; }
     159    LayerPropertiesMap& changedLayers() { return m_changedLayerProperties; }
    156160    Vector<WebCore::GraphicsLayer::PlatformLayerID> destroyedLayers() const { return m_destroyedLayerIDs; }
    157161
     
    176180private:
    177181    WebCore::GraphicsLayer::PlatformLayerID m_rootLayerID;
    178     HashMap<WebCore::GraphicsLayer::PlatformLayerID, LayerProperties> m_changedLayerProperties;
     182    LayerPropertiesMap m_changedLayerProperties;
    179183    Vector<LayerCreationProperties> m_createdLayers;
    180184    Vector<WebCore::GraphicsLayer::PlatformLayerID> m_destroyedLayerIDs;
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

    r163666 r164405  
    7373    : changedProperties(NoChange)
    7474    , everChangedProperties(NoChange)
     75    , anchorPoint(0.5, 0.5, 0)
     76    , contentsRect(FloatPoint(), FloatSize(1, 1))
     77    , maskLayerID(0)
     78    , timeOffset(0)
     79    , speed(1)
     80    , contentsScale(1)
     81    , borderWidth(0)
     82    , opacity(1)
    7583    , backgroundColor(Color::transparent)
    76     , anchorPoint(0.5, 0.5, 0)
    77     , borderWidth(0)
    7884    , borderColor(Color::black)
    79     , opacity(1)
     85    , edgeAntialiasingMask(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge)
     86    , customAppearance(GraphicsLayer::NoCustomAppearance)
     87    , minificationFilter(PlatformCALayer::FilterType::Linear)
     88    , magnificationFilter(PlatformCALayer::FilterType::Linear)
    8089    , hidden(false)
    8190    , geometryFlipped(false)
     
    8392    , masksToBounds(false)
    8493    , opaque(false)
    85     , maskLayerID(0)
    86     , contentsRect(FloatPoint(), FloatSize(1, 1))
    87     , contentsScale(1)
    88     , minificationFilter(PlatformCALayer::FilterType::Linear)
    89     , magnificationFilter(PlatformCALayer::FilterType::Linear)
    90     , speed(1)
    91     , timeOffset(0)
    92     , edgeAntialiasingMask(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge)
    93     , customAppearance(GraphicsLayer::NoCustomAppearance)
    94 {
     94{
     95}
     96
     97RemoteLayerTreeTransaction::LayerProperties::LayerProperties(const LayerProperties& other)
     98    : changedProperties(other.changedProperties)
     99    , everChangedProperties(other.everChangedProperties)
     100    , name(other.name)
     101    , children(other.children)
     102    , position(other.position)
     103    , anchorPoint(other.anchorPoint)
     104    , size(other.size)
     105    , contentsRect(other.contentsRect)
     106    , maskLayerID(other.maskLayerID)
     107    , timeOffset(other.timeOffset)
     108    , speed(other.speed)
     109    , contentsScale(other.contentsScale)
     110    , borderWidth(other.borderWidth)
     111    , opacity(other.opacity)
     112    , backgroundColor(other.backgroundColor)
     113    , borderColor(other.borderColor)
     114    , edgeAntialiasingMask(other.edgeAntialiasingMask)
     115    , customAppearance(other.customAppearance)
     116    , minificationFilter(other.minificationFilter)
     117    , magnificationFilter(other.magnificationFilter)
     118    , hidden(other.hidden)
     119    , geometryFlipped(other.geometryFlipped)
     120    , doubleSided(other.doubleSided)
     121    , masksToBounds(other.masksToBounds)
     122    , opaque(other.opaque)
     123{
     124    if (other.transform)
     125        transform = std::make_unique<TransformationMatrix>(*other.transform);
     126
     127    if (other.sublayerTransform)
     128        sublayerTransform = std::make_unique<TransformationMatrix>(*other.sublayerTransform);
     129   
     130    if (other.backingStore)
     131        backingStore = std::make_unique<RemoteLayerBackingStore>(*other.backingStore);
     132
     133    if (other.filters)
     134        filters = std::make_unique<FilterOperations>(*other.filters);
    95135}
    96136
     
    127167
    128168    if (changedProperties & TransformChanged)
    129         encoder << transform;
     169        encoder << *transform;
    130170
    131171    if (changedProperties & SublayerTransformChanged)
    132         encoder << sublayerTransform;
     172        encoder << *sublayerTransform;
    133173
    134174    if (changedProperties & HiddenChanged)
     
    169209
    170210    if (changedProperties & BackingStoreChanged) {
    171         encoder << backingStore.hasFrontBuffer();
    172         if (backingStore.hasFrontBuffer())
    173             encoder << backingStore;
     211        encoder << backingStore->hasFrontBuffer();
     212        if (backingStore->hasFrontBuffer())
     213            encoder << *backingStore;
    174214    }
    175215
    176216    if (changedProperties & FiltersChanged)
    177         encoder << filters;
     217        encoder << *filters;
    178218
    179219    if (changedProperties & EdgeAntialiasingMaskChanged)
     
    240280
    241281    if (result.changedProperties & TransformChanged) {
    242         if (!decoder.decode(result.transform))
    243             return false;
     282        TransformationMatrix transform;
     283        if (!decoder.decode(transform))
     284            return false;
     285       
     286        result.transform = std::make_unique<TransformationMatrix>(transform);
    244287    }
    245288
    246289    if (result.changedProperties & SublayerTransformChanged) {
    247         if (!decoder.decode(result.sublayerTransform))
    248             return false;
     290        TransformationMatrix transform;
     291        if (!decoder.decode(transform))
     292            return false;
     293
     294        result.sublayerTransform = std::make_unique<TransformationMatrix>(transform);
    249295    }
    250296
     
    313359        if (!decoder.decode(hasFrontBuffer))
    314360            return false;
    315         if (hasFrontBuffer && !decoder.decode(result.backingStore))
    316             return false;
     361        if (hasFrontBuffer) {
     362            RemoteLayerBackingStore backingStore;
     363            if (!decoder.decode(backingStore))
     364                return false;
     365           
     366            result.backingStore = std::make_unique<RemoteLayerBackingStore>(backingStore);
     367        }
    317368    }
    318369
    319370    if (result.changedProperties & FiltersChanged) {
    320         if (!decoder.decode(result.filters))
    321             return false;
     371        std::unique_ptr<FilterOperations> filters = std::make_unique<FilterOperations>();
     372        if (!decoder.decode(*filters))
     373            return false;
     374        result.filters = std::move(filters);
    322375    }
    323376
     
    347400    encoder << m_rootLayerID;
    348401    encoder << m_createdLayers;
    349     encoder << m_changedLayerProperties;
     402
     403    encoder << m_changedLayerProperties.size();
     404
     405    for (const auto& layerProperties : m_changedLayerProperties) {
     406        encoder << layerProperties.key;
     407        encoder << *layerProperties.value;
     408    }
     409   
    350410    encoder << m_destroyedLayerIDs;
    351411    encoder << m_contentsSize;
     
    367427        return false;
    368428
    369     if (!decoder.decode(result.m_changedLayerProperties))
    370         return false;
     429    int numChangedLayerProperties;
     430    if (!decoder.decode(numChangedLayerProperties))
     431        return false;
     432
     433    for (int i = 0; i < numChangedLayerProperties; ++i) {
     434        GraphicsLayer::PlatformLayerID layerID;
     435        if (!decoder.decode(layerID))
     436            return false;
     437
     438        std::unique_ptr<LayerProperties> layerProperties = std::make_unique<LayerProperties>();
     439        if (!decoder.decode(*layerProperties))
     440            return false;
     441
     442        result.changedLayers().set(layerID, std::move(layerProperties));
     443    }
    371444
    372445    if (!decoder.decode(result.m_destroyedLayerIDs))
     
    408481void RemoteLayerTreeTransaction::layerPropertiesChanged(PlatformCALayerRemote* remoteLayer, RemoteLayerTreeTransaction::LayerProperties& properties)
    409482{
    410     m_changedLayerProperties.set(remoteLayer->layerID(), properties);
     483    m_changedLayerProperties.set(remoteLayer->layerID(), std::make_unique<RemoteLayerTreeTransaction::LayerProperties>(properties));
    411484}
    412485
     
    591664}
    592665
    593 static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const HashMap<GraphicsLayer::PlatformLayerID, RemoteLayerTreeTransaction::LayerProperties>& changedLayerProperties)
     666static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const RemoteLayerTreeTransaction::LayerPropertiesMap& changedLayerProperties)
    594667{
    595668    if (changedLayerProperties.isEmpty())
     
    606679
    607680    for (auto layerID : layerIDs) {
    608         const RemoteLayerTreeTransaction::LayerProperties& layerProperties = changedLayerProperties.get(layerID);
     681        const RemoteLayerTreeTransaction::LayerProperties& layerProperties = *changedLayerProperties.get(layerID);
    609682
    610683        ts << "\n";
     
    641714
    642715        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TransformChanged)
    643             dumpProperty<TransformationMatrix>(ts, "transform", layerProperties.transform);
     716            dumpProperty<TransformationMatrix>(ts, "transform", layerProperties.transform ? *layerProperties.transform : TransformationMatrix());
    644717
    645718        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SublayerTransformChanged)
    646             dumpProperty<TransformationMatrix>(ts, "sublayerTransform", layerProperties.sublayerTransform);
     719            dumpProperty<TransformationMatrix>(ts, "sublayerTransform", layerProperties.sublayerTransform ? *layerProperties.sublayerTransform : TransformationMatrix());
    647720
    648721        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::HiddenChanged)
     
    683756
    684757        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged)
    685             dumpProperty<IntSize>(ts, "backingStore", layerProperties.backingStore.size());
     758            dumpProperty<IntSize>(ts, "backingStore", layerProperties.backingStore ? layerProperties.backingStore->size() : IntSize());
    686759
    687760        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
    688             dumpProperty<FilterOperations>(ts, "filters", layerProperties.filters);
     761            dumpProperty<FilterOperations>(ts, "filters", layerProperties.filters ? *layerProperties.filters : FilterOperations());
    689762
    690763        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h

    r163837 r164405  
    5353
    5454private:
    55     CALayer *createLayer(RemoteLayerTreeTransaction::LayerCreationProperties);
     55    CALayer *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&);
    5656
    5757    CALayer *m_rootLayer;
  • trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm

    r163959 r164405  
    6969    for (auto& changedLayer : transaction.changedLayers()) {
    7070        auto layerID = changedLayer.key;
    71         const auto& properties = changedLayer.value;
     71        const RemoteLayerTreeTransaction::LayerProperties& properties = *changedLayer.value;
    7272
    7373        CALayer *layer = getLayer(layerID);
     
    108108}
    109109
    110 CALayer *RemoteLayerTreeHost::createLayer(RemoteLayerTreeTransaction::LayerCreationProperties properties)
     110CALayer *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties)
    111111{
    112112    RetainPtr<CALayer>& layer = m_layers.add(properties.layerID, nullptr).iterator->value;
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

    r163959 r164405  
    6868}
    6969
     70PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(const PlatformCALayerRemote& other, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
     71{
     72    RefPtr<PlatformCALayerRemote> layer = adoptRef(new PlatformCALayerRemote(other, owner, context));
     73
     74    context->layerWasCreated(layer.get(), LayerTypeCustom);
     75
     76    return layer.release();
     77}
     78
    7079PlatformCALayerRemote::PlatformCALayerRemote(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
    7180    : PlatformCALayer(layerType, owner)
     
    7786}
    7887
     88PlatformCALayerRemote::PlatformCALayerRemote(const PlatformCALayerRemote& other, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
     89    : PlatformCALayer(other.layerType(), owner)
     90    , m_properties(other.m_properties)
     91    , m_superlayer(nullptr)
     92    , m_maskLayer(nullptr)
     93    , m_acceleratesDrawing(other.acceleratesDrawing())
     94    , m_context(context)
     95{
     96}
     97
    7998PassRefPtr<PlatformCALayer> PlatformCALayerRemote::clone(PlatformCALayerClient* client) const
    8099{
    81     RefPtr<PlatformCALayerRemote> clone = PlatformCALayerRemote::create(layerType(), client, m_context);
    82 
    83     clone->m_properties = m_properties;
     100    RefPtr<PlatformCALayerRemote> clone = PlatformCALayerRemote::create(*this, client, m_context);
     101
    84102    clone->m_properties.notePropertiesChanged(static_cast<RemoteLayerTreeTransaction::LayerChange>(m_properties.everChangedProperties & ~RemoteLayerTreeTransaction::BackingStoreChanged));
    85103
     
    96114void PlatformCALayerRemote::recursiveBuildTransaction(RemoteLayerTreeTransaction& transaction)
    97115{
    98     if (m_properties.backingStore.display())
     116    if (m_properties.backingStore && m_properties.backingStore->display())
    99117        m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreChanged);
    100118
     
    132150void PlatformCALayerRemote::ensureBackingStore()
    133151{
    134     m_properties.backingStore.ensureBackingStore(this, expandedIntSize(m_properties.size), m_properties.contentsScale, m_acceleratesDrawing);
     152    if (!m_properties.backingStore)
     153        m_properties.backingStore = std::make_unique<RemoteLayerBackingStore>();
     154    m_properties.backingStore->ensureBackingStore(this, expandedIntSize(m_properties.size), m_properties.contentsScale, m_acceleratesDrawing);
    135155}
    136156
     
    140160
    141161    if (!rect) {
    142         m_properties.backingStore.setNeedsDisplay();
     162        m_properties.backingStore->setNeedsDisplay();
    143163        return;
    144164    }
    145165
    146166    // FIXME: Need to map this through contentsRect/etc.
    147     m_properties.backingStore.setNeedsDisplay(enclosingIntRect(*rect));
     167    m_properties.backingStore->setNeedsDisplay(enclosingIntRect(*rect));
    148168}
    149169
     
    318338TransformationMatrix PlatformCALayerRemote::transform() const
    319339{
    320     return m_properties.transform;
     340    return m_properties.transform ? *m_properties.transform : TransformationMatrix();
    321341}
    322342
    323343void PlatformCALayerRemote::setTransform(const TransformationMatrix& value)
    324344{
    325     m_properties.transform = value;
     345    m_properties.transform = std::make_unique<TransformationMatrix>(value);
    326346    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::TransformChanged);
    327347}
     
    329349TransformationMatrix PlatformCALayerRemote::sublayerTransform() const
    330350{
    331     return m_properties.sublayerTransform;
     351    return m_properties.sublayerTransform ? *m_properties.sublayerTransform : TransformationMatrix();
    332352}
    333353
    334354void PlatformCALayerRemote::setSublayerTransform(const TransformationMatrix& value)
    335355{
    336     m_properties.sublayerTransform = value;
     356    m_properties.sublayerTransform = std::make_unique<TransformationMatrix>(value);
    337357    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::SublayerTransformChanged);
    338358}
     
    447467void PlatformCALayerRemote::setFilters(const FilterOperations& filters)
    448468{
    449     m_properties.filters = filters;
     469    m_properties.filters = std::make_unique<FilterOperations>(filters);
    450470    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::FiltersChanged);
    451471}
     
    522542void PlatformCALayerRemote::enumerateRectsBeingDrawn(CGContextRef context, void (^block)(CGRect))
    523543{
    524     m_properties.backingStore.enumerateRectsBeingDrawn(context, block);
     544    m_properties.backingStore->enumerateRectsBeingDrawn(context, block);
    525545}
    526546
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

    r163079 r164405  
    4040    static PassRefPtr<PlatformCALayerRemote> create(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
    4141    static PassRefPtr<PlatformCALayerRemote> create(PlatformLayer *, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
     42    static PassRefPtr<PlatformCALayerRemote> create(const PlatformCALayerRemote&, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
    4243
    4344    virtual ~PlatformCALayerRemote();
     
    150151protected:
    151152    PlatformCALayerRemote(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext* context);
     153    PlatformCALayerRemote(const PlatformCALayerRemote&, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
    152154
    153155private:
Note: See TracChangeset for help on using the changeset viewer.