Title: [234594] trunk/Source/WebCore
Revision
234594
Author
zandober...@gmail.com
Date
2018-08-06 01:48:01 -0700 (Mon, 06 Aug 2018)

Log Message

[Nicosia] Add additional layer state classes, use impl-based approach to make them extendable
https://bugs.webkit.org/show_bug.cgi?id=188341

Reviewed by Carlos Garcia Campos.

Add the ContentLayer, BackingStore and ImageBacking classes in the
Nicosia namespace. State objects of CompositionLayer instances keep
references to objects of these classes depending on the content that's
presented in the associated GraphicsLayer.

ContentLayer derives from the PlatformLayer class. It's used for layers
that display things like WebGL and HTML5 canvas and media content in a
platform-specific way. In case of TextureMapper the hardware-accelerated
content is piped into that rendering pipeline.

BackingStore is meant to represent the painted contents of a layer. The
equivalent current functionality is using a tiled backing store that
has its contents copied into the CoordinatedBackingStore instance.

ImageBacking is used for a layer whose content is a simple Image object.
Image's pixel data is rasterized and again managed through
CoordinatedBackingStore for rendering.

All these classes, along with the CompositionLayer class, should now be
constructed with a factory function that returns an object that derives
the class-specific Impl interface. This will allow for simpler
implementation of different approaches in parallel. The TextureMapper
variants will be the first ones, replicating the current behavior as it
is implemented across classes in the CoordinatedGraphics and
TextureMapper layers.

* platform/graphics/nicosia/NicosiaPlatformLayer.cpp:
(Nicosia::CompositionLayer::CompositionLayer):
* platform/graphics/nicosia/NicosiaPlatformLayer.h:
(Nicosia::PlatformLayer::isContentLayer const):
(Nicosia::CompositionLayer::Impl::isTextureMapperImpl const):
(Nicosia::CompositionLayer::create):
(Nicosia::CompositionLayer::impl const):
(Nicosia::ContentLayer::Impl::isTextureMapperImpl const):
(Nicosia::ContentLayer::create):
(Nicosia::ContentLayer::impl const):
(Nicosia::BackingStore::Impl::isTextureMapperImpl const):
(Nicosia::BackingStore::create):
(Nicosia::BackingStore::impl const):
(Nicosia::ImageBacking::Impl::isTextureMapperImpl const):
(Nicosia::ImageBacking::create):
(Nicosia::ImageBacking::impl const):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (234593 => 234594)


--- trunk/Source/WebCore/ChangeLog	2018-08-06 08:46:30 UTC (rev 234593)
+++ trunk/Source/WebCore/ChangeLog	2018-08-06 08:48:01 UTC (rev 234594)
@@ -1,5 +1,57 @@
 2018-08-06  Zan Dobersek  <zdober...@igalia.com>
 
+        [Nicosia] Add additional layer state classes, use impl-based approach to make them extendable
+        https://bugs.webkit.org/show_bug.cgi?id=188341
+
+        Reviewed by Carlos Garcia Campos.
+
+        Add the ContentLayer, BackingStore and ImageBacking classes in the
+        Nicosia namespace. State objects of CompositionLayer instances keep
+        references to objects of these classes depending on the content that's
+        presented in the associated GraphicsLayer.
+
+        ContentLayer derives from the PlatformLayer class. It's used for layers
+        that display things like WebGL and HTML5 canvas and media content in a
+        platform-specific way. In case of TextureMapper the hardware-accelerated
+        content is piped into that rendering pipeline.
+
+        BackingStore is meant to represent the painted contents of a layer. The
+        equivalent current functionality is using a tiled backing store that
+        has its contents copied into the CoordinatedBackingStore instance.
+
+        ImageBacking is used for a layer whose content is a simple Image object.
+        Image's pixel data is rasterized and again managed through
+        CoordinatedBackingStore for rendering.
+
+        All these classes, along with the CompositionLayer class, should now be
+        constructed with a factory function that returns an object that derives
+        the class-specific Impl interface. This will allow for simpler
+        implementation of different approaches in parallel. The TextureMapper
+        variants will be the first ones, replicating the current behavior as it
+        is implemented across classes in the CoordinatedGraphics and
+        TextureMapper layers.
+
+        * platform/graphics/nicosia/NicosiaPlatformLayer.cpp:
+        (Nicosia::CompositionLayer::CompositionLayer):
+        * platform/graphics/nicosia/NicosiaPlatformLayer.h:
+        (Nicosia::PlatformLayer::isContentLayer const):
+        (Nicosia::CompositionLayer::Impl::isTextureMapperImpl const):
+        (Nicosia::CompositionLayer::create):
+        (Nicosia::CompositionLayer::impl const):
+        (Nicosia::ContentLayer::Impl::isTextureMapperImpl const):
+        (Nicosia::ContentLayer::create):
+        (Nicosia::ContentLayer::impl const):
+        (Nicosia::BackingStore::Impl::isTextureMapperImpl const):
+        (Nicosia::BackingStore::create):
+        (Nicosia::BackingStore::impl const):
+        (Nicosia::ImageBacking::Impl::isTextureMapperImpl const):
+        (Nicosia::ImageBacking::create):
+        (Nicosia::ImageBacking::impl const):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::CoordinatedGraphicsLayer):
+
+2018-08-06  Zan Dobersek  <zdober...@igalia.com>
+
         [Nicosia] Add Nicosia::Scene
         https://bugs.webkit.org/show_bug.cgi?id=188340
 

