Title: [287967] trunk/Source
Revision
287967
Author
hironori.fu...@sony.com
Date
2022-01-12 18:17:09 -0800 (Wed, 12 Jan 2022)

Log Message

[WinCairo] Tiling scroll support
https://bugs.webkit.org/show_bug.cgi?id=233676

Reviewed by Don Olmstead.

Source/WebCore:

Added a new class TextureMapperSparseBackingStore that supports
partially tiling the layer and removing tiles outside of the
coverage rect.

* Headers.cmake:
* platform/TextureMapper.cmake:
* platform/graphics/texmap/TextureMapperSparseBackingStore.cpp: Added.
(WebCore::TextureMapperSparseBackingStore::TextureMapperSparseBackingStore):
(WebCore::TextureMapperSparseBackingStore::setSize):
(WebCore::TextureMapperSparseBackingStore::removeUncoveredTiles):
(WebCore::TextureMapperSparseBackingStore::adjustedTransformForRect):
(WebCore::TextureMapperSparseBackingStore::paintToTextureMapper):
(WebCore::TextureMapperSparseBackingStore::drawBorder):
(WebCore::TextureMapperSparseBackingStore::drawRepaintCounter):
(WebCore::TextureMapperSparseBackingStore::tileDimension const):
(WebCore::TextureMapperSparseBackingStore::updateContents):
* platform/graphics/texmap/TextureMapperSparseBackingStore.h: Added.

Source/WebKit:

Added a new class WCTiledBacking that implements TiledBacking.

Copied computeVisibleAndCoverageRect,
transformByApplyingAnchorPoint and layerTransform from
GraphicsLayerAC.

* GPUProcess/graphics/wc/WCScene.cpp:
(WebKit::WCScene::update):
* WebProcess/WebPage/wc/DrawingAreaWC.cpp:
(WebKit::DrawingAreaWC::DrawingAreaWC):
(WebKit::DrawingAreaWC::updatePreferences):
(WebKit::DrawingAreaWC::shouldUseTiledBackingForFrameView const):
(WebKit::DrawingAreaWC::setNeedsDisplayInRect):
(WebKit::DrawingAreaWC::scroll):
(WebKit::flushLayerImageBuffers):
(WebKit::DrawingAreaWC::sendUpdateAC):
(WebKit::DrawingAreaWC::RootLayerClient::RootLayerClient): Deleted.
(WebKit::DrawingAreaWC::RootLayerClient::paintContents): Deleted.
(WebKit::DrawingAreaWC::RootLayerClient::deviceScaleFactor const): Deleted.
* WebProcess/WebPage/wc/DrawingAreaWC.h:
* WebProcess/WebPage/wc/GraphicsLayerWC.cpp:
(WebKit::GraphicsLayerWC::GraphicsLayerWC):
(WebKit::GraphicsLayerWC::setNeedsDisplay):
(WebKit::GraphicsLayerWC::setNeedsDisplayInRect):
(WebKit::GraphicsLayerWC::setBackgroundColor):
(WebKit::GraphicsLayerWC::setDrawsContent):
(WebKit::GraphicsLayerWC::noteLayerPropertyChanged):
(WebKit::GraphicsLayerWC::flushCompositingState):
(WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly):
(WebKit::GraphicsLayerWC::tiledBacking const):
(WebKit::GraphicsLayerWC::createImageBuffer):
(WebKit::accumulatesTransform):
(WebKit::GraphicsLayerWC::transformByApplyingAnchorPoint const):
(WebKit::GraphicsLayerWC::layerTransform const):
(WebKit::GraphicsLayerWC::computeVisibleAndCoverageRect const):
(WebKit::GraphicsLayerWC::recursiveCommitChanges):
* WebProcess/WebPage/wc/GraphicsLayerWC.h:
* WebProcess/WebPage/wc/WCUpateInfo.h:
(WebKit::WCLayerUpateInfo::encode const):
(WebKit::WCLayerUpateInfo::decode):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287966 => 287967)


--- trunk/Source/WebCore/ChangeLog	2022-01-13 02:04:01 UTC (rev 287966)
+++ trunk/Source/WebCore/ChangeLog	2022-01-13 02:17:09 UTC (rev 287967)
@@ -1,3 +1,28 @@
+2022-01-12  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [WinCairo] Tiling scroll support
+        https://bugs.webkit.org/show_bug.cgi?id=233676
+
+        Reviewed by Don Olmstead.
+
+        Added a new class TextureMapperSparseBackingStore that supports
+        partially tiling the layer and removing tiles outside of the
+        coverage rect.
+
+        * Headers.cmake:
+        * platform/TextureMapper.cmake:
+        * platform/graphics/texmap/TextureMapperSparseBackingStore.cpp: Added.
+        (WebCore::TextureMapperSparseBackingStore::TextureMapperSparseBackingStore):
+        (WebCore::TextureMapperSparseBackingStore::setSize):
+        (WebCore::TextureMapperSparseBackingStore::removeUncoveredTiles):
+        (WebCore::TextureMapperSparseBackingStore::adjustedTransformForRect):
+        (WebCore::TextureMapperSparseBackingStore::paintToTextureMapper):
+        (WebCore::TextureMapperSparseBackingStore::drawBorder):
+        (WebCore::TextureMapperSparseBackingStore::drawRepaintCounter):
+        (WebCore::TextureMapperSparseBackingStore::tileDimension const):
+        (WebCore::TextureMapperSparseBackingStore::updateContents):
+        * platform/graphics/texmap/TextureMapperSparseBackingStore.h: Added.
+
 2022-01-12  Megan Gardner  <megan_gard...@apple.com>
 
         Add to Contact menu item does nothing on mac.

Modified: trunk/Source/WebCore/Headers.cmake (287966 => 287967)


--- trunk/Source/WebCore/Headers.cmake	2022-01-13 02:04:01 UTC (rev 287966)
+++ trunk/Source/WebCore/Headers.cmake	2022-01-13 02:17:09 UTC (rev 287967)
@@ -1645,6 +1645,7 @@
     platform/graphics/transforms/ScaleTransformOperation.h
     platform/graphics/transforms/TransformOperation.h
     platform/graphics/transforms/TransformOperations.h
+    platform/graphics/transforms/TransformState.h
     platform/graphics/transforms/TransformationMatrix.h
     platform/graphics/transforms/TranslateTransformOperation.h
 

Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (287966 => 287967)


