Remove RemoteLayerBackingStore’s RemoteLayerTreeContext pointer
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jun 2014 03:11:24 +0000 (03:11 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jun 2014 03:11:24 +0000 (03:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134055

Reviewed by Simon Fraser.

* Shared/mac/RemoteLayerBackingStore.h:
* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::RemoteLayerBackingStore):
(WebKit::RemoteLayerBackingStore::~RemoteLayerBackingStore):
(WebKit::RemoteLayerBackingStore::ensureBackingStore):
(WebKit::RemoteLayerBackingStore::display):
(WebKit::RemoteLayerBackingStore::drawInContext):
Remove RemoteLayerBackingStore's RemoteLayerTreeContext pointer. Instead, use the PlatformCALayer's.
Pass the PlatformCALayer in to the constructor, and remove it from ensureBackingStore();
RemoteLayerBackingStore is (for now) strictly tied to a single layer.

* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::ensureBackingStore):
(WebKit::PlatformCALayerRemote::updateBackingStore):
* WebProcess/WebPage/mac/PlatformCALayerRemote.h:
(WebKit::PlatformCALayerRemote::context):

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h
Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

index d6e6cf3f4ed9f0c0fbe3c6e35597e120f4e97abd..52fe312727246863ed15879db762e32fa583ccfe 100644 (file)
@@ -1,3 +1,27 @@
+2014-06-18  Tim Horton  <timothy_horton@apple.com>
+
+        Remove RemoteLayerBackingStore’s RemoteLayerTreeContext pointer
+        https://bugs.webkit.org/show_bug.cgi?id=134055
+
+        Reviewed by Simon Fraser.
+
+        * Shared/mac/RemoteLayerBackingStore.h:
+        * Shared/mac/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::RemoteLayerBackingStore):
+        (WebKit::RemoteLayerBackingStore::~RemoteLayerBackingStore):
+        (WebKit::RemoteLayerBackingStore::ensureBackingStore):
+        (WebKit::RemoteLayerBackingStore::display):
+        (WebKit::RemoteLayerBackingStore::drawInContext):
+        Remove RemoteLayerBackingStore's RemoteLayerTreeContext pointer. Instead, use the PlatformCALayer's.
+        Pass the PlatformCALayer in to the constructor, and remove it from ensureBackingStore();
+        RemoteLayerBackingStore is (for now) strictly tied to a single layer.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::ensureBackingStore):
+        (WebKit::PlatformCALayerRemote::updateBackingStore):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+        (WebKit::PlatformCALayerRemote::context):
+
 2014-06-18  Dan Bernstein  <mitz@apple.com>
 
         [Cocoa] Modernize one-method authentication