Modified: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.cpp (234593 => 234594)


--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.cpp	2018-08-06 08:46:30 UTC (rev 234593)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.cpp	2018-08-06 08:48:01 UTC (rev 234594)
@@ -38,11 +38,14 @@
 
 PlatformLayer::~PlatformLayer() = default;
 
-CompositionLayer::CompositionLayer(uint64_t id)
+
+CompositionLayer::CompositionLayer(uint64_t id, const Impl::Factory& factory)
     : PlatformLayer(id)
+    , m_impl(factory(id, *this))
 {
 }
 
 CompositionLayer::~CompositionLayer() = default;
+CompositionLayer::Impl::~Impl() = default;
 
 } // namespace Nicosia

Modified: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h (234593 => 234594)


--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h	2018-08-06 08:46:30 UTC (rev 234593)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h	2018-08-06 08:48:01 UTC (rev 234594)
@@ -36,6 +36,7 @@
 #include "FloatSize.h"
 #include "TextureMapperAnimation.h"
 #include "TransformationMatrix.h"
+#include <wtf/Function.h>
 #include <wtf/Lock.h>
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/TypeCasts.h>
@@ -47,6 +48,7 @@
     virtual ~PlatformLayer();
 
     virtual bool isCompositionLayer() const { return false; }
+    virtual bool isContentLayer() const { return false; }
 
     uint64_t id() const { return m_id; }
 
@@ -60,16 +62,29 @@
     } m_state;
 };
 
+class ContentLayer;
+class BackingStore;
+class ImageBacking;
+
 class CompositionLayer : public PlatformLayer {
 public:
-    static Ref<CompositionLayer> create(uint64_t id)
+    class Impl {
+    public:
+        using Factory = WTF::Function<std::unique_ptr<Impl>(uint64_t, CompositionLayer&)>;
+
+        virtual ~Impl();
+        virtual bool isTextureMapperImpl() const { return false; }
+    };
+
+    static Ref<CompositionLayer> create(uint64_t id, const Impl::Factory& factory)
     {
-        return adoptRef(*new CompositionLayer(id));
+        return adoptRef(*new CompositionLayer(id, factory));
     }
     virtual ~CompositionLayer();
-
     bool isCompositionLayer() const override { return true; }
 
+    Impl& impl() const { return *m_impl; }
+
     struct LayerState {
         struct Delta {
             Delta() = default;
@@ -91,6 +106,9 @@
                     bool maskChanged : 1;
                     bool replicaChanged : 1;
                     bool flagsChanged : 1;
+                    bool contentLayerChanged : 1;
+                    bool backingStoreChanged : 1;
+                    bool imageBackingChanged : 1;
                     bool repaintCounterChanged : 1;
                     bool debugBorderChanged : 1;
                 };
@@ -140,6 +158,10 @@
         RefPtr<CompositionLayer> replica;
         RefPtr<CompositionLayer> mask;
 
+        RefPtr<ContentLayer> contentLayer;
+        RefPtr<BackingStore> backingStore;
+        RefPtr<ImageBacking> imageBacking;
+
         struct RepaintCounter {
             unsigned count { 0 };
             bool visible { false };
@@ -159,13 +181,88 @@
     }
 
 private:
-    explicit CompositionLayer(uint64_t);
+    CompositionLayer(uint64_t, const Impl::Factory&);
 
+    std::unique_ptr<Impl> m_impl;
+
     struct {
         LayerState pending;
     } m_state;
 };
 
+class ContentLayer : public PlatformLayer {
+public:
+    class Impl {
+    public:
+        using Factory = WTF::Function<std::unique_ptr<Impl>(ContentLayer&)>;
+
+        virtual ~Impl();
+        virtual bool isTextureMapperImpl() const { return false; }
+    };
+
+    static Ref<ContentLayer> create(const Impl::Factory& factory)
+    {
+        return adoptRef(*new ContentLayer(factory));
+    }
+    virtual ~ContentLayer();
+    bool isContentLayer() const override { return true; }
+
+    Impl& impl() const { return *m_impl; }
+
+private:
+    ContentLayer(const Impl::Factory&);
+
+    std::unique_ptr<Impl> m_impl;
+};
+
+class BackingStore : public ThreadSafeRefCounted<BackingStore> {
+public:
+    class Impl {
+    public:
+        using Factory = WTF::Function<std::unique_ptr<Impl>(BackingStore&)>;
+
+        virtual ~Impl();
+        virtual bool isTextureMapperImpl() const { return false; }
+    };
+
+    static Ref<BackingStore> create(const Impl::Factory& factory)
+    {
+        return adoptRef(*new BackingStore(factory));
+    }
+    virtual ~BackingStore();
+
+    Impl& impl() const { return *m_impl; }
+
+private:
+    BackingStore(const Impl::Factory&);
+
+    std::unique_ptr<Impl> m_impl;
+};
+
+class ImageBacking : public ThreadSafeRefCounted<ImageBacking> {
+public:
+    class Impl {
+    public:
+        using Factory = WTF::Function<std::unique_ptr<Impl>(ImageBacking&)>;
+
+        virtual ~Impl();
+        virtual bool isTextureMapperImpl() const { return false; }
+    };
+
+    static Ref<ImageBacking> create(const Impl::Factory& factory)
+    {
+        return adoptRef(*new ImageBacking(factory));
+    }
+    virtual ~ImageBacking();
+
+    Impl& impl() const { return *m_impl; }
+
+private:
+    ImageBacking(const Impl::Factory&);
+
+    std::unique_ptr<Impl> m_impl;
+};
+
 } // namespace Nicosia
 
 #define SPECIALIZE_TYPE_TRAITS_NICOSIA_PLATFORMLAYER(ToClassName, predicate) \