--- trunk/Source/WebCore/platform/TextureMapper.cmake	2022-01-13 02:04:01 UTC (rev 287966)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake	2022-01-13 02:17:09 UTC (rev 287967)
@@ -129,3 +129,12 @@
         platform/graphics/nicosia/texmap/NicosiaGCGLANGLELayer.cpp
     )
 endif ()
+
+if (USE_GRAPHICS_LAYER_WC)
+    list(APPEND WebCore_SOURCES
+        platform/graphics/texmap/TextureMapperSparseBackingStore.cpp
+    )
+    list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
+        platform/graphics/texmap/TextureMapperSparseBackingStore.h
+    )
+endif ()

Added: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperSparseBackingStore.cpp (0 => 287967)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperSparseBackingStore.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperSparseBackingStore.cpp	2022-01-13 02:17:09 UTC (rev 287967)
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2022 Sony Interactive Entertainment Inc.
+ * 
+ * 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 "TextureMapperSparseBackingStore.h"
+
+#if USE(GRAPHICS_LAYER_WC)
+
+namespace WebCore {
+
+TextureMapperSparseBackingStore::TextureMapperSparseBackingStore(int tileSize)
+    : m_tileSize(tileSize)
+{
+}
+
+void TextureMapperSparseBackingStore::setSize(const IntSize& size)
+{
+    if (m_size == size)
+        return;
+    m_tiles.clear();
+    m_size = size;
+    auto tiles = tileDimension();
+    for (int y = 0; y < tiles.height(); y++) {
+        for (int x = 0; x < tiles.width(); x++) {
+            IntRect rect = { x * m_tileSize, y * m_tileSize, m_tileSize, m_tileSize };
+            rect.intersect({ { }, m_size });
+            m_tiles.append(TextureMapperTile(rect));
+        }
+    }
+}
+
+void TextureMapperSparseBackingStore::removeUncoveredTiles(const IntRect& coverage)
+{
+    auto minCoveredX = coverage.x() / m_tileSize;
+    auto maxCoveredX = (coverage.maxX() + m_tileSize - 1) / m_tileSize;
+    auto minCoveredY = coverage.y() / m_tileSize;
+    auto maxCoveredY = (coverage.maxY() + m_tileSize - 1) / m_tileSize;
+    auto tiles = tileDimension();
+    for (int y = 0; y < tiles.height(); y++) {
+        bool coveredY = minCoveredY <= y && y < maxCoveredY;
+        for (int x = 0; x < tiles.width(); x++) {
+            bool covered = coveredY && minCoveredX <= x && x < maxCoveredX;
+            if (!covered)
+                m_tiles[x + y * tiles.width()].setTexture(nullptr);
+        }
+    }
+}
+
+TransformationMatrix TextureMapperSparseBackingStore::adjustedTransformForRect(const FloatRect& targetRect)
+{
+    return TransformationMatrix::rectToRect({ { }, m_size }, targetRect);
+}
+
+void TextureMapperSparseBackingStore::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
+{
+    IntRect rect = { { }, m_size };
+    TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+    for (auto& tile : m_tiles)
+        tile.paint(textureMapper, adjustedTransform, opacity, calculateExposedTileEdges(rect, tile.rect()));
+}
+
+void TextureMapperSparseBackingStore::drawBorder(TextureMapper& textureMapper, const Color& borderColor, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)
+{
+    TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+    for (auto& tile : m_tiles)
+        textureMapper.drawBorder(borderColor, borderWidth, tile.rect(), adjustedTransform);
+}
+
+void TextureMapperSparseBackingStore::drawRepaintCounter(TextureMapper& textureMapper, int repaintCount, const Color& borderColor, const FloatRect& targetRect, const TransformationMatrix& transform)
+{
+    TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+    for (auto& tile : m_tiles)
+        textureMapper.drawNumber(repaintCount, borderColor, tile.rect().location(), adjustedTransform);
+}
+
+IntSize TextureMapperSparseBackingStore::tileDimension() const
+{
+    return { (m_size.width() + m_tileSize - 1) / m_tileSize,  (m_size.height() + m_tileSize - 1) / m_tileSize };
+}
+
+void TextureMapperSparseBackingStore::updateContents(TextureMapper& textureMapper, Image& image, const IntRect& dirtyRect)
+{
+    for (auto& tile : m_tiles)
+        tile.updateContents(textureMapper, &image, dirtyRect);
+}
+
+} // namespace WebCore
+
+#endif // USE(GRAPHICS_LAYER_WC)

Added: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperSparseBackingStore.h (0 => 287967)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperSparseBackingStore.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperSparseBackingStore.h	2022-01-13 02:17:09 UTC (rev 287967)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2022 Sony Interactive Entertainment Inc.
+ * 
+ * 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
+
+#if USE(GRAPHICS_LAYER_WC)
+
+#include "TextureMapperBackingStore.h"
+#include "TextureMapperTile.h"
+
+namespace WebCore {
+
+class TextureMapperSparseBackingStore final : public TextureMapperBackingStore {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    TextureMapperSparseBackingStore(int tileSize);
+    void setSize(const IntSize&);
+    void removeUncoveredTiles(const IntRect& coverage);
+    void paintToTextureMapper(TextureMapper&, const FloatRect&, const TransformationMatrix&, float) override;
+    void drawBorder(TextureMapper&, const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) override;
+    void drawRepaintCounter(TextureMapper&, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) override;
+    void updateContents(TextureMapper&, Image&, const IntRect& dirtyRect);
+
+private:
+    IntSize tileDimension() const;
+    TransformationMatrix adjustedTransformForRect(const FloatRect&);
+
+    int m_tileSize;
+    Vector<TextureMapperTile> m_tiles;
+    IntSize m_size;
+};
+
+} // namespace WebCore
+
+#endif // USE(GRAPHICS_LAYER_WC)

Modified: trunk/Source/WebKit/ChangeLog (287966 => 287967)


