Title: [164405] trunk/Source/WebKit2
Revision
164405
Author
[email protected]
Date
2014-02-19 18:03:37 -0800 (Wed, 19 Feb 2014)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (164404 => 164405)


--- trunk/Source/WebKit2/ChangeLog	2014-02-20 01:16:56 UTC (rev 164404)
+++ trunk/Source/WebKit2/ChangeLog	2014-02-20 02:03:37 UTC (rev 164405)
@@ -1,3 +1,53 @@
+2014-02-19  Simon Fraser  <[email protected]>
+
+        [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:
+
 2014-02-19  Benjamin Poulain  <[email protected]>
 
         Remove -[WKContentView setViewportSize:]

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.h (164404 => 164405)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.h	2014-02-20 01:16:56 UTC (rev 164404)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.h	2014-02-20 02:03:37 UTC (rev 164405)
@@ -34,7 +34,7 @@
 class RemoteLayerTreePropertyApplier {
 public:
     typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, CALayer *> RelatedLayerMap;
-    static void applyPropertiesToLayer(CALayer *, RemoteLayerTreeTransaction::LayerProperties, RelatedLayerMap);
+    static void applyPropertiesToLayer(CALayer *, const RemoteLayerTreeTransaction::LayerProperties&, const RelatedLayerMap&);
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm (164404 => 164405)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm	2014-02-20 01:16:56 UTC (rev 164404)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm	2014-02-20 02:03:37 UTC (rev 164405)
@@ -79,7 +79,7 @@
 #endif
 }
 
-void RemoteLayerTreePropertyApplier::applyPropertiesToLayer(CALayer *layer, RemoteLayerTreeTransaction::LayerProperties properties, RelatedLayerMap relatedLayers)
+void RemoteLayerTreePropertyApplier::applyPropertiesToLayer(CALayer *layer, const RemoteLayerTreeTransaction::LayerProperties& properties, const RelatedLayerMap& relatedLayers)
 {
     if (properties.changedProperties & RemoteLayerTreeTransaction::NameChanged)
         layer.name = properties.name;
@@ -117,10 +117,10 @@
         layer.opacity = properties.opacity;
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::TransformChanged)
-        layer.transform = properties.transform;
+        layer.transform = properties.transform ? (CATransform3D)*properties.transform.get() : CATransform3DIdentity;
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::SublayerTransformChanged)
-        layer.sublayerTransform = properties.sublayerTransform;
+        layer.sublayerTransform = properties.sublayerTransform ? (CATransform3D)*properties.sublayerTransform.get() : CATransform3DIdentity;
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::HiddenChanged)
         layer.hidden = properties.hidden;
