Give all PlatformCALayers a PlatformLayerID, not just remote ones
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Jan 2014 00:15:12 +0000 (00:15 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Jan 2014 00:15:12 +0000 (00:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126466

Reviewed by Tim Horton.

Source/WebCore:

The ScrollingStateTree has references to both GraphicsLayers and PlatformLayers
which is confusing, and is necessary because the underlying PlatformLayer
inside a GraphicsLayer can change. In order to hide some of this complexity,
expose GraphicsLayer::primaryLayerID() which is a PlatformLayerID that clients
can hold onto to test for underlying layer swapping.

Also constify LayerType m_layerType on PlatformCALayer, which required
cleaning up the construction of PlatformCALayerMac in the case where a
PlatformCALayerMac is wrapping an existing CALayer (which happens for video).

* WebCore.exp.in:
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::primaryLayerID):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::primaryLayerID):
* platform/graphics/ca/GraphicsLayerCA.h:
* platform/graphics/ca/PlatformCALayer.cpp:
(WebCore::generateLayerID):
(WebCore::PlatformCALayer::PlatformCALayer):
* platform/graphics/ca/PlatformCALayer.h:
(WebCore::PlatformCALayer::layerID):
* platform/graphics/ca/mac/PlatformCALayerMac.h:
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(PlatformCALayerMac::create):
(PlatformCALayerMac::PlatformCALayerMac):
(PlatformCALayerMac::commonInit):

Source/WebKit2:

The ScrollingStateTree has references to both GraphicsLayers and PlatformLayers
which is confusing, and is necessary because the underlying PlatformLayer
inside a GraphicsLayer can change. In order to hide some of this complexity,
expose GraphicsLayer::primaryLayerID() which is a PlatformLayerID that clients
can hold onto to test for underlying layer swapping.

GraphicsLayerCARemote and PlatformCALayerRemote can now just use the
primaryLayerID() function exposed via the base class.

* WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp:
* WebProcess/WebPage/mac/GraphicsLayerCARemote.h:
* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(PlatformCALayerRemote::PlatformCALayerRemote):
(PlatformCALayerRemote::recursiveBuildTransaction):
* WebProcess/WebPage/mac/PlatformCALayerRemote.h:

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

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
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.cpp
Source/WebCore/platform/graphics/ca/PlatformCALayer.h
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/GraphicsLayerCARemote.h
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

index 3882c17..807d0a9 100644 (file)
@@ -1,3 +1,37 @@
+2014-01-03  Simon Fraser  <simon.fraser@apple.com>
+
+        Give all PlatformCALayers a PlatformLayerID, not just remote ones
+        https://bugs.webkit.org/show_bug.cgi?id=126466
+
+        Reviewed by Tim Horton.
+
+        The ScrollingStateTree has references to both GraphicsLayers and PlatformLayers
+        which is confusing, and is necessary because the underlying PlatformLayer
+        inside a GraphicsLayer can change. In order to hide some of this complexity,
+        expose GraphicsLayer::primaryLayerID() which is a PlatformLayerID that clients
+        can hold onto to test for underlying layer swapping.
+        
+        Also constify LayerType m_layerType on PlatformCALayer, which required
+        cleaning up the construction of PlatformCALayerMac in the case where a
+        PlatformCALayerMac is wrapping an existing CALayer (which happens for video).
+
+        * WebCore.exp.in:
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::primaryLayerID):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::primaryLayerID):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * platform/graphics/ca/PlatformCALayer.cpp:
+        (WebCore::generateLayerID):
+        (WebCore::PlatformCALayer::PlatformCALayer):
+        * platform/graphics/ca/PlatformCALayer.h:
+        (WebCore::PlatformCALayer::layerID):
+        * platform/graphics/ca/mac/PlatformCALayerMac.h:
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (PlatformCALayerMac::create):
+        (PlatformCALayerMac::PlatformCALayerMac):
+        (PlatformCALayerMac::commonInit):
+
 2014-01-03  Andreas Kling  <akling@apple.com>
 
         Add lineageOfType renderer iterator and start using it.
index 6aed231..be84cca 100644 (file)
@@ -575,12 +575,14 @@ __ZN7WebCore15GraphicsLayerCA8addChildEPNS_13GraphicsLayerE
 __ZN7WebCore15GraphicsLayerCAC2EPNS_19GraphicsLayerClientE
 __ZN7WebCore15GraphicsLayerCAD2Ev
 __ZN7WebCore15GraphicsLayerCA19setCustomAppearanceENS_13GraphicsLayer16CustomAppearanceE