index fa7db62ea5ce85ff08fdbd7da7dbbaf81217f172..24272331de8575a2b3c7124ff808c99e4c017b93 100644 (file)
@@ -42,16 +42,15 @@ typedef Vector<WebCore::FloatRect, 5> RepaintRectList;
 namespace WebKit {
 
 class PlatformCALayerRemote;
-class RemoteLayerTreeContext;
 
 class RemoteLayerBackingStore {
     WTF_MAKE_NONCOPYABLE(RemoteLayerBackingStore);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    RemoteLayerBackingStore(RemoteLayerTreeContext*);
+    RemoteLayerBackingStore(PlatformCALayerRemote*);
     ~RemoteLayerBackingStore();
 
-    void ensureBackingStore(PlatformCALayerRemote*, WebCore::FloatSize, float scale, bool acceleratesDrawing, bool isOpaque);
+    void ensureBackingStore(WebCore::FloatSize, float scale, bool acceleratesDrawing, bool isOpaque);
 
     void setNeedsDisplay(const WebCore::IntRect);
     void setNeedsDisplay();
@@ -128,8 +127,6 @@ private:
 
     WebCore::RepaintRectList m_paintingRects;
 
-    RemoteLayerTreeContext* m_context;
-
     std::chrono::steady_clock::time_point m_lastDisplayTime;
 };
 
index 5829905d3c4e772a20d8f721eb0773b38a445fb1..81f6f39d802aff39787a1c4b474b55e3366469e3 100644 (file)
@@ -55,30 +55,32 @@ using namespace WebCore;
 
 namespace WebKit {
 
-RemoteLayerBackingStore::RemoteLayerBackingStore(RemoteLayerTreeContext* context)
-    : m_layer(nullptr)
+RemoteLayerBackingStore::RemoteLayerBackingStore(PlatformCALayerRemote* layer)
+    : m_layer(layer)
     , m_isOpaque(false)
-    , m_context(context)
     , m_lastDisplayTime(std::chrono::steady_clock::time_point::min())
 {
-    if (m_context)
-        m_context->backingStoreWasCreated(this);
+    if (!m_layer)
+        return;
+    if (RemoteLayerTreeContext* context = m_layer->context())
+        context->backingStoreWasCreated(this);
 }
 
 RemoteLayerBackingStore::~RemoteLayerBackingStore()
 {
     clearBackingStore();
 
-    if (m_context)
-        m_context->backingStoreWillBeDestroyed(this);
+    if (!m_layer)
+        return;
+    if (RemoteLayerTreeContext* context = m_layer->context())
+        context->backingStoreWillBeDestroyed(this);
 }
 
-void RemoteLayerBackingStore::ensureBackingStore(PlatformCALayerRemote* layer, FloatSize size, float scale, bool acceleratesDrawing, bool isOpaque)
+void RemoteLayerBackingStore::ensureBackingStore(FloatSize size, float scale, bool acceleratesDrawing, bool isOpaque)
 {
-    if (m_layer == layer && m_size == size && m_scale == scale && m_acceleratesDrawing == acceleratesDrawing && m_isOpaque == isOpaque)
+    if (m_size == size && m_scale == scale && m_acceleratesDrawing == acceleratesDrawing && m_isOpaque == isOpaque)
         return;
 
-    m_layer = layer;
     m_size = size;
     m_scale = scale;
     m_acceleratesDrawing = acceleratesDrawing;
@@ -201,8 +203,8 @@ bool RemoteLayerBackingStore::display()
 
     m_lastDisplayTime = std::chrono::steady_clock::now();
 
-    if (m_context)
-        m_context->backingStoreWillBeDisplayed(this);
+    if (RemoteLayerTreeContext* context = m_layer->context())
+        context->backingStoreWillBeDisplayed(this);
 
     // Make the previous front buffer non-volatile early, so that we can dirty the whole layer if it comes back empty.
     setBufferVolatility(BufferType::Front, false);
@@ -319,6 +321,7 @@ void RemoteLayerBackingStore::drawInContext(GraphicsContext& context, CGImageRef
 
     context.scale(FloatSize(m_scale, m_scale));
 
+    // FIXME: This should be moved to PlatformCALayerRemote for better layering.
     switch (m_layer->layerType()) {
     case PlatformCALayer::LayerTypeSimpleLayer:
     case PlatformCALayer::LayerTypeTiledBackingTileLayer:
index 4b4d3644346b94538b9b3d3a980e9f225e389e5e..e8e2b7464375654a428d4a73e0505b2cfbe30e06 100644 (file)
@@ -167,7 +167,7 @@ void PlatformCALayerRemote::ensureBackingStore()
     ASSERT(owner());
     
     if (!m_properties.backingStore)
-        m_properties.backingStore = std::make_unique<RemoteLayerBackingStore>(m_context);
+        m_properties.backingStore = std::make_unique<RemoteLayerBackingStore>(this);
 
     updateBackingStore();
 }
@@ -177,7 +177,7 @@ void PlatformCALayerRemote::updateBackingStore()
     if (!m_properties.backingStore)
         return;
 
-    m_properties.backingStore->ensureBackingStore(this, m_properties.bounds.size(), m_properties.contentsScale, m_acceleratesDrawing, m_properties.opaque);
+    m_properties.backingStore->ensureBackingStore(m_properties.bounds.size(), m_properties.contentsScale, m_acceleratesDrawing, m_properties.opaque);
 }
 
 void PlatformCALayerRemote::setNeedsDisplay(const FloatRect* rect)
index 3954808635ec848fdb4ce4a08b34573066f8865e..be389cd8273429bd8ecc96e968c4b8d5f99b8626 100644 (file)
@@ -161,13 +161,12 @@ public:
     void didCommit();
 
     void clearContext() { m_context = nullptr; }
+    RemoteLayerTreeContext* context() const { return m_context; }
 
 protected:
     PlatformCALayerRemote(WebCore::PlatformCALayer::LayerType, WebCore::PlatformCALayerClient* owner, RemoteLayerTreeContext* context);
     PlatformCALayerRemote(const PlatformCALayerRemote&, WebCore::PlatformCALayerClient*, RemoteLayerTreeContext*);
 
-    RemoteLayerTreeContext* context() const { return m_context; }
-
 private:
     virtual bool isPlatformCALayerRemote() const override { return true; }
     void ensureBackingStore();