@@ -168,17 +168,17 @@
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged) {
 #if USE(IOSURFACE)
-        if (properties.backingStore.acceleratesDrawing())
-            layer.contents = (id)properties.backingStore.surface().get();
+        if (properties.backingStore->acceleratesDrawing())
+            layer.contents = (id)properties.backingStore->surface().get();
         else
 #else
-            ASSERT(!properties.backingStore.acceleratesDrawing());
+            ASSERT(!properties.backingStore || !properties.backingStore->acceleratesDrawing());
 #endif
-        layer.contents = (id)properties.backingStore.image().get();
+        layer.contents = properties.backingStore ? (id)properties.backingStore->image().get() : nil;
     }
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
-        PlatformCAFilters::setFiltersOnLayer(layer, properties.filters);
+        PlatformCAFilters::setFiltersOnLayer(layer, properties.filters ? *properties.filters : FilterOperations());
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
         layer.edgeAntialiasingMask = properties.edgeAntialiasingMask;

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h (164404 => 164405)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h	2014-02-20 01:16:56 UTC (rev 164404)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h	2014-02-20 02:03:37 UTC (rev 164405)
@@ -92,6 +92,7 @@
 
     struct LayerProperties {
         LayerProperties();
+        LayerProperties(const LayerProperties& other);
 
         void encode(IPC::ArgumentEncoder&) const;
         static bool decode(IPC::ArgumentDecoder&, LayerProperties&);
@@ -106,32 +107,32 @@
         LayerChange everChangedProperties;
 
         String name;
+        std::unique_ptr<WebCore::TransformationMatrix> transform;
+        std::unique_ptr<WebCore::TransformationMatrix> sublayerTransform;
         Vector<WebCore::GraphicsLayer::PlatformLayerID> children;
         WebCore::FloatPoint3D position;
+        WebCore::FloatPoint3D anchorPoint;
         WebCore::FloatSize size;
+        WebCore::FloatRect contentsRect;
+        std::unique_ptr<RemoteLayerBackingStore> backingStore;
+        std::unique_ptr<WebCore::FilterOperations> filters;
+        WebCore::GraphicsLayer::PlatformLayerID maskLayerID;
+        double timeOffset;
+        float speed;
+        float contentsScale;
+        float borderWidth;
+        float opacity;
         WebCore::Color backgroundColor;
-        WebCore::FloatPoint3D anchorPoint;
-        float borderWidth;
         WebCore::Color borderColor;
-        float opacity;
-        WebCore::TransformationMatrix transform;
-        WebCore::TransformationMatrix sublayerTransform;
+        unsigned edgeAntialiasingMask;
+        WebCore::GraphicsLayer::CustomAppearance customAppearance;
+        WebCore::PlatformCALayer::FilterType minificationFilter;
+        WebCore::PlatformCALayer::FilterType magnificationFilter;
         bool hidden;
         bool geometryFlipped;
         bool doubleSided;
         bool masksToBounds;
         bool opaque;
-        WebCore::GraphicsLayer::PlatformLayerID maskLayerID;
-        WebCore::FloatRect contentsRect;
-        float contentsScale;
-        WebCore::PlatformCALayer::FilterType minificationFilter;
-        WebCore::PlatformCALayer::FilterType magnificationFilter;
-        float speed;
-        double timeOffset;
-        RemoteLayerBackingStore backingStore;
-        WebCore::FilterOperations filters;
-        unsigned edgeAntialiasingMask;
-        WebCore::GraphicsLayer::CustomAppearance customAppearance;
     };
 
     explicit RemoteLayerTreeTransaction();
@@ -151,8 +152,11 @@
     void dump() const;
 #endif
 
+    typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, std::unique_ptr<LayerProperties>> LayerPropertiesMap;
+    
     Vector<LayerCreationProperties> createdLayers() const { return m_createdLayers; }
-    HashMap<WebCore::GraphicsLayer::PlatformLayerID, LayerProperties> changedLayers() const { return m_changedLayerProperties; }
+    const LayerPropertiesMap& changedLayers() const { return m_changedLayerProperties; }
+    LayerPropertiesMap& changedLayers() { return m_changedLayerProperties; }
     Vector<WebCore::GraphicsLayer::PlatformLayerID> destroyedLayers() const { return m_destroyedLayerIDs; }
 
     WebCore::IntSize contentsSize() const { return m_contentsSize; }
@@ -175,7 +179,7 @@
 
 private:
     WebCore::GraphicsLayer::PlatformLayerID m_rootLayerID;
-    HashMap<WebCore::GraphicsLayer::PlatformLayerID, LayerProperties> m_changedLayerProperties;
+    LayerPropertiesMap m_changedLayerProperties;
     Vector<LayerCreationProperties> m_createdLayers;
     Vector<WebCore::GraphicsLayer::PlatformLayerID> m_destroyedLayerIDs;
     WebCore::IntSize m_contentsSize;

Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm (164404 => 164405)


--- trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm	2014-02-20 01:16:56 UTC (rev 164404)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm	2014-02-20 02:03:37 UTC (rev 164405)
@@ -72,28 +72,68 @@
 RemoteLayerTreeTransaction::LayerProperties::LayerProperties()
     : changedProperties(NoChange)
     , everChangedProperties(NoChange)
-    , backgroundColor(Color::transparent)
     , anchorPoint(0.5, 0.5, 0)
+    , contentsRect(FloatPoint(), FloatSize(1, 1))
+    , maskLayerID(0)
+    , timeOffset(0)
+    , speed(1)
+    , contentsScale(1)
     , borderWidth(0)
+    , opacity(1)
+    , backgroundColor(Color::transparent)
     , borderColor(Color::black)
