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

Log Message

[Nicosia] Add Nicosia::Scene
https://bugs.webkit.org/show_bug.cgi?id=188340

Reviewed by Carlos Garcia Campos.

Source/WebCore:

Add the Nicosia::Scene class that controls the scene's state and enables
thread-safe updates to that state.

The State struct itself holds a set of all the layers in the scene, and
separates out the root layer specifically. An ID counter is also present
there, allowing consumers of this state to easily check for any updates.

A reference to the Nicosia::Scene object now replaces the
HashSet-and-root-layer pair in the CoordinatedGraphicsState struct.

* platform/TextureMapper.cmake:
* platform/graphics/nicosia/NicosiaScene.cpp: Added.
* platform/graphics/nicosia/NicosiaScene.h: Added.
(Nicosia::Scene::create):
(Nicosia::Scene::accessState):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:

Source/WebKit:

CompositingCoordinator spawns a Nicosia::Scene object that it shares
with the CoordinatedGraphicsSceneState instance. All the
Nicosia::CompositionLayer objects indirectly managed by
CompositingCoordinator are now stored in a local Nicosia::Scene::State
member object. Upon each flush that requires frame synchronization the
Nicosia::Scene object is updated in a thread-safe manner, increasing
the scene ID value as well as copying the local HashSet and root layer
values into the shared Scene object, allowing for the consumer (which
currently is the related CoordinatedGraphicsScene instance) to update
its output accordingly.

* WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
(WebKit::CompositingCoordinator::CompositingCoordinator):
(WebKit::CompositingCoordinator::flushPendingLayerChanges):
(WebKit::CompositingCoordinator::initializeRootCompositingLayerIfNeeded):
(WebKit::CompositingCoordinator::createGraphicsLayer):
(WebKit::CompositingCoordinator::detachLayer):
(WebKit::CompositingCoordinator::attachLayer):
* WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:

Modified Paths

Added Paths

Diff

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


--- trunk/Source/WebCore/ChangeLog	2018-08-06 08:25:34 UTC (rev 234592)
+++ trunk/Source/WebCore/ChangeLog	2018-08-06 08:46:30 UTC (rev 234593)
@@ -1,3 +1,27 @@
+2018-08-06  Zan Dobersek  <zdober...@igalia.com>
+
+        [Nicosia] Add Nicosia::Scene
+        https://bugs.webkit.org/show_bug.cgi?id=188340
+
+        Reviewed by Carlos Garcia Campos.
+
+        Add the Nicosia::Scene class that controls the scene's state and enables
+        thread-safe updates to that state.
+
+        The State struct itself holds a set of all the layers in the scene, and
+        separates out the root layer specifically. An ID counter is also present
+        there, allowing consumers of this state to easily check for any updates.
+
+        A reference to the Nicosia::Scene object now replaces the
+        HashSet-and-root-layer pair in the CoordinatedGraphicsState struct.
+
+        * platform/TextureMapper.cmake:
+        * platform/graphics/nicosia/NicosiaScene.cpp: Added.
+        * platform/graphics/nicosia/NicosiaScene.h: Added.
+        (Nicosia::Scene::create):
+        (Nicosia::Scene::accessState):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
+
 2018-08-06  Carlos Eduardo Ramalho  <cadubent...@gmail.com>
 
         [GTK] Buttons are drawn too large, text not centered

Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (234592 => 234593)


--- trunk/Source/WebCore/platform/TextureMapper.cmake	2018-08-06 08:25:34 UTC (rev 234592)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake	2018-08-06 08:46:30 UTC (rev 234593)
@@ -52,6 +52,7 @@
         platform/graphics/nicosia/NicosiaPaintingEngineBasic.cpp
         platform/graphics/nicosia/NicosiaPaintingEngineThreaded.cpp
         platform/graphics/nicosia/NicosiaPlatformLayer.cpp
+        platform/graphics/nicosia/NicosiaScene.cpp
 
         platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp
         platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp

Added: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaScene.cpp (0 => 234593)


--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaScene.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaScene.cpp	2018-08-06 08:46:30 UTC (rev 234593)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2018 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NicosiaScene.h"
+
+#include "NicosiaPlatformLayer.h"
+
+namespace Nicosia {
+
+Scene::Scene() = default;
+Scene::~Scene() = default;
+
+Scene::State::State() = default;
+Scene::State::~State() = default;
+
+} // namespace Nicosia

Added: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaScene.h (0 => 234593)


--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaScene.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaScene.h	2018-08-06 08:46:30 UTC (rev 234593)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2018 Metrological Group B.V.
+ * Copyright (C) 2018 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <cstdint>
+#include <wtf/HashSet.h>
+#include <wtf/Lock.h>
+#include <wtf/RefPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
+
+namespace Nicosia {
+
+class CompositionLayer;
+
+class Scene : public ThreadSafeRefCounted<Scene> {
+public:
+    static Ref<Scene> create()
+    {
+        return adoptRef(*new Scene);
+    }
+    ~Scene();
+
+    struct State {
+        State();
+        ~State();
+
+        uint32_t id { 0 };
+        HashSet<RefPtr<Nicosia::CompositionLayer>> layers;
+        RefPtr<Nicosia::CompositionLayer> rootLayer;
+    };
+
+    template<typename F>
+    void accessState(const F& functor)
+    {
+        LockHolder locker(m_scene.lock);
+        functor(m_scene.state);
+    }
+
+private:
+    Scene();
+
+    struct {
+        Lock lock;
+        State state;
+    } m_scene;
+};
+
+} // namespace Nicosia

Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h (234592 => 234593)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h	2018-08-06 08:25:34 UTC (rev 234592)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h	2018-08-06 08:46:30 UTC (rev 234593)
@@ -38,6 +38,7 @@
 #include "IntSize.h"
 #include "NicosiaBuffer.h"
 #include "NicosiaPlatformLayer.h"