+__ZNK7WebCore15GraphicsLayerCA14primaryLayerIDEv
 __ZN7WebCore15HitTestLocation12rectForPointERKNS_11LayoutPointEjjjj
 __ZN7WebCore15HitTestLocationC1ERKNS_10FloatPointE
 __ZN7WebCore15HitTestLocationD1Ev
 __ZN7WebCore15JSDOMWindowBase8commonVMEv
 __ZN7WebCore15PasteboardImageC1Ev
 __ZN7WebCore15PasteboardImageD1Ev
+__ZN7WebCore15PlatformCALayerC2ENS0_9LayerTypeEPNS_21PlatformCALayerClientE
 __ZN7WebCore15PlatformCALayerD2Ev
 __ZN7WebCore15ProtectionSpaceC1ERKN3WTF6StringEiNS_25ProtectionSpaceServerTypeES4_NS_35ProtectionSpaceAuthenticationSchemeE
 __ZN7WebCore15ProtectionSpaceC1Ev
index ff95086..644ee04 100644 (file)
@@ -226,12 +226,13 @@ class GraphicsLayer {
 public:
     static std::unique_ptr<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayerClient*);
     
-    typedef uint64_t PlatformLayerID;
-
     virtual ~GraphicsLayer();
 
     virtual void initialize() { }
 
+    typedef uint64_t PlatformLayerID;
+    virtual PlatformLayerID primaryLayerID() const { return 0; }
+
     GraphicsLayerClient* client() const { return m_client; }
 
     // Layer name. Only used to identify layers in debug output
index 6104b5d..3ebdef5 100644 (file)
@@ -397,6 +397,11 @@ void GraphicsLayerCA::setName(const String& name)
     noteLayerPropertyChanged(NameChanged);
 }
 
+GraphicsLayer::PlatformLayerID GraphicsLayerCA::primaryLayerID() const
+{
+    return primaryLayer()->layerID();
+}
+
 PlatformLayer* GraphicsLayerCA::platformLayer() const
 {
     return primaryLayer()->platformLayer();
index b62e3a0..aa7cb02 100644 (file)
@@ -60,6 +60,8 @@ public:
 
     virtual void setName(const String&);
 
+    virtual PlatformLayerID primaryLayerID() const OVERRIDE;
+
     virtual PlatformLayer* platformLayer() const;
     virtual PlatformCALayer* platformCALayer() const { return primaryLayer(); }
 
index 3ef8bf4..3b31f87 100644 (file)
 
 namespace WebCore {
 
+static GraphicsLayer::PlatformLayerID generateLayerID()
+{
+    static GraphicsLayer::PlatformLayerID layerID;
+    return ++layerID;
+}
+
+PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformCALayerClient* owner)
+    : m_layerType(layerType)
+    , m_layerID(generateLayerID())
+    , m_owner(owner)
+{
+}
+
 PlatformCALayer::~PlatformCALayer()
 {
     // Clear the owner, which also clears it in the delegate to prevent attempts
index 3aecdba..fb7e610 100644 (file)
@@ -29,6 +29,7 @@
 #if USE(ACCELERATED_COMPOSITING)
 
 #include "GraphicsContext.h"
+#include "GraphicsLayer.h"
 #include "PlatformCAAnimation.h"
 #include "PlatformCALayerClient.h"
 #include <QuartzCore/CABase.h>
@@ -80,6 +81,8 @@ public:
 
     virtual ~PlatformCALayer();
 
+    GraphicsLayer::PlatformLayerID layerID() const { return m_layerID; }
+
     virtual bool isPlatformCALayerMac() const { return false; }
     virtual bool isPlatformCALayerRemote() const { return false; }
 
@@ -210,12 +213,10 @@ public:
 #endif
 
 protected:
-    PlatformCALayer(LayerType layerType, PlatformCALayerClient* owner)
-        : m_layerType(layerType)
-        , m_owner(owner)
-    { }
+    PlatformCALayer(LayerType, PlatformCALayerClient* owner);
 
-    LayerType m_layerType;
+    const LayerType m_layerType;
+    const GraphicsLayer::PlatformLayerID m_layerID;
     RetainPtr<PlatformLayer> m_layer;
     PlatformCALayerClient* m_owner;
 };
index 98ff602..0bbe526 100644 (file)
@@ -147,7 +147,11 @@ public:
     virtual void enumerateRectsBeingDrawn(CGContextRef, void (^block)(CGRect)) OVERRIDE;
 
 private:
-    PlatformCALayerMac(LayerType, PlatformLayer*, PlatformCALayerClient* owner);
+    PlatformCALayerMac(LayerType, PlatformCALayerClient* owner);
+    PlatformCALayerMac(PlatformLayer*, PlatformCALayerClient* owner);
+
+    void commonInit();
+
     virtual bool isPlatformCALayerMac() const OVERRIDE { return true; }
 
     bool requiresCustomAppearanceUpdateOnBoundsChange() const;
index e363a00..31b4824 100644 (file)
@@ -55,12 +55,12 @@ using namespace WebCore;
 
 PassRefPtr<PlatformCALayer> PlatformCALayerMac::create(LayerType layerType, PlatformCALayerClient* owner)
 {
-    return adoptRef(new PlatformCALayerMac(layerType, 0, owner));
+    return adoptRef(new PlatformCALayerMac(layerType, owner));
 }
 
 PassRefPtr<PlatformCALayer> PlatformCALayerMac::create(void* platformLayer, PlatformCALayerClient* owner)
 {
-    return adoptRef(new PlatformCALayerMac(LayerTypeCustom, static_cast<PlatformLayer*>(platformLayer), owner));
+    return adoptRef(new PlatformCALayerMac(static_cast<PlatformLayer*>(platformLayer), owner));
 }
 
 static NSString * const platformCALayerPointer = @"WKPlatformCALayer";
@@ -177,50 +177,57 @@ static NSString *toCAFilterType(PlatformCALayer::FilterType type)
     }
 }
 