-    , opacity(1)
+    , edgeAntialiasingMask(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge)
+    , customAppearance(GraphicsLayer::NoCustomAppearance)
+    , minificationFilter(PlatformCALayer::FilterType::Linear)
+    , magnificationFilter(PlatformCALayer::FilterType::Linear)
     , hidden(false)
     , geometryFlipped(false)
     , doubleSided(true)
     , masksToBounds(false)
     , opaque(false)
-    , maskLayerID(0)
-    , contentsRect(FloatPoint(), FloatSize(1, 1))
-    , contentsScale(1)
-    , minificationFilter(PlatformCALayer::FilterType::Linear)
-    , magnificationFilter(PlatformCALayer::FilterType::Linear)
-    , speed(1)
-    , timeOffset(0)
-    , edgeAntialiasingMask(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge)
-    , customAppearance(GraphicsLayer::NoCustomAppearance)
 {
 }
 
+RemoteLayerTreeTransaction::LayerProperties::LayerProperties(const LayerProperties& other)
+    : changedProperties(other.changedProperties)
+    , everChangedProperties(other.everChangedProperties)
+    , name(other.name)
+    , children(other.children)
+    , position(other.position)
+    , anchorPoint(other.anchorPoint)
+    , size(other.size)
+    , contentsRect(other.contentsRect)
+    , maskLayerID(other.maskLayerID)
+    , timeOffset(other.timeOffset)
+    , speed(other.speed)
+    , contentsScale(other.contentsScale)
+    , borderWidth(other.borderWidth)
+    , opacity(other.opacity)
+    , backgroundColor(other.backgroundColor)
+    , borderColor(other.borderColor)
+    , edgeAntialiasingMask(other.edgeAntialiasingMask)
+    , customAppearance(other.customAppearance)
+    , minificationFilter(other.minificationFilter)
+    , magnificationFilter(other.magnificationFilter)
+    , hidden(other.hidden)
+    , geometryFlipped(other.geometryFlipped)
+    , doubleSided(other.doubleSided)
+    , masksToBounds(other.masksToBounds)
+    , opaque(other.opaque)
+{
+    if (other.transform)
+        transform = std::make_unique<TransformationMatrix>(*other.transform);
+
+    if (other.sublayerTransform)
+        sublayerTransform = std::make_unique<TransformationMatrix>(*other.sublayerTransform);
+    
+    if (other.backingStore)
+        backingStore = std::make_unique<RemoteLayerBackingStore>(*other.backingStore);
+
+    if (other.filters)
+        filters = std::make_unique<FilterOperations>(*other.filters);
+}
+
 void RemoteLayerTreeTransaction::LayerProperties::encode(IPC::ArgumentEncoder& encoder) const
 {
     encoder.encodeEnum(changedProperties);
@@ -126,10 +166,10 @@
         encoder << opacity;
 
     if (changedProperties & TransformChanged)
-        encoder << transform;
+        encoder << *transform;
 
     if (changedProperties & SublayerTransformChanged)
-        encoder << sublayerTransform;
+        encoder << *sublayerTransform;
 
     if (changedProperties & HiddenChanged)
         encoder << hidden;
@@ -168,13 +208,13 @@
         encoder << timeOffset;
 
     if (changedProperties & BackingStoreChanged) {
-        encoder << backingStore.hasFrontBuffer();
-        if (backingStore.hasFrontBuffer())
-            encoder << backingStore;
+        encoder << backingStore->hasFrontBuffer();
+        if (backingStore->hasFrontBuffer())
+            encoder << *backingStore;
     }
 
     if (changedProperties & FiltersChanged)
-        encoder << filters;
+        encoder << *filters;
 
     if (changedProperties & EdgeAntialiasingMaskChanged)
         encoder << edgeAntialiasingMask;
@@ -239,13 +279,19 @@
     }
 
     if (result.changedProperties & TransformChanged) {
-        if (!decoder.decode(result.transform))
+        TransformationMatrix transform;
+        if (!decoder.decode(transform))
             return false;
+        
+        result.transform = std::make_unique<TransformationMatrix>(transform);
     }
 
     if (result.changedProperties & SublayerTransformChanged) {
-        if (!decoder.decode(result.sublayerTransform))
+        TransformationMatrix transform;
+        if (!decoder.decode(transform))
             return false;
+
+        result.sublayerTransform = std::make_unique<TransformationMatrix>(transform);
     }
 
     if (result.changedProperties & HiddenChanged) {
@@ -312,13 +358,20 @@
         bool hasFrontBuffer = false;
         if (!decoder.decode(hasFrontBuffer))
             return false;
-        if (hasFrontBuffer && !decoder.decode(result.backingStore))
-            return false;
+        if (hasFrontBuffer) {
+            RemoteLayerBackingStore backingStore;
+            if (!decoder.decode(backingStore))
+                return false;
+            
+            result.backingStore = std::make_unique<RemoteLayerBackingStore>(backingStore);
+        }
     }
 
     if (result.changedProperties & FiltersChanged) {
-        if (!decoder.decode(result.filters))
+        std::unique_ptr<FilterOperations> filters = std::make_unique<FilterOperations>();
+        if (!decoder.decode(*filters))
             return false;
+        result.filters = std::move(filters);
     }
 
     if (result.changedProperties & EdgeAntialiasingMaskChanged) {
@@ -346,7 +399,14 @@
 {
     encoder << m_rootLayerID;
     encoder << m_createdLayers;
-    encoder << m_changedLayerProperties;
+
+    encoder << m_changedLayerProperties.size();
+
+    for (const auto& layerProperties : m_changedLayerProperties) {
+        encoder << layerProperties.key;
+        encoder << *layerProperties.value;
+    }
+    
     encoder << m_destroyedLayerIDs;
     encoder << m_contentsSize;
     encoder << m_pageScaleFactor;
@@ -366,9 +426,22 @@
     if (!decoder.decode(result.m_createdLayers))
         return false;
 
-    if (!decoder.decode(result.m_changedLayerProperties))
+    int numChangedLayerProperties;
+    if (!decoder.decode(numChangedLayerProperties))
         return false;
 
+    for (int i = 0; i < numChangedLayerProperties; ++i) {
+        GraphicsLayer::PlatformLayerID layerID;
+        if (!decoder.decode(layerID))
+            return false;
+
+        std::unique_ptr<LayerProperties> layerProperties = std::make_unique<LayerProperties>();
+        if (!decoder.decode(*layerProperties))
+            return false;
+
+        result.changedLayers().set(layerID, std::move(layerProperties));
+    }
+
     if (!decoder.decode(result.m_destroyedLayerIDs))
         return false;
 
@@ -407,7 +480,7 @@
 
 void RemoteLayerTreeTransaction::layerPropertiesChanged(PlatformCALayerRemote* remoteLayer, RemoteLayerTreeTransaction::LayerProperties& properties)
 {
-    m_changedLayerProperties.set(remoteLayer->layerID(), properties);
+    m_changedLayerProperties.set(remoteLayer->layerID(), std::make_unique<RemoteLayerTreeTransaction::LayerProperties>(properties));
 }
 
 void RemoteLayerTreeTransaction::setCreatedLayers(Vector<LayerCreationProperties> createdLayers)
@@ -590,7 +663,7 @@
     ts.decreaseIndent();
 }
 
-static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const HashMap<GraphicsLayer::PlatformLayerID, RemoteLayerTreeTransaction::LayerProperties>& changedLayerProperties)
+static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const RemoteLayerTreeTransaction::LayerPropertiesMap& changedLayerProperties)
 {
     if (changedLayerProperties.isEmpty())
         return;
@@ -605,7 +678,7 @@
     std::sort(layerIDs.begin(), layerIDs.end());
 
     for (auto layerID : layerIDs) {
-        const RemoteLayerTreeTransaction::LayerProperties& layerProperties = changedLayerProperties.get(layerID);
+        const RemoteLayerTreeTransaction::LayerProperties& layerProperties = *changedLayerProperties.get(layerID);
 
         ts << "\n";
         ts.increaseIndent();
@@ -640,10 +713,10 @@
             dumpProperty<float>(ts, "opacity", layerProperties.opacity);
 
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::TransformChanged)
-            dumpProperty<TransformationMatrix>(ts, "transform", layerProperties.transform);
+            dumpProperty<TransformationMatrix>(ts, "transform", layerProperties.transform ? *layerProperties.transform : TransformationMatrix());
 
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::SublayerTransformChanged)
-            dumpProperty<TransformationMatrix>(ts, "sublayerTransform", layerProperties.sublayerTransform);
+            dumpProperty<TransformationMatrix>(ts, "sublayerTransform", layerProperties.sublayerTransform ? *layerProperties.sublayerTransform : TransformationMatrix());
 
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::HiddenChanged)
             dumpProperty<bool>(ts, "hidden", layerProperties.hidden);