+#include "NicosiaScene.h"
 #include "SurfaceUpdateInfo.h"
 #include "TextureMapperAnimation.h"
 #include "TransformationMatrix.h"
@@ -171,8 +172,7 @@
 
 struct CoordinatedGraphicsState {
     struct NicosiaState {
-        HashSet<RefPtr<Nicosia::CompositionLayer>> layers;
-        RefPtr<Nicosia::CompositionLayer> rootLayer;
+        RefPtr<Nicosia::Scene> scene;
     } nicosia;
 
     uint32_t rootCompositingLayer;

Modified: trunk/Source/WebKit/ChangeLog (234592 => 234593)


--- trunk/Source/WebKit/ChangeLog	2018-08-06 08:25:34 UTC (rev 234592)
+++ trunk/Source/WebKit/ChangeLog	2018-08-06 08:46:30 UTC (rev 234593)
@@ -1,3 +1,30 @@
+2018-08-06  Zan Dobersek  <zdober...@igalia.com>
+
+        [Nicosia] Add Nicosia::Scene
+        https://bugs.webkit.org/show_bug.cgi?id=188340
+
+        Reviewed by Carlos Garcia Campos.
+
+        CompositingCoordinator spawns a Nicosia::Scene object that it shares
+        with the CoordinatedGraphicsSceneState instance. All the
+        Nicosia::CompositionLayer objects indirectly managed by
+        CompositingCoordinator are now stored in a local Nicosia::Scene::State
+        member object. Upon each flush that requires frame synchronization the
+        Nicosia::Scene object is updated in a thread-safe manner, increasing
+        the scene ID value as well as copying the local HashSet and root layer
+        values into the shared Scene object, allowing for the consumer (which
+        currently is the related CoordinatedGraphicsScene instance) to update
+        its output accordingly.
+
+        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
+        (WebKit::CompositingCoordinator::CompositingCoordinator):
+        (WebKit::CompositingCoordinator::flushPendingLayerChanges):
+        (WebKit::CompositingCoordinator::initializeRootCompositingLayerIfNeeded):
+        (WebKit::CompositingCoordinator::createGraphicsLayer):
+        (WebKit::CompositingCoordinator::detachLayer):
+        (WebKit::CompositingCoordinator::attachLayer):
+        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
+
 2018-08-05  Yusuke Suzuki  <utatane....@gmail.com>
 
         Add support for microtasks in workers

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp (234592 => 234593)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp	2018-08-06 08:25:34 UTC (rev 234592)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp	2018-08-06 08:46:30 UTC (rev 234593)
@@ -52,6 +52,8 @@
     , m_client(client)
     , m_paintingEngine(Nicosia::PaintingEngine::create())
 {
+    m_nicosia.scene = Nicosia::Scene::create();
+    m_state.nicosia.scene = m_nicosia.scene;
 }
 
 CompositingCoordinator::~CompositingCoordinator()
@@ -125,6 +127,14 @@
     if (m_shouldSyncFrame) {
         didSync = true;
 
+        m_state.nicosia.scene->accessState(
+            [this](Nicosia::Scene::State& state)
+            {
+                ++state.id;
+                state.layers = m_nicosia.state.layers;
+                state.rootLayer = m_nicosia.state.rootLayer;
+            });
+
         m_client.commitSceneState(m_state);
 
         clearPendingStateChanges();
@@ -172,7 +182,7 @@
         return;
 
     auto& rootLayer = downcast<CoordinatedGraphicsLayer>(*m_rootLayer);
-    m_state.nicosia.rootLayer = rootLayer.compositionLayer();
+    m_nicosia.state.rootLayer = rootLayer.compositionLayer();
     m_state.rootCompositingLayer = rootLayer.id();
     m_didInitializeRootCompositingLayer = true;
     m_shouldSyncFrame = true;
@@ -263,7 +273,7 @@
 {
     CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(layerType, client);
     layer->setCoordinator(this);
-    m_state.nicosia.layers.add(layer->compositionLayer());
+    m_nicosia.state.layers.add(layer->compositionLayer());
     m_registeredLayers.add(layer->id(), layer);
     m_state.layersToCreate.append(layer->id());
     layer->setNeedsVisibleRectAdjustment();
@@ -304,7 +314,7 @@
     if (m_isPurging)
         return;
 
-    m_state.nicosia.layers.remove(layer->compositionLayer());
+    m_nicosia.state.layers.remove(layer->compositionLayer());
     m_registeredLayers.remove(layer->id());
 
     size_t index = m_state.layersToCreate.find(layer->id());
@@ -320,7 +330,7 @@
 void CompositingCoordinator::attachLayer(CoordinatedGraphicsLayer* layer)
 {
     layer->setCoordinator(this);
-    m_state.nicosia.layers.add(layer->compositionLayer());
+    m_nicosia.state.layers.add(layer->compositionLayer());
     m_registeredLayers.add(layer->id(), layer);
     m_state.layersToCreate.append(layer->id());
     layer->setNeedsVisibleRectAdjustment();

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h (234592 => 234593)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h	2018-08-06 08:25:34 UTC (rev 234592)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h	2018-08-06 08:46:30 UTC (rev 234593)
@@ -128,6 +128,10 @@
     WebCore::GraphicsLayer* m_rootCompositingLayer { nullptr };
     WebCore::GraphicsLayer* m_overlayCompositingLayer { nullptr };
 
+    struct {
+        RefPtr<Nicosia::Scene> scene;
+        Nicosia::Scene::State state;
+    } m_nicosia;
     WebCore::CoordinatedGraphicsState m_state;
 
     HashMap<WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayer*> m_registeredLayers;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to