@@ -174,3 +271,24 @@
     SPECIALIZE_TYPE_TRAITS_END()
 
 SPECIALIZE_TYPE_TRAITS_NICOSIA_PLATFORMLAYER(CompositionLayer, isCompositionLayer());
+SPECIALIZE_TYPE_TRAITS_NICOSIA_PLATFORMLAYER(ContentLayer, isContentLayer());
+
+#define SPECIALIZE_TYPE_TRAITS_NICOSIA_COMPOSITIONLAYER_IMPL(ToClassName, predicate) \
+    SPECIALIZE_TYPE_TRAITS_BEGIN(Nicosia::ToClassName) \
+    static bool isType(const Nicosia::CompositionLayer::Impl& impl) { return impl.predicate; } \
+    SPECIALIZE_TYPE_TRAITS_END()
+
+#define SPECIALIZE_TYPE_TRAITS_NICOSIA_CONTENTLAYER_IMPL(ToClassName, predicate) \
+    SPECIALIZE_TYPE_TRAITS_BEGIN(Nicosia::ToClassName) \
+    static bool isType(const Nicosia::ContentLayer::Impl& impl) { return impl.predicate; } \
+    SPECIALIZE_TYPE_TRAITS_END()
+
+#define SPECIALIZE_TYPE_TRAITS_NICOSIA_BACKINGSTORE_IMPL(ToClassName, predicate) \
+    SPECIALIZE_TYPE_TRAITS_BEGIN(Nicosia::ToClassName) \
+    static bool isType(const Nicosia::BackingStore::Impl& impl) { return impl.predicate; } \
+    SPECIALIZE_TYPE_TRAITS_END()
+
+#define SPECIALIZE_TYPE_TRAITS_NICOSIA_IMAGEBACKING_IMPL(ToClassName, predicate) \
+    SPECIALIZE_TYPE_TRAITS_BEGIN(Nicosia::ToClassName) \
+    static bool isType(const Nicosia::ImageBacking::Impl& impl) { return impl.predicate; } \
+    SPECIALIZE_TYPE_TRAITS_END()

Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp (234593 => 234594)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2018-08-06 08:46:30 UTC (rev 234593)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2018-08-06 08:48:01 UTC (rev 234594)
@@ -121,6 +121,13 @@
     setShouldUpdateVisibleRect();
 }
 
+// FIXME: this is a temporary helper class to keep Nicosia::CompositionLayer creation working.
+class CompositionLayerNoopImpl final : public Nicosia::CompositionLayer::Impl {
+public:
+    CompositionLayerNoopImpl() = default;
+    virtual ~CompositionLayerNoopImpl() = default;
+};
+
 CoordinatedGraphicsLayer::CoordinatedGraphicsLayer(Type layerType, GraphicsLayerClient& client)
     : GraphicsLayer(layerType, client)
 #ifndef NDEBUG
@@ -147,7 +154,11 @@
     static CoordinatedLayerID nextLayerID = 1;
     m_id = nextLayerID++;
 
-    m_nicosia.layer = Nicosia::CompositionLayer::create(m_id);
+    m_nicosia.layer = Nicosia::CompositionLayer::create(m_id,
+        [](uint64_t, Nicosia::CompositionLayer&)
+        {
+            return std::make_unique<CompositionLayerNoopImpl>();
+        });
 }
 
 CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to