@@ -682,10 +755,10 @@
             dumpProperty<double>(ts, "timeOffset", layerProperties.timeOffset);
 
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::BackingStoreChanged)
-            dumpProperty<IntSize>(ts, "backingStore", layerProperties.backingStore.size());
+            dumpProperty<IntSize>(ts, "backingStore", layerProperties.backingStore ? layerProperties.backingStore->size() : IntSize());
 
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::FiltersChanged)
-            dumpProperty<FilterOperations>(ts, "filters", layerProperties.filters);
+            dumpProperty<FilterOperations>(ts, "filters", layerProperties.filters ? *layerProperties.filters : FilterOperations());
 
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
             dumpProperty<unsigned>(ts, "edgeAntialiasingMask", layerProperties.edgeAntialiasingMask);

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h (164404 => 164405)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h	2014-02-20 01:16:56 UTC (rev 164404)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h	2014-02-20 02:03:37 UTC (rev 164405)
@@ -52,7 +52,7 @@
     bool isDebugLayerTreeHost() const { return m_isDebugLayerTreeHost; }
 
 private:
-    CALayer *createLayer(RemoteLayerTreeTransaction::LayerCreationProperties);
+    CALayer *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&);
 
     CALayer *m_rootLayer;
     HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<CALayer>> m_layers;

