Add a custom behavior flag to GraphicsLayer, piped down to PlatformCALayer, for scrol...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Mar 2014 19:36:49 +0000 (19:36 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Mar 2014 19:36:49 +0000 (19:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130778

Reviewed by Tim Horton.

Make it possible to put a "custom behavior" flag on a layer so that,
with UI-side compositing, we know to create a specific type of
layer or view for that GraphicsLayer.

Source/WebCore:

* WebCore.exp.in:
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::GraphicsLayer):
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::setCustomBehavior):
(WebCore::GraphicsLayer::customBehavior):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
(WebCore::GraphicsLayerCA::updateCustomBehavior):
(WebCore::GraphicsLayerCA::setCustomBehavior):
* platform/graphics/ca/GraphicsLayerCA.h:
* platform/graphics/ca/PlatformCALayer.h:
* platform/graphics/ca/mac/PlatformCALayerMac.h:
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(PlatformCALayerMac::PlatformCALayerMac):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateScrollingLayers):

Source/WebKit2:

* Shared/mac/RemoteLayerTreeTransaction.h:
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
(WebKit::dumpChangedLayers):
* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(PlatformCALayerRemote::customBehavior):
(PlatformCALayerRemote::updateCustomBehavior):
* WebProcess/WebPage/mac/PlatformCALayerRemote.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166308 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/ca/PlatformCALayer.h
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

index 9176bd9..b368f65 100644 (file)
@@ -1,3 +1,32 @@
+2014-03-26  Simon Fraser  <simon.fraser@apple.com>
+
+        Add a custom behavior flag to GraphicsLayer, piped down to PlatformCALayer, for scrolling layers
+        https://bugs.webkit.org/show_bug.cgi?id=130778
+
+        Reviewed by Tim Horton.
+
+        Make it possible to put a "custom behavior" flag on a layer so that,
+        with UI-side compositing, we know to create a specific type of
+        layer or view for that GraphicsLayer.
+
+        * WebCore.exp.in:
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::GraphicsLayer):
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::setCustomBehavior):
+        (WebCore::GraphicsLayer::customBehavior):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
+        (WebCore::GraphicsLayerCA::updateCustomBehavior):
+        (WebCore::GraphicsLayerCA::setCustomBehavior):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * platform/graphics/ca/PlatformCALayer.h:
+        * platform/graphics/ca/mac/PlatformCALayerMac.h:
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (PlatformCALayerMac::PlatformCALayerMac):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateScrollingLayers):
+
 2014-03-26  Brent Fulgham  <bfulgham@apple.com>
 
         Unreviewed test correction.
index e644673..35f4a68 100644 (file)
@@ -545,6 +545,7 @@ __ZN7WebCore15GraphicsLayerCA16removeFromParentEv
 __ZN7WebCore15GraphicsLayerCA16resumeAnimationsEv
 __ZN7WebCore15GraphicsLayerCA16setMasksToBoundsEb
 __ZN7WebCore15GraphicsLayerCA17setContentsOpaqueEb
+__ZN7WebCore15GraphicsLayerCA17setCustomBehaviorENS_13GraphicsLayer14CustomBehaviorE
 __ZN7WebCore15GraphicsLayerCA17suspendAnimationsEd
 __ZN7WebCore15GraphicsLayerCA18setAllowTiledLayerEb
 __ZN7WebCore15GraphicsLayerCA18setBackgroundColorERKNS_5ColorE
index ff2343a..0fe88d6 100644 (file)
@@ -99,6 +99,7 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
     , m_replicatedLayer(0)
     , m_repaintCount(0)
     , m_customAppearance(NoCustomAppearance)
+    , m_customBehavior(NoCustomBehavior)
 {
 #ifndef NDEBUG
     if (m_client)
index df3ae56..5fbc986 100644 (file)
@@ -443,6 +443,10 @@ public:
     virtual void setCustomAppearance(CustomAppearance customAppearance) { m_customAppearance = customAppearance; }
     CustomAppearance customAppearance() const { return m_customAppearance; }
 
+    enum CustomBehavior { NoCustomBehavior, CustomScrollingBehavior };
+    virtual void setCustomBehavior(CustomBehavior customBehavior) { m_customBehavior = customBehavior; }
+    CustomBehavior customBehavior() const { return m_customBehavior; }
+
     // z-position is the z-equivalent of position(). It's only used for debugging purposes.
     virtual float zPosition() const { return m_zPosition; }
     virtual void setZPosition(float);
@@ -611,6 +615,7 @@ protected:
 
     int m_repaintCount;
     CustomAppearance m_customAppearance;
+    CustomBehavior m_customBehavior;
 };
 
 #define GRAPHICSLAYER_TYPE_CASTS(ToValueTypeName, predicate) \
index b2d92e1..d3a28e5 100644 (file)
@@ -1409,6 +1409,9 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers(CommitState& commitState
     if (m_uncommittedChanges & CustomAppearanceChanged)
         updateCustomAppearance();
 
+    if (m_uncommittedChanges & CustomBehaviorChanged)
+        updateCustomBehavior();
+
     if (m_uncommittedChanges & ChildrenChanged) {
         updateSublayerList();
         // Sublayers may set this flag again, so clear it to avoid always updating sublayers in commitLayerChangesAfterSublayers().
@@ -2952,6 +2955,11 @@ void GraphicsLayerCA::updateCustomAppearance()
     m_layer->updateCustomAppearance(m_customAppearance);
 }
 
+void GraphicsLayerCA::updateCustomBehavior()
+{
+    m_layer->updateCustomBehavior(m_customBehavior);
+}
+
 void GraphicsLayerCA::setShowDebugBorder(bool showBorder)
 {
     if (showBorder == m_showDebugBorder)
@@ -3053,6 +3061,15 @@ void GraphicsLayerCA::setCustomAppearance(CustomAppearance customAppearance)
     noteLayerPropertyChanged(CustomAppearanceChanged);
 }
 
+void GraphicsLayerCA::setCustomBehavior(CustomBehavior customBehavior)
+{
+    if (customBehavior == m_customBehavior)
+        return;
+
+    GraphicsLayer::setCustomBehavior(customBehavior);
+    noteLayerPropertyChanged(CustomBehaviorChanged);
+}
+
 bool GraphicsLayerCA::requiresTiledLayer(float pageScaleFactor) const
 {
     if (!m_drawsContent || !m_allowTiledLayer || m_isPageTiledBackingLayer)
index 14c0f8d..2a43d1f 100644 (file)
@@ -138,6 +138,7 @@ public:
     virtual void setDebugBorder(const Color&, float borderWidth);
 
     virtual void setCustomAppearance(CustomAppearance);
+    virtual void setCustomBehavior(CustomBehavior);
 
     virtual void layerDidDisplay(PlatformLayer*);
 
@@ -389,7 +390,8 @@ private:
     void updateTiles();
     void updateContentsScale(float pageScaleFactor);
     void updateCustomAppearance();
-    
+    void updateCustomBehavior();
+
     enum StructuralLayerPurpose {
         NoStructuralLayer = 0,
         StructuralLayerForPreserves3D,
@@ -447,9 +449,10 @@ private:
         TilesAdded = 1 < 29,
         DebugIndicatorsChanged = 1 << 30,
         CustomAppearanceChanged = 1 << 31,
-        BlendModeChanged        = 1 << 32
+        CustomBehaviorChanged = 1 << 32,
+        BlendModeChanged = 1 << 33
     };
-    typedef unsigned LayerChangeFlags;
+    typedef uint64_t LayerChangeFlags;
     enum ScheduleFlushOrNot { ScheduleFlush, DontScheduleFlush };
     void noteLayerPropertyChanged(LayerChangeFlags, ScheduleFlushOrNot = ScheduleFlush);
     void noteSublayersChanged(ScheduleFlushOrNot = ScheduleFlush);
index 5143c20..81db712 100644 (file)
@@ -197,6 +197,9 @@ public:
     virtual GraphicsLayer::CustomAppearance customAppearance() const = 0;
     virtual void updateCustomAppearance(GraphicsLayer::CustomAppearance) = 0;
 
+    virtual GraphicsLayer::CustomBehavior customBehavior() const = 0;
+    virtual void updateCustomBehavior(GraphicsLayer::CustomBehavior) = 0;
+
     virtual TiledBacking* tiledBacking() = 0;
 
 #if PLATFORM(WIN)
index d670ee6..c52df22 100644 (file)
@@ -136,6 +136,9 @@ public:
     virtual GraphicsLayer::CustomAppearance customAppearance() const override { return m_customAppearance; }
     virtual void updateCustomAppearance(GraphicsLayer::CustomAppearance) override;
 
+    virtual GraphicsLayer::CustomBehavior customBehavior() const override { return m_customBehavior; }
+    virtual void updateCustomBehavior(GraphicsLayer::CustomBehavior) override { }
+
     virtual TiledBacking* tiledBacking() override;
 
     virtual PassRefPtr<PlatformCALayer> clone(PlatformCALayerClient* owner) const override;
@@ -157,6 +160,7 @@ private:
     RetainPtr<NSObject> m_delegate;
     OwnPtr<PlatformCALayerList> m_customSublayers;
     GraphicsLayer::CustomAppearance m_customAppearance;
+    GraphicsLayer::CustomBehavior m_customBehavior;
 };
 
 PLATFORM_CALAYER_TYPE_CASTS(PlatformCALayerMac, isPlatformCALayerMac())
index c242790..6856a22 100644 (file)
@@ -165,6 +165,7 @@ static NSString *toCAFilterType(PlatformCALayer::FilterType type)
 PlatformCALayerMac::PlatformCALayerMac(LayerType layerType, PlatformCALayerClient* owner)
     : PlatformCALayer(layerType, owner)
     , m_customAppearance(GraphicsLayer::NoCustomAppearance)
+    , m_customBehavior(GraphicsLayer::NoCustomBehavior)
 {
     Class layerClass = Nil;
     switch (layerType) {
@@ -205,6 +206,7 @@ PlatformCALayerMac::PlatformCALayerMac(LayerType layerType, PlatformCALayerClien
 PlatformCALayerMac::PlatformCALayerMac(PlatformLayer* layer, PlatformCALayerClient* owner)
     : PlatformCALayer([layer isKindOfClass:getAVPlayerLayerClass()] ? LayerTypeAVPlayerLayer : LayerTypeCustom, owner)
     , m_customAppearance(GraphicsLayer::NoCustomAppearance)
+    , m_customBehavior(GraphicsLayer::NoCustomBehavior)
 {
     m_layer = layer;
     commonInit();
index 8ee1798..c9fa884 100644 (file)
@@ -1431,7 +1431,9 @@ bool RenderLayerBacking::updateScrollingLayers(bool needsScrollingLayers)
         m_scrollingLayer = createGraphicsLayer("Scrolling container");
         m_scrollingLayer->setDrawsContent(false);
         m_scrollingLayer->setMasksToBounds(true);
-
+#if PLATFORM(IOS)
+        m_scrollingLayer->setCustomBehavior(GraphicsLayer::CustomScrollingBehavior);
+#endif
         // Inner layer which renders the content that scrolls.
         m_scrollingContentsLayer = createGraphicsLayer("Scrolled Contents");
         m_scrollingContentsLayer->setDrawsContent(true);
index 5a5de8c..969da5e 100644 (file)
@@ -1,3 +1,25 @@
+2014-03-26  Simon Fraser  <simon.fraser@apple.com>
+
+        Add a custom behavior flag to GraphicsLayer, piped down to PlatformCALayer, for scrolling layers
+        https://bugs.webkit.org/show_bug.cgi?id=130778
+
+        Reviewed by Tim Horton.
+
+        Make it possible to put a "custom behavior" flag on a layer so that,
+        with UI-side compositing, we know to create a specific type of
+        layer or view for that GraphicsLayer.
+
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
+        (WebKit::dumpChangedLayers):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (PlatformCALayerRemote::customBehavior):
+        (PlatformCALayerRemote::updateCustomBehavior):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+
 2014-03-26  Zoltan Horvath  <zoltan@webkit.org>
 
         [CSS Shapes] Remove shape-inside support
index f358a56..218b8d0 100644 (file)
@@ -75,7 +75,8 @@ public:
         BackingStoreChanged = 1 << 24,
         FiltersChanged = 1 << 25,
         EdgeAntialiasingMaskChanged = 1 << 26,
-        CustomAppearanceChanged = 1 << 27
+        CustomAppearanceChanged = 1 << 27,
+        CustomBehaviorChanged = 1 << 28
     };
     typedef unsigned LayerChange;
 
@@ -127,6 +128,7 @@ public:
         WebCore::Color borderColor;
         unsigned edgeAntialiasingMask;
         WebCore::GraphicsLayer::CustomAppearance customAppearance;
+        WebCore::GraphicsLayer::CustomBehavior customBehavior;
         WebCore::PlatformCALayer::FilterType minificationFilter;
         WebCore::PlatformCALayer::FilterType magnificationFilter;
         bool hidden;
index d3ca5ef..907a387 100644 (file)
@@ -87,6 +87,7 @@ RemoteLayerTreeTransaction::LayerProperties::LayerProperties()
     , borderColor(Color::black)
     , edgeAntialiasingMask(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge)
     , customAppearance(GraphicsLayer::NoCustomAppearance)
+    , customBehavior(GraphicsLayer::NoCustomBehavior)
     , minificationFilter(PlatformCALayer::FilterType::Linear)
     , magnificationFilter(PlatformCALayer::FilterType::Linear)
     , hidden(false)
@@ -116,6 +117,7 @@ RemoteLayerTreeTransaction::LayerProperties::LayerProperties(const LayerProperti
     , borderColor(other.borderColor)
     , edgeAntialiasingMask(other.edgeAntialiasingMask)
     , customAppearance(other.customAppearance)
+    , customBehavior(other.customBehavior)
     , minificationFilter(other.minificationFilter)
     , magnificationFilter(other.magnificationFilter)
     , hidden(other.hidden)
@@ -224,6 +226,9 @@ void RemoteLayerTreeTransaction::LayerProperties::encode(IPC::ArgumentEncoder& e
 
     if (changedProperties & CustomAppearanceChanged)
         encoder.encodeEnum(customAppearance);
+
+    if (changedProperties & CustomBehaviorChanged)
+        encoder.encodeEnum(customBehavior);
 }
 
 bool RemoteLayerTreeTransaction::LayerProperties::decode(IPC::ArgumentDecoder& decoder, LayerProperties& result)
@@ -387,6 +392,11 @@ bool RemoteLayerTreeTransaction::LayerProperties::decode(IPC::ArgumentDecoder& d
             return false;
     }
 
+    if (result.changedProperties & CustomBehaviorChanged) {
+        if (!decoder.decodeEnum(result.customBehavior))
+            return false;
+    }
+
     return true;
 }
 
@@ -805,6 +815,9 @@ static void dumpChangedLayers(RemoteLayerTreeTextStream& ts, const RemoteLayerTr
         if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CustomAppearanceChanged)
             dumpProperty<GraphicsLayer::CustomAppearance>(ts, "customAppearance", layerProperties.customAppearance);
 
+        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CustomBehaviorChanged)
+            dumpProperty<GraphicsLayer::CustomBehavior>(ts, "customBehavior", layerProperties.customBehavior);
+
         ts << ")";
 
         ts.decreaseIndent();
index 49c64f8..7659665 100644 (file)
@@ -563,6 +563,17 @@ void PlatformCALayerRemote::updateCustomAppearance(GraphicsLayer::CustomAppearan
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::CustomAppearanceChanged);
 }
 
+GraphicsLayer::CustomBehavior PlatformCALayerRemote::customBehavior() const
+{
+    return m_properties.customBehavior;
+}
+
+void PlatformCALayerRemote::updateCustomBehavior(GraphicsLayer::CustomBehavior customBehavior)
+{
+    m_properties.customBehavior = customBehavior;
+    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::CustomBehaviorChanged);
+}
+
 PassRefPtr<PlatformCALayer> PlatformCALayerRemote::createCompatibleLayer(PlatformCALayer::LayerType layerType, PlatformCALayerClient* client) const
 {
     return PlatformCALayerRemote::create(layerType, client, m_context);
index 17d7a11..b7289f9 100644 (file)
@@ -138,6 +138,9 @@ public:
     virtual WebCore::GraphicsLayer::CustomAppearance customAppearance() const override;
     virtual void updateCustomAppearance(WebCore::GraphicsLayer::CustomAppearance) override;
 
+    virtual WebCore::GraphicsLayer::CustomBehavior customBehavior() const override;
+    virtual void updateCustomBehavior(WebCore::GraphicsLayer::CustomBehavior) override;
+
     virtual WebCore::TiledBacking* tiledBacking() override { return nullptr; }
 
     virtual PassRefPtr<WebCore::PlatformCALayer> clone(WebCore::PlatformCALayerClient* owner) const override;