--- trunk/Source/WebKit/ChangeLog	2022-01-13 02:04:01 UTC (rev 287966)
+++ trunk/Source/WebKit/ChangeLog	2022-01-13 02:17:09 UTC (rev 287967)
@@ -1,3 +1,51 @@
+2022-01-12  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [WinCairo] Tiling scroll support
+        https://bugs.webkit.org/show_bug.cgi?id=233676
+
+        Reviewed by Don Olmstead.
+
+        Added a new class WCTiledBacking that implements TiledBacking.
+
+        Copied computeVisibleAndCoverageRect,
+        transformByApplyingAnchorPoint and layerTransform from
+        GraphicsLayerAC.
+
+        * GPUProcess/graphics/wc/WCScene.cpp:
+        (WebKit::WCScene::update):
+        * WebProcess/WebPage/wc/DrawingAreaWC.cpp:
+        (WebKit::DrawingAreaWC::DrawingAreaWC):
+        (WebKit::DrawingAreaWC::updatePreferences):
+        (WebKit::DrawingAreaWC::shouldUseTiledBackingForFrameView const):
+        (WebKit::DrawingAreaWC::setNeedsDisplayInRect):
+        (WebKit::DrawingAreaWC::scroll):
+        (WebKit::flushLayerImageBuffers):
+        (WebKit::DrawingAreaWC::sendUpdateAC):
+        (WebKit::DrawingAreaWC::RootLayerClient::RootLayerClient): Deleted.
+        (WebKit::DrawingAreaWC::RootLayerClient::paintContents): Deleted.
+        (WebKit::DrawingAreaWC::RootLayerClient::deviceScaleFactor const): Deleted.
+        * WebProcess/WebPage/wc/DrawingAreaWC.h:
+        * WebProcess/WebPage/wc/GraphicsLayerWC.cpp:
+        (WebKit::GraphicsLayerWC::GraphicsLayerWC):
+        (WebKit::GraphicsLayerWC::setNeedsDisplay):
+        (WebKit::GraphicsLayerWC::setNeedsDisplayInRect):
+        (WebKit::GraphicsLayerWC::setBackgroundColor):
+        (WebKit::GraphicsLayerWC::setDrawsContent):
+        (WebKit::GraphicsLayerWC::noteLayerPropertyChanged):
+        (WebKit::GraphicsLayerWC::flushCompositingState):
+        (WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly):
+        (WebKit::GraphicsLayerWC::tiledBacking const):
+        (WebKit::GraphicsLayerWC::createImageBuffer):
+        (WebKit::accumulatesTransform):
+        (WebKit::GraphicsLayerWC::transformByApplyingAnchorPoint const):
+        (WebKit::GraphicsLayerWC::layerTransform const):
+        (WebKit::GraphicsLayerWC::computeVisibleAndCoverageRect const):
+        (WebKit::GraphicsLayerWC::recursiveCommitChanges):
+        * WebProcess/WebPage/wc/GraphicsLayerWC.h:
+        * WebProcess/WebPage/wc/WCUpateInfo.h:
+        (WebKit::WCLayerUpateInfo::encode const):
+        (WebKit::WCLayerUpateInfo::decode):
+
 2022-01-12  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, reverting r287944.

Modified: trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp (287966 => 287967)


--- trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp	2022-01-13 02:04:01 UTC (rev 287966)
+++ trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp	2022-01-13 02:17:09 UTC (rev 287967)
@@ -36,7 +36,7 @@
 #include <WebCore/GraphicsContextGLOpenGL.h>
 #include <WebCore/TextureMapperLayer.h>
 #include <WebCore/TextureMapperPlatformLayer.h>
-#include <WebCore/TextureMapperTiledBackingStore.h>
+#include <WebCore/TextureMapperSparseBackingStore.h>
 
 namespace WebKit {
 
@@ -52,7 +52,7 @@
     }
 
     WebCore::TextureMapperLayer texmapLayer;
-    RefPtr<WebCore::TextureMapperTiledBackingStore> backingStore;
+    std::optional<WebCore::TextureMapperSparseBackingStore> backingStore;
     std::unique_ptr<WebCore::TextureMapperLayer> backdropLayer;
 };
 
@@ -122,16 +122,27 @@
             layer->texmapLayer.setBackfaceVisibility(layerUpdate.backfaceVisibility);
         if (layerUpdate.changes & WCLayerChange::MasksToBounds)
             layer->texmapLayer.setMasksToBounds(layerUpdate.masksToBounds);