Modified: trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm (164404 => 164405)


--- trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm	2014-02-20 01:16:56 UTC (rev 164404)
+++ trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm	2014-02-20 02:03:37 UTC (rev 164405)
@@ -68,7 +68,7 @@
 
     for (auto& changedLayer : transaction.changedLayers()) {
         auto layerID = changedLayer.key;
-        const auto& properties = changedLayer.value;
+        const RemoteLayerTreeTransaction::LayerProperties& properties = *changedLayer.value;
 
         CALayer *layer = getLayer(layerID);
         ASSERT(layer);
@@ -107,7 +107,7 @@
     return m_layers.get(layerID).get();
 }
 
-CALayer *RemoteLayerTreeHost::createLayer(RemoteLayerTreeTransaction::LayerCreationProperties properties)
+CALayer *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties)
 {
     RetainPtr<CALayer>& layer = m_layers.add(properties.layerID, nullptr).iterator->value;
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp (164404 => 164405)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp	2014-02-20 01:16:56 UTC (rev 164404)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp	2014-02-20 02:03:37 UTC (rev 164405)
@@ -67,6 +67,15 @@
     return layer.release();
 }
 
+PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(const PlatformCALayerRemote& other, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
+{
+    RefPtr<PlatformCALayerRemote> layer = adoptRef(new PlatformCALayerRemote(other, owner, context));
+
+    context->layerWasCreated(layer.get(), LayerTypeCustom);
+
+    return layer.release();
+}
+
 PlatformCALayerRemote::PlatformCALayerRemote(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
     : PlatformCALayer(layerType, owner)
     , m_superlayer(nullptr)
@@ -76,11 +85,20 @@
 {
 }
 
+PlatformCALayerRemote::PlatformCALayerRemote(const PlatformCALayerRemote& other, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
+    : PlatformCALayer(other.layerType(), owner)
+    , m_properties(other.m_properties)
+    , m_superlayer(nullptr)
+    , m_maskLayer(nullptr)
+    , m_acceleratesDrawing(other.acceleratesDrawing())
+    , m_context(context)
+{
+}
+
 PassRefPtr<PlatformCALayer> PlatformCALayerRemote::clone(PlatformCALayerClient* client) const
 {
-    RefPtr<PlatformCALayerRemote> clone = PlatformCALayerRemote::create(layerType(), client, m_context);
+    RefPtr<PlatformCALayerRemote> clone = PlatformCALayerRemote::create(*this, client, m_context);
 
-    clone->m_properties = m_properties;
     clone->m_properties.notePropertiesChanged(static_cast<RemoteLayerTreeTransaction::LayerChange>(m_properties.everChangedProperties & ~RemoteLayerTreeTransaction::BackingStoreChanged));
 
     return clone.release();
@@ -95,7 +113,7 @@
 
 void PlatformCALayerRemote::recursiveBuildTransaction(RemoteLayerTreeTransaction& transaction)
 {
-    if (m_properties.backingStore.display())
+    if (m_properties.backingStore && m_properties.backingStore->display())
         m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreChanged);
 
     if (m_properties.changedProperties != RemoteLayerTreeTransaction::NoChange) {
@@ -131,7 +149,9 @@
 
 void PlatformCALayerRemote::ensureBackingStore()
 {
-    m_properties.backingStore.ensureBackingStore(this, expandedIntSize(m_properties.size), m_properties.contentsScale, m_acceleratesDrawing);
+    if (!m_properties.backingStore)
+        m_properties.backingStore = std::make_unique<RemoteLayerBackingStore>();
+    m_properties.backingStore->ensureBackingStore(this, expandedIntSize(m_properties.size), m_properties.contentsScale, m_acceleratesDrawing);
 }
 
 void PlatformCALayerRemote::setNeedsDisplay(const FloatRect* rect)
@@ -139,12 +159,12 @@
     ensureBackingStore();
 
     if (!rect) {
-        m_properties.backingStore.setNeedsDisplay();
+        m_properties.backingStore->setNeedsDisplay();
         return;
     }
 
     // FIXME: Need to map this through contentsRect/etc.
-    m_properties.backingStore.setNeedsDisplay(enclosingIntRect(*rect));
+    m_properties.backingStore->setNeedsDisplay(enclosingIntRect(*rect));
 }
 
 void PlatformCALayerRemote::setContentsChanged()
@@ -317,23 +337,23 @@
 
 TransformationMatrix PlatformCALayerRemote::transform() const
 {
-    return m_properties.transform;
+    return m_properties.transform ? *m_properties.transform : TransformationMatrix();
 }
 
 void PlatformCALayerRemote::setTransform(const TransformationMatrix& value)
 {
-    m_properties.transform = value;
+    m_properties.transform = std::make_unique<TransformationMatrix>(value);
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::TransformChanged);
 }
 
 TransformationMatrix PlatformCALayerRemote::sublayerTransform() const
 {
-    return m_properties.sublayerTransform;
+    return m_properties.sublayerTransform ? *m_properties.sublayerTransform : TransformationMatrix();
 }
 
 void PlatformCALayerRemote::setSublayerTransform(const TransformationMatrix& value)
 {
-    m_properties.sublayerTransform = value;
+    m_properties.sublayerTransform = std::make_unique<TransformationMatrix>(value);
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::SublayerTransformChanged);
 }
 
@@ -446,7 +466,7 @@
 #if ENABLE(CSS_FILTERS)
 void PlatformCALayerRemote::setFilters(const FilterOperations& filters)
 {
-    m_properties.filters = filters;
+    m_properties.filters = std::make_unique<FilterOperations>(filters);
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::FiltersChanged);
 }
 
@@ -521,7 +541,7 @@
 
 void PlatformCALayerRemote::enumerateRectsBeingDrawn(CGContextRef context, void (^block)(CGRect))
 {
-    m_properties.backingStore.enumerateRectsBeingDrawn(context, block);
+    m_properties.backingStore->enumerateRectsBeingDrawn(context, block);
 }
 
 uint32_t PlatformCALayerRemote::hostingContextID()

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h (164404 => 164405)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h	2014-02-20 01:16:56 UTC (rev 164404)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h	2014-02-20 02:03:37 UTC (rev 164405)
@@ -39,6 +39,7 @@
 public:
     static PassRefPtr<PlatformCALayerRemote> create(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
     static PassRefPtr<PlatformCALayerRemote> create(PlatformLayer *, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
+    static PassRefPtr<PlatformCALayerRemote> create(const PlatformCALayerRemote&, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
 
     virtual ~PlatformCALayerRemote();
 
@@ -149,6 +150,7 @@
 
 protected:
     PlatformCALayerRemote(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext* context);
+    PlatformCALayerRemote(const PlatformCALayerRemote&, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
 
 private:
     virtual bool isPlatformCALayerRemote() const override { return true; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to