-PlatformCALayerMac::PlatformCALayerMac(LayerType layerType, PlatformLayer* layer, PlatformCALayerClient* owner)
-    : PlatformCALayer(layer ? LayerTypeCustom : layerType, owner)
+PlatformCALayerMac::PlatformCALayerMac(LayerType layerType, PlatformCALayerClient* owner)
+    : PlatformCALayer(layerType, owner)
     , m_customAppearance(GraphicsLayer::NoCustomAppearance)
 {
-    BEGIN_BLOCK_OBJC_EXCEPTIONS
-    if (layer) {
-        if ([layer isKindOfClass:getAVPlayerLayerClass()])
-            m_layerType = LayerTypeAVPlayerLayer;
-        m_layer = layer;
-    } else {
-        Class layerClass = Nil;
-        switch (layerType) {
-        case LayerTypeLayer:
-        case LayerTypeRootLayer:
-            layerClass = [CALayer class];
-            break;
-        case LayerTypeWebLayer:
-            layerClass = [WebLayer class];
-            break;
-        case LayerTypeSimpleLayer:
-        case LayerTypeTiledBackingTileLayer:
-            layerClass = [WebSimpleLayer class];
-            break;
-        case LayerTypeTransformLayer:
-            layerClass = [CATransformLayer class];
-            break;
-        case LayerTypeWebTiledLayer:
-            ASSERT_NOT_REACHED();
-            break;
-        case LayerTypeTiledBackingLayer:
-        case LayerTypePageTiledBackingLayer:
-            layerClass = [WebTiledBackingLayer class];
-            break;
-        case LayerTypeAVPlayerLayer:
-            layerClass = getAVPlayerLayerClass();
-            break;
-        case LayerTypeCustom:
-            break;
-        }
-
-        if (layerClass)
-            m_layer = adoptNS([[layerClass alloc] init]);
+    Class layerClass = Nil;
+    switch (layerType) {
+    case LayerTypeLayer:
+    case LayerTypeRootLayer:
+        layerClass = [CALayer class];
+        break;
+    case LayerTypeWebLayer:
+        layerClass = [WebLayer class];
+        break;
+    case LayerTypeSimpleLayer:
+    case LayerTypeTiledBackingTileLayer:
+        layerClass = [WebSimpleLayer class];
+        break;
+    case LayerTypeTransformLayer:
+        layerClass = [CATransformLayer class];
+        break;
+    case LayerTypeWebTiledLayer:
+        ASSERT_NOT_REACHED();
+        break;
+    case LayerTypeTiledBackingLayer:
+    case LayerTypePageTiledBackingLayer:
+        layerClass = [WebTiledBackingLayer class];
+        break;
+    case LayerTypeAVPlayerLayer:
+        layerClass = getAVPlayerLayerClass();
+        break;
+    case LayerTypeCustom:
+        break;
     }
+
+    if (layerClass)
+        m_layer = adoptNS([[layerClass alloc] init]);
     
+    commonInit();
+}
+
+PlatformCALayerMac::PlatformCALayerMac(PlatformLayer* layer, PlatformCALayerClient* owner)
+    : PlatformCALayer([layer isKindOfClass:getAVPlayerLayerClass()] ? LayerTypeAVPlayerLayer : LayerTypeCustom, owner)
+    , m_customAppearance(GraphicsLayer::NoCustomAppearance)
+{
+    m_layer = layer;
+    commonInit();
+}
+
+void PlatformCALayerMac::commonInit()
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS
     // Save a pointer to 'this' in the CALayer
     [m_layer.get() setValue:[NSValue valueWithPointer:this] forKey:platformCALayerPointer];
     
index fe74c84..c20acf2 100644 (file)
@@ -1,3 +1,26 @@
+2014-01-03  Simon Fraser  <simon.fraser@apple.com>
+
+        Give all PlatformCALayers a PlatformLayerID, not just remote ones
+        https://bugs.webkit.org/show_bug.cgi?id=126466
+
+        Reviewed by Tim Horton.
+
+        The ScrollingStateTree has references to both GraphicsLayers and PlatformLayers
+        which is confusing, and is necessary because the underlying PlatformLayer
+        inside a GraphicsLayer can change. In order to hide some of this complexity,
+        expose GraphicsLayer::primaryLayerID() which is a PlatformLayerID that clients
+        can hold onto to test for underlying layer swapping.
+        
+        GraphicsLayerCARemote and PlatformCALayerRemote can now just use the
+        primaryLayerID() function exposed via the base class.
+
+        * WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp:
+        * WebProcess/WebPage/mac/GraphicsLayerCARemote.h:
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (PlatformCALayerRemote::PlatformCALayerRemote):
+        (PlatformCALayerRemote::recursiveBuildTransaction):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+
 2014-01-03  Dan Bernstein  <mitz@apple.com>
 
         [Cocoa] Expose session state API
index 2896873..0d81f17 100644 (file)
@@ -38,11 +38,6 @@ GraphicsLayerCARemote::~GraphicsLayerCARemote()
 {
 }
 
-GraphicsLayer::PlatformLayerID GraphicsLayerCARemote::primaryLayerID() const
-{
-    return toPlatformCALayerRemote(platformCALayer())->layerID();
-}
-
 #if ENABLE(CSS_FILTERS)
 bool GraphicsLayerCARemote::filtersCanBeComposited(const FilterOperations& filters)
 {
index aa6c46d..c2dad44 100644 (file)
@@ -45,8 +45,6 @@ public:
 
     virtual ~GraphicsLayerCARemote();
     
-    PlatformLayerID primaryLayerID() const;
-
 #if ENABLE(CSS_FILTERS)
     virtual bool filtersCanBeComposited(const WebCore::FilterOperations& filters) OVERRIDE;
 #endif
index 73c91e9..25113a4 100644 (file)
 using namespace WebCore;
 using namespace WebKit;
 
-static WebCore::GraphicsLayer::PlatformLayerID generateLayerID()
-{
-    static WebCore::GraphicsLayer::PlatformLayerID layerID;
-    return ++layerID;
-}
-
 PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
 {
     RefPtr<PlatformCALayerRemote> layer;
@@ -78,7 +72,6 @@ PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(PlatformLayer *p
 
 PlatformCALayerRemote::PlatformCALayerRemote(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext* context)
     : PlatformCALayer(layerType, owner)
-    , m_layerID(generateLayerID())
     , m_superlayer(nullptr)
     , m_maskLayer(nullptr)
     , m_acceleratesDrawing(false)
@@ -112,7 +105,7 @@ void PlatformCALayerRemote::recursiveBuildTransaction(RemoteLayerTreeTransaction
         if (m_properties.changedProperties & RemoteLayerTreeTransaction::ChildrenChanged) {
             m_properties.children.clear();
             for (auto layer : m_children)
-                m_properties.children.append(toPlatformCALayerRemote(layer.get())->layerID());
+                m_properties.children.append(layer->layerID());
         }
 
         if (m_layerType == LayerTypeCustom) {
index 3544b50..44431af 100644 (file)
@@ -44,8 +44,6 @@ public:
 
     virtual ~PlatformCALayerRemote();
 
-    WebCore::GraphicsLayer::PlatformLayerID layerID() { return m_layerID; }
-
     virtual bool usesTiledBackingLayer() const OVERRIDE { return layerType() == LayerTypePageTiledBackingLayer || layerType() == LayerTypeTiledBackingLayer; }
 
     virtual PlatformLayer* platformLayer() const OVERRIDE { return nullptr; }
@@ -161,7 +159,6 @@ private:
 
     bool requiresCustomAppearanceUpdateOnBoundsChange() const;
 
-    const WebCore::GraphicsLayer::PlatformLayerID m_layerID;
     RemoteLayerTreeTransaction::LayerProperties m_properties;
     WebCore::PlatformCALayerList m_children;
     PlatformCALayerRemote* m_superlayer;