-        if (layerUpdate.changes & WCLayerChange::BackingStore) {
-            auto bitmap = layerUpdate.backingStore.bitmap();
-            if (bitmap) {
-                layer->backingStore = WebCore::TextureMapperTiledBackingStore::create();
-                auto image = bitmap->createImage();
-                layer->backingStore->updateContents(*m_textureMapper, image.get(), bitmap->size(), { { }, bitmap->size() });
-                layer->texmapLayer.setBackingStore(layer->backingStore.get());
+        if (layerUpdate.changes & WCLayerChange::Background) {
+            if (layerUpdate.hasBackingStore) {
+                if (!layer->backingStore) {
+                    const int tileSize = 512;
+                    layer->backingStore.emplace<WebCore::TextureMapperSparseBackingStore>(tileSize);
+                    auto& backingStore = *layer->backingStore;
+                    layer->texmapLayer.setBackgroundColor({ });
+                    layer->texmapLayer.setBackingStore(&backingStore);
+                }
+                auto& backingStore = *layer->backingStore;
+                backingStore.setSize(WebCore::IntSize(layer->texmapLayer.size()));
+                backingStore.removeUncoveredTiles(layerUpdate.coverageRect);
+                auto bitmap = layerUpdate.backingStore.bitmap();
+                if (bitmap) {
+                    auto image = bitmap->createImage();
+                    backingStore.updateContents(*m_textureMapper, *image, layerUpdate.dirtyRect);
+                }
             } else {
+                layer->texmapLayer.setBackgroundColor(layerUpdate.backgroundColor);
                 layer->texmapLayer.setBackingStore(nullptr);
-                layer->backingStore = nullptr;
+                layer->backingStore = std::nullopt;
             }
         }
         if (layerUpdate.changes & WCLayerChange::SolidColor)
@@ -140,8 +151,6 @@
             layer->texmapLayer.setDebugVisuals(layerUpdate.showDebugBorder, layerUpdate.debugBorderColor, layerUpdate.debugBorderWidth);
         if (layerUpdate.changes & WCLayerChange::RepaintCount)
             layer->texmapLayer.setRepaintCounter(layerUpdate.showRepaintCounter, layerUpdate.repaintCount);
-        if (layerUpdate.changes & WCLayerChange::BackgroundColor)
-            layer->texmapLayer.setBackgroundColor(layerUpdate.backgroundColor);
         if (layerUpdate.changes & WCLayerChange::Opacity)
             layer->texmapLayer.setOpacity(layerUpdate.opacity);
         if (layerUpdate.changes & WCLayerChange::Transform)

Modified: trunk/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.cpp (287966 => 287967)


--- trunk/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.cpp	2022-01-13 02:04:01 UTC (rev 287966)
+++ trunk/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.cpp	2022-01-13 02:17:09 UTC (rev 287967)
@@ -31,6 +31,7 @@
 #include "PlatformImageBufferShareableBackend.h"
 #include "RemoteWCLayerTreeHostProxy.h"
 #include "UpdateInfo.h"
+#include "WebFrame.h"
 #include "WebPageCreationParameters.h"
 #include "WebProcess.h"
 #include <WebCore/ConcreteImageBuffer.h>
@@ -42,7 +43,6 @@
 
 DrawingAreaWC::DrawingAreaWC(WebPage& webPage, const WebPageCreationParameters& parameters)
     : DrawingArea(DrawingAreaType::WC, parameters.drawingAreaIdentifier, webPage)
-    , m_rootLayerClient(webPage)
     , m_remoteWCLayerTreeHostProxy(makeUnique<RemoteWCLayerTreeHostProxy>(webPage, *this))
     , m_layerFactory(*this)
     , m_rootLayer(GraphicsLayer::create(graphicsLayerFactory(), this->m_rootLayerClient))
@@ -50,10 +50,7 @@
     , m_commitQueue(WorkQueue::create("DrawingAreaWC CommitQueue"_s))
 {
     m_rootLayer->setName(MAKE_STATIC_STRING_IMPL("drawing area root"));
-    m_rootLayer->setDrawsContent(true);
-    m_rootLayer->setContentsOpaque(true);
     m_rootLayer->setSize(m_webPage.size());
-    m_rootLayer->setNeedsDisplay();
 }
 
 DrawingAreaWC::~DrawingAreaWC()
@@ -93,6 +90,17 @@
     updateRootLayers();
 }
 
+void DrawingAreaWC::updatePreferences(const WebPreferencesStore&)
+{
+    Settings& settings = m_webPage.corePage()->settings();
+    settings.setAcceleratedCompositingForFixedPositionEnabled(settings.acceleratedCompositingEnabled());
+}
+
+bool DrawingAreaWC::shouldUseTiledBackingForFrameView(const WebCore::FrameView& frameView) const
+{
+    return frameView.frame().isMainFrame();
+}
+
 void DrawingAreaWC::setLayerTreeStateIsFrozen(bool isFrozen)
 {
     if (m_isRenderingSuspended == isFrozen)
@@ -122,9 +130,8 @@
 void DrawingAreaWC::setNeedsDisplayInRect(const IntRect& rect)
 {
     if (isCompositingMode())
-        m_rootLayer->setNeedsDisplayInRect(rect);
-    else
-        m_dirtyRegion.unite(rect);
+        return;
+    m_dirtyRegion.unite(rect);
     triggerRenderingUpdate();
 }
 
@@ -131,32 +138,31 @@
 void DrawingAreaWC::scroll(const IntRect& scrollRect, const IntSize& scrollDelta)
 {
     if (isCompositingMode())
-        m_rootLayer->setNeedsDisplayInRect(scrollRect);
-    else {
-        if (scrollRect != m_scrollRect) {
-            // Just repaint the entire current scroll rect, we'll scroll the new rect instead.
-            setNeedsDisplayInRect(m_scrollRect);
-            m_scrollRect = { };
-            m_scrollOffset = { };
-        }
-        // Get the part of the dirty region that is in the scroll rect.
-        Region dirtyRegionInScrollRect = intersect(scrollRect, m_dirtyRegion);
-        if (!dirtyRegionInScrollRect.isEmpty()) {
-            // There are parts of the dirty region that are inside the scroll rect.
-            // We need to subtract them from the region, move them and re-add them.
-            m_dirtyRegion.subtract(scrollRect);
-            // Move the dirty parts.
-            Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect);
-            // And add them back.
-            m_dirtyRegion.unite(movedDirtyRegionInScrollRect);
-        }
-        // Compute the scroll repaint region.
-        Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta));
-        m_dirtyRegion.unite(scrollRepaintRegion);
-        m_scrollRect = scrollRect;
-        m_scrollOffset += scrollDelta;
-        triggerRenderingUpdate();
+        return;
+
+    if (scrollRect != m_scrollRect) {
+        // Just repaint the entire current scroll rect, we'll scroll the new rect instead.
+        setNeedsDisplayInRect(m_scrollRect);
+        m_scrollRect = { };
+        m_scrollOffset = { };
     }
+    // Get the part of the dirty region that is in the scroll rect.
+    Region dirtyRegionInScrollRect = intersect(scrollRect, m_dirtyRegion);
+    if (!dirtyRegionInScrollRect.isEmpty()) {
+        // There are parts of the dirty region that are inside the scroll rect.
+        // We need to subtract them from the region, move them and re-add them.
+        m_dirtyRegion.subtract(scrollRect);
+        // Move the dirty parts.
+        Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect);
+        // And add them back.
+        m_dirtyRegion.unite(movedDirtyRegionInScrollRect);
+    }
+    // Compute the scroll repaint region.
+    Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta));
+    m_dirtyRegion.unite(scrollRepaintRegion);
+    m_scrollRect = scrollRect;
+    m_scrollOffset += scrollDelta;
+    triggerRenderingUpdate();
 }
 
 void DrawingAreaWC::triggerRenderingUpdate()
@@ -173,7 +179,7 @@
 static void flushLayerImageBuffers(WCUpateInfo& info)
 {
     for (auto& layerInfo : info.changedLayers) {
-        if (layerInfo.changes & WCLayerChange::BackingStore) {
+        if (layerInfo.changes & WCLayerChange::Background) {
             if (auto image = layerInfo.backingStore.imageBuffer()) {
                 if (auto flusher = image->createFlusher())
                     flusher->flush();
@@ -220,8 +226,10 @@
     m_rootLayer->flushCompositingStateForThisLayerOnly();
 
     // Because our view-relative overlay root layer is not attached to the FrameView's GraphicsLayer tree, we need to flush it manually.
-    if (m_viewOverlayRootLayer)
-        m_viewOverlayRootLayer->flushCompositingState({ });
+    if (m_viewOverlayRootLayer) {
+        FloatRect visibleRect({ }, m_webPage.size());
+        m_viewOverlayRootLayer->flushCompositingState(visibleRect);
+    }
 
     m_updateInfo.rootLayer = m_rootLayer->primaryLayerID();
 
@@ -341,22 +349,4 @@
     }
 }
 
-DrawingAreaWC::RootLayerClient::RootLayerClient(WebPage& webPage)
-    : m_webPage(webPage)
-{
-}
-
-void DrawingAreaWC::RootLayerClient::paintContents(const GraphicsLayer*, GraphicsContext& context, const FloatRect& rectToPaint, GraphicsLayerPaintBehavior)
-{
-    context.save();
-    context.clip(rectToPaint);
-    m_webPage.corePage()->mainFrame().view()->paint(context, enclosingIntRect(rectToPaint));
-    context.restore();
-}
-
-float DrawingAreaWC::RootLayerClient::deviceScaleFactor() const
-{
-    return m_webPage.corePage()->deviceScaleFactor();
-}
-
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.h (287966 => 287967)


--- trunk/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.h	2022-01-13 02:04:01 UTC (rev 287966)
+++ trunk/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.h	2022-01-13 02:17:09 UTC (rev 287967)
@@ -57,6 +57,8 @@
     void updateGeometry(uint64_t, WebCore::IntSize) override;
     void setRootCompositingLayer(WebCore::GraphicsLayer*) override;
     void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) override;
+    void updatePreferences(const WebPreferencesStore&) override;
+    bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const override;
     // GraphicsLayerWC::Observer
     void graphicsLayerAdded(GraphicsLayerWC&) override;
     void graphicsLayerRemoved(GraphicsLayerWC&) override;
@@ -71,16 +73,7 @@
     void sendUpdateNonAC();
     void updateRootLayers();
 
-    class RootLayerClient : public WebCore::GraphicsLayerClient {
-    public:
-        RootLayerClient(WebPage&);
-    private:
-        void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::FloatRect& rectToPaint, WebCore::GraphicsLayerPaintBehavior) override;
-        float deviceScaleFactor() const override;
-        WebPage& m_webPage;
-    };
-
-    RootLayerClient m_rootLayerClient;
+    WebCore::GraphicsLayerClient m_rootLayerClient;
     std::unique_ptr<RemoteWCLayerTreeHostProxy> m_remoteWCLayerTreeHostProxy;
     WCLayerFactory m_layerFactory;
     DoublyLinkedList<GraphicsLayerWC> m_liveGraphicsLayers;

Modified: trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp (287966 => 287967)


--- trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp	2022-01-13 02:04:01 UTC (rev 287966)
+++ trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp	2022-01-13 02:17:09 UTC (rev 287967)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2010-2021 Apple Inc. All rights reserved.
  * Copyright (C) 2021 Sony Interactive Entertainment Inc.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,14 +28,124 @@
 #include "GraphicsLayerWC.h"
 
 #include "WCPlatformLayerGCGL.h"
+#include <WebCore/TransformState.h>
 
 namespace WebKit {
 using namespace WebCore;
 
+class WCTiledBacking final : public TiledBacking {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    WCTiledBacking(GraphicsLayerWC& owner)
+        : m_owner(owner) { }
+
+    bool paintAndFlush(WCLayerUpateInfo& update)
+    {
+        update.dirtyRect = enclosingIntRect(m_dirtyRect);
+        update.coverageRect = m_coverageRect;
+        m_dirtyRect = { };
+        auto& imageRect = update.dirtyRect;
+        if (imageRect.isEmpty())
+            return false;
+        auto image = m_owner.createImageBuffer(imageRect.size());
+        auto& context = image->context();
+        context.translate(-imageRect.x(), -imageRect.y());
+        m_owner.paintGraphicsLayerContents(context, update.dirtyRect);
+        image->flushDrawingContextAsync();
+        update.backingStore.setImageBuffer(WTFMove(image));
+        return true;
+    }
+
+    void setDirtyRect(const WebCore::FloatRect& rect)
+    {
+        m_dirtyRect.unite(rect);
+    }
+
+    bool hasDirtyRect()
+    {
+        return !m_dirtyRect.isEmpty();
+    }
+
+    TiledBacking* tiledBacking() const { return const_cast<WCTiledBacking*>(this); };
+
+    IntRect adjustCoverageRect(IntRect coverage)
+    {
+        int x = coverage.x() / tileSize().width() * tileSize().width();
+        int y = coverage.y() / tileSize().height() * tileSize().height();
+        int maxX = (coverage.maxX() + tileSize().width() - 1) / tileSize().width() * tileSize().width();
+        int maxY = (coverage.maxY() + tileSize().height() - 1) / tileSize().height() * tileSize().height();
+        IntRect newCoverage { x, y, maxX - x, maxY - y };
+        newCoverage.intersect(bounds());
+        return newCoverage;
+    }
+
+    // TiledBacking override
+    void setVisibleRect(const FloatRect&) final { }
+    FloatRect visibleRect() const final { return { }; };
+    void setLayoutViewportRect(std::optional<FloatRect>) final { }
+    void setCoverageRect(const FloatRect& rect) final
+    {
+        auto newCoverage = adjustCoverageRect(enclosingIntRect(rect));
+        WebCore::Region region(newCoverage);
+        region.subtract(m_coverageRect);
+        setDirtyRect(region.bounds());
+        m_coverageRect = newCoverage;
+        m_dirtyRect.intersect(m_coverageRect);
+    }
+    FloatRect coverageRect() const final { return { }; };
+    bool tilesWouldChangeForCoverageRect(const FloatRect&) const final { return false; }
+    void setTiledScrollingIndicatorPosition(const FloatPoint&) final { }
+    void setTopContentInset(float) final { }
+    void setVelocity(const VelocityData&) final { }
+    void setTileSizeUpdateDelayDisabledForTesting(bool) final { };
+    void setScrollability(Scrollability) final { }
+    void prepopulateRect(const FloatRect&) final { }
+    void setIsInWindow(bool) final { }
+    bool isInWindow() const final { return m_isInWindow; }
+    void setTileCoverage(TileCoverage) final { }
+    TileCoverage tileCoverage() const final { return { }; };
+    FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) final { return { }; };
+    FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) final { return { }; };
+    void willStartLiveResize() final { };
+    void didEndLiveResize() final { };
+    IntSize tileSize() const final { return { 512, 512 }; };
+    void revalidateTiles() final { }
+    void forceRepaint() final { }
+    IntRect tileGridExtent() const final { return { }; }
+    void setScrollingPerformanceTestingEnabled(bool flag) final { }
+    bool scrollingPerformanceTestingEnabled() const final { return false; };
+    double retainedTileBackingStoreMemory() const final { return 0; }
+    IntRect tileCoverageRect() const final { return { }; }
+    void setScrollingModeIndication(ScrollingModeIndication) final { }
+    void setHasMargins(bool marginTop, bool marginBottom, bool marginLeft, bool marginRight) final { }
+    bool hasMargins() const final { return false; };
+    bool hasHorizontalMargins() const final { return false; };
+    bool hasVerticalMargins() const final { return false; };
+    void setMarginSize(int) final { }
+    int topMarginHeight() const final { return 0; };
+    int bottomMarginHeight() const final { return 0; };
+    int leftMarginWidth() const final { return 0; };
+    int rightMarginWidth() const final { return 0; };
+    void setZoomedOutContentsScale(float) final { }
+    float zoomedOutContentsScale() const final { return 1; }
+    IntRect bounds() const final { return { { }, IntSize(m_owner.size()) }; };
+    IntRect boundsWithoutMargin() const final { return bounds(); };
+
+private:
+    bool m_isInWindow { false };
+    WebCore::IntRect m_coverageRect;
+    WebCore::FloatRect m_dirtyRect;
+    GraphicsLayerWC& m_owner;
+};
+
+
 GraphicsLayerWC::GraphicsLayerWC(Type layerType, GraphicsLayerClient& client, Observer& observer)
     : GraphicsLayer(layerType, client)
     , m_observer(&observer)
 {
+    m_tiledBacking = makeUnique<WCTiledBacking>(*this);
+    if (layerType == Type::Normal)
+        client.tiledBackingUsageChanged(this, true);
     m_observer->graphicsLayerAdded(*this);
 }
 
@@ -59,17 +170,16 @@
 
 void GraphicsLayerWC::setNeedsDisplay()
 {
-    if (!drawsContent())
-        return;
-    noteLayerPropertyChanged(WCLayerChange::BackingStore);
-    addRepaintRect({ { }, m_size });
+    setNeedsDisplayInRect({ { }, m_size }, ClipToLayer);
 }
 
-void GraphicsLayerWC::setNeedsDisplayInRect(const WebCore::FloatRect& rect, ShouldClipToLayer)
+void GraphicsLayerWC::setNeedsDisplayInRect(const WebCore::FloatRect& rect, ShouldClipToLayer shouldClip)
 {
     if (!drawsContent())
         return;
-    noteLayerPropertyChanged(WCLayerChange::BackingStore);
+
+    m_tiledBacking->setDirtyRect(rect);
+    noteLayerPropertyChanged(WCLayerChange::Background);
     addRepaintRect(rect);
 }
 
@@ -221,7 +331,7 @@
     if (value == backgroundColor())
         return;
     GraphicsLayer::setBackgroundColor(value);
-    noteLayerPropertyChanged(WCLayerChange::BackgroundColor);
+    noteLayerPropertyChanged(WCLayerChange::Background);
 }
 
 void GraphicsLayerWC::setOpacity(float value)
@@ -253,7 +363,7 @@
     if (value == drawsContent())
         return;
     GraphicsLayer::setDrawsContent(value);
-    noteLayerPropertyChanged(WCLayerChange::BackingStore);
+    noteLayerPropertyChanged(WCLayerChange::Background);
     updateDebugIndicators();
 }
 
@@ -374,25 +484,24 @@
     noteLayerPropertyChanged(WCLayerChange::BackdropFilters);
 }
 
-void GraphicsLayerWC::noteLayerPropertyChanged(OptionSet<WCLayerChange> flags)
+void GraphicsLayerWC::noteLayerPropertyChanged(OptionSet<WCLayerChange> flags, ScheduleFlushOrNot scheduleFlush)
 {
     if (beingDestroyed())
         return;
     bool needsFlush = !m_uncommittedChanges;
     m_uncommittedChanges.add(flags);
-    if (needsFlush)
+    if (needsFlush && scheduleFlush == ScheduleFlush)
         client().notifyFlushRequired(this);
 }
 
-void GraphicsLayerWC::flushCompositingState(const FloatRect& rect)
+void GraphicsLayerWC::flushCompositingState(const FloatRect& passedVisibleRect)
 {
-    if (auto* mask = maskLayer())
-        mask->flushCompositingStateForThisLayerOnly();
-    if (auto* replica = replicaLayer())
-        replica->flushCompositingStateForThisLayerOnly();
-    flushCompositingStateForThisLayerOnly();
-    for (auto& child : children())
-        child->flushCompositingState(rect);
+    // passedVisibleRect doesn't contain the scrollbar area. Inflate it.
+    FloatRect visibleRect = passedVisibleRect;
+    visibleRect.inflate(20.f);
+    TransformState state(TransformState::UnapplyInverseTransformDirection, FloatQuad(visibleRect));
+    state.setSecondaryQuad(FloatQuad { visibleRect });
+    recursiveCommitChanges(state);
 }
 
 void GraphicsLayerWC::flushCompositingStateForThisLayerOnly()
@@ -437,17 +546,16 @@
         update.backfaceVisibility = backfaceVisibility();
     if (update.changes & WCLayerChange::MasksToBounds)
         update.masksToBounds = masksToBounds();
-    if (update.changes & WCLayerChange::BackingStore) {
-        if (drawsContent() && contentsAreVisible() && !size().isEmpty()) {
-            auto image = m_observer->createImageBuffer(size());
-            FloatRect clipRect = { { }, size() };
-            paintGraphicsLayerContents(image->context(), clipRect);
-            image->flushDrawingContextAsync();
-            update.backingStore.setImageBuffer(WTFMove(image));
-
-            incrementRepaintCount();
-            update.changes.add(WCLayerChange::RepaintCount);
-        }
+    if (update.changes & WCLayerChange::Background) {
+        update.backgroundColor = backgroundColor();
+        if (drawsContent() && contentsAreVisible()) {
+            update.hasBackingStore = true;
+            if (m_tiledBacking->paintAndFlush(update)) {
+                incrementRepaintCount();
+                update.changes.add(WCLayerChange::RepaintCount);
+            }
+        } else
+            update.hasBackingStore = false;
     }
     if (update.changes & WCLayerChange::SolidColor)
         update.solidColor = m_solidColor;
@@ -460,8 +568,6 @@
         update.showRepaintCounter = isShowingRepaintCounter();
         update.repaintCount = repaintCount();
     }
-    if (update.changes & WCLayerChange::BackgroundColor)
-        update.backgroundColor = backgroundColor();
     if (update.changes & WCLayerChange::Opacity)
         update.opacity = opacity();
     if (update.changes & WCLayerChange::Transform)
@@ -482,4 +588,124 @@
     m_observer->commitLayerUpateInfo(WTFMove(update));
 }
 
+TiledBacking* GraphicsLayerWC::tiledBacking() const
+{
+    return m_tiledBacking->tiledBacking();
+}
+
+RefPtr<WebCore::ImageBuffer> GraphicsLayerWC::createImageBuffer(WebCore::FloatSize size)
+{
+    return m_observer->createImageBuffer(size);
+}
+
+static inline bool accumulatesTransform(const GraphicsLayerWC& layer)
+{
+    return !layer.masksToBounds() && (layer.preserves3D() || (layer.parent() && layer.parent()->preserves3D()));
+}
+
+TransformationMatrix GraphicsLayerWC::transformByApplyingAnchorPoint(const TransformationMatrix& matrix) const
+{
+    if (matrix.isIdentity())
+        return matrix;
+
+    TransformationMatrix result;
+    FloatPoint3D absoluteAnchorPoint(anchorPoint());
+    absoluteAnchorPoint.scale(size().width(), size().height(), 1);
+    result.translate3d(absoluteAnchorPoint.x(), absoluteAnchorPoint.y(), absoluteAnchorPoint.z());
+    result.multiply(matrix);
+    result.translate3d(-absoluteAnchorPoint.x(), -absoluteAnchorPoint.y(), -absoluteAnchorPoint.z());
+    return result;
+}
+
+TransformationMatrix GraphicsLayerWC::layerTransform(const FloatPoint& position, const TransformationMatrix* customTransform) const
+{
+    TransformationMatrix transform;
+    transform.translate(position.x(), position.y());
+
+    TransformationMatrix currentTransform;
+    if (customTransform)
+        currentTransform = *customTransform;
+    else if (m_transform)
+        currentTransform = *m_transform;
+
+    transform.multiply(transformByApplyingAnchorPoint(currentTransform));
+
+    if (GraphicsLayer* parentLayer = parent()) {
+        if (parentLayer->hasNonIdentityChildrenTransform()) {
+            FloatPoint boundsOrigin = parentLayer->boundsOrigin();
+
+            FloatPoint3D parentAnchorPoint(parentLayer->anchorPoint());
+            parentAnchorPoint.scale(parentLayer->size().width(), parentLayer->size().height(), 1);
+            parentAnchorPoint += boundsOrigin;
+
+            transform.translateRight3d(-parentAnchorPoint.x(), -parentAnchorPoint.y(), -parentAnchorPoint.z());
+            transform = parentLayer->childrenTransform() * transform;
+            transform.translateRight3d(parentAnchorPoint.x(), parentAnchorPoint.y(), parentAnchorPoint.z());
+        }
+    }
+
+    return transform;
+}
+
+GraphicsLayerWC::VisibleAndCoverageRects GraphicsLayerWC::computeVisibleAndCoverageRect(TransformState& state, bool preserves3D) const
+{
+    FloatPoint position = approximatePosition();
+    client().customPositionForVisibleRectComputation(this, position);
+
+    TransformationMatrix layerTransform;
+    TransformationMatrix currentTransform;
+    if (client().getCurrentTransform(this, currentTransform))
+        layerTransform = this->layerTransform(position, &currentTransform);
+    else
+        layerTransform = this->layerTransform(position);
+
+    bool applyWasClamped;
+    TransformState::TransformAccumulation accumulation = preserves3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
+    state.applyTransform(layerTransform, accumulation, &applyWasClamped);
+
+    bool mapWasClamped;
+    FloatRect clipRectForChildren = state.mappedQuad(&mapWasClamped).boundingBox();
+    FloatPoint boundsOrigin = m_boundsOrigin;
+    clipRectForChildren.move(boundsOrigin.x(), boundsOrigin.y());
+    
+    FloatRect clipRectForSelf(boundsOrigin, m_size);
+    if (!applyWasClamped && !mapWasClamped)
+        clipRectForSelf.intersect(clipRectForChildren);
+
+    if (masksToBounds()) {
+        ASSERT(accumulation == TransformState::FlattenTransform);
+        // Flatten, and replace the quad in the TransformState with one that is clipped to this layer's bounds.
+        state.flatten();
+        state.setQuad(clipRectForSelf);
+        if (state.isMappingSecondaryQuad())
+            state.setSecondaryQuad(FloatQuad { clipRectForSelf });
+    }
+
+    FloatRect coverageRect = clipRectForSelf;
+    auto quad = state.mappedSecondaryQuad(&mapWasClamped);
+    if (quad && !mapWasClamped && !applyWasClamped)
+        coverageRect = (*quad).boundingBox();
+
+    return { clipRectForSelf, coverageRect, currentTransform };
+}
+
+void GraphicsLayerWC::recursiveCommitChanges(const TransformState& state)
+{
+    TransformState localState = state;
+
+    bool accumulateTransform = accumulatesTransform(*this);
+    VisibleAndCoverageRects rects = computeVisibleAndCoverageRect(localState, accumulateTransform);
+    m_tiledBacking->setCoverageRect(rects.coverageRect);
+    if (m_tiledBacking->hasDirtyRect())
+        noteLayerPropertyChanged(WCLayerChange::Background, DontScheduleFlush);
+
+    flushCompositingStateForThisLayerOnly();
+    if (auto* mask = maskLayer())
+        static_cast<GraphicsLayerWC*>(mask)->recursiveCommitChanges(localState);
+    if (auto* replica = replicaLayer())
+        static_cast<GraphicsLayerWC*>(replica)->recursiveCommitChanges(localState);
+    for (auto& child : children())
+        static_cast<GraphicsLayerWC*>(child.ptr())->recursiveCommitChanges(localState);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h (287966 => 287967)


--- trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h	2022-01-13 02:04:01 UTC (rev 287966)
+++ trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h	2022-01-13 02:17:09 UTC (rev 287967)
@@ -29,7 +29,12 @@
 #include <WebCore/GraphicsLayerContentsDisplayDelegate.h>
 #include <wtf/DoublyLinkedList.h>
 
+namespace WebCore {
+class TransformState;
+}
+
 namespace WebKit {
+class WCTiledBacking;
 
 class GraphicsLayerWC final : public WebCore::GraphicsLayer, public DoublyLinkedListNode<GraphicsLayerWC> {
 public:
@@ -88,10 +93,28 @@
     void setBackdropFiltersRect(const WebCore::FloatRoundedRect&) override;
     void flushCompositingState(const WebCore::FloatRect& clipRect) override;
     void flushCompositingStateForThisLayerOnly() override;
+    WebCore::TiledBacking* tiledBacking() const override;
 
+protected:
+    friend WCTiledBacking;
+
+    RefPtr<WebCore::ImageBuffer> createImageBuffer(WebCore::FloatSize);
+    
 private:
-    void noteLayerPropertyChanged(OptionSet<WCLayerChange>);
+    struct VisibleAndCoverageRects {
+        WTF_MAKE_STRUCT_FAST_ALLOCATED;
+        WebCore::FloatRect visibleRect;
+        WebCore::FloatRect coverageRect;
+        WebCore::TransformationMatrix animatingTransform;
+    };
 
+    enum ScheduleFlushOrNot { ScheduleFlush, DontScheduleFlush };
+    void noteLayerPropertyChanged(OptionSet<WCLayerChange>, ScheduleFlushOrNot = ScheduleFlush);
+    WebCore::TransformationMatrix transformByApplyingAnchorPoint(const WebCore::TransformationMatrix&) const;
+    WebCore::TransformationMatrix layerTransform(const WebCore::FloatPoint&, const WebCore::TransformationMatrix* = nullptr) const;
+    VisibleAndCoverageRects computeVisibleAndCoverageRect(WebCore::TransformState&, bool preserves3D) const;
+    void recursiveCommitChanges(const WebCore::TransformState&);
+
     static GraphicsLayer::PlatformLayerID generateLayerID();
 
     friend class WTF::DoublyLinkedListNode<GraphicsLayerWC>;
@@ -100,6 +123,7 @@
     GraphicsLayerWC* m_next;
     WebCore::GraphicsLayer::PlatformLayerID m_layerID { generateLayerID() };
     Observer* m_observer;
+    std::unique_ptr<WCTiledBacking> m_tiledBacking;
     PlatformLayer* m_platformLayer { nullptr };
     WebCore::Color m_solidColor;
     WebCore::Color m_debugBorderColor;

Modified: trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h (287966 => 287967)


--- trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h	2022-01-13 02:04:01 UTC (rev 287966)
+++ trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h	2022-01-13 02:17:09 UTC (rev 287967)
@@ -50,13 +50,12 @@
     ContentsRect            = 1 << 11,
     ContentsClippingRect    = 1 << 12,
     Opacity                 = 1 << 13,
-    BackingStore            = 1 << 14,
+    Background              = 1 << 14,
     Transform               = 1 << 15,
     ChildrenTransform       = 1 << 16,
     Filters                 = 1 << 17,
     BackdropFilters         = 1 << 18,
     PlatformLayer           = 1 << 19,
-    BackgroundColor         = 1 << 20,
 };
 
 struct WCLayerUpateInfo {
@@ -76,6 +75,7 @@
     bool backfaceVisibility;
     bool preserves3D;
     bool hasPlatformLayer;
+    bool hasBackingStore;
     WebCore::Color solidColor;
     WebCore::Color backgroundColor;
     WebCore::Color debugBorderColor;
@@ -84,6 +84,8 @@
     int repaintCount;
     WebCore::FloatRect contentsRect;
     WCBackingStore backingStore;
+    WebCore::IntRect dirtyRect;
+    WebCore::IntRect coverageRect;
     WebCore::TransformationMatrix transform;
     WebCore::TransformationMatrix childrenTransform;
     WebCore::FilterOperations filters;
@@ -123,12 +125,10 @@
             encoder << contentsRect;
         if (changes & WCLayerChange::ContentsClippingRect)
             encoder << contentsClippingRect;
-        if (changes & WCLayerChange::BackgroundColor)
-            encoder << backgroundColor;
         if (changes & WCLayerChange::Opacity)
             encoder << opacity;
-        if (changes & WCLayerChange::BackingStore)
-            encoder << backingStore;
+        if (changes & WCLayerChange::Background)
+            encoder << backgroundColor << hasBackingStore << backingStore << dirtyRect << coverageRect;
         if (changes & WCLayerChange::Transform)
             encoder << transform;
         if (changes & WCLayerChange::ChildrenTransform)
@@ -212,17 +212,21 @@
             if (!decoder.decode(result.contentsClippingRect))
                 return false;
         }
-        if (result.changes & WCLayerChange::BackgroundColor) {
-            if (!decoder.decode(result.backgroundColor))
-                return false;
-        }
         if (result.changes & WCLayerChange::Opacity) {
             if (!decoder.decode(result.opacity))
                 return false;
         }
-        if (result.changes & WCLayerChange::BackingStore) {
+        if (result.changes & WCLayerChange::Background) {
+            if (!decoder.decode(result.backgroundColor))
+                return false;
+            if (!decoder.decode(result.hasBackingStore))
+                return false;
             if (!decoder.decode(result.backingStore))
                 return false;
+            if (!decoder.decode(result.dirtyRect))
+                return false;
+            if (!decoder.decode(result.coverageRect))
+                return false;
         }
         if (result.changes & WCLayerChange::Transform) {
             if (!decoder.decode(result.transform))
@@ -303,13 +307,12 @@
         WebKit::WCLayerChange::ContentsRect,
         WebKit::WCLayerChange::ContentsClippingRect,
         WebKit::WCLayerChange::Opacity,
-        WebKit::WCLayerChange::BackingStore,
+        WebKit::WCLayerChange::Background,
         WebKit::WCLayerChange::Transform,
         WebKit::WCLayerChange::ChildrenTransform,
         WebKit::WCLayerChange::Filters,
         WebKit::WCLayerChange::BackdropFilters,
-        WebKit::WCLayerChange::PlatformLayer,
-        WebKit::WCLayerChange::BackgroundColor
+        WebKit::WCLayerChange::PlatformLayer
     >;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to