Title: [286046] trunk/Source
Revision
286046
Author
[email protected]
Date
2021-11-18 22:26:43 -0800 (Thu, 18 Nov 2021)

Log Message

[TextureMapper][GraphicsLayerTextureMapper][GraphicsLayerWC] setBackgroundColor support
https://bugs.webkit.org/show_bug.cgi?id=233244

Reviewed by Don Olmstead.

Source/WebCore:

TextureMapper, GraphicsLayerTextureMapper and GraphicsLayerWC
didn't support setBackgroundColor. setBackgroundColor is used for
"painting flush" feature of Web Inspector Elements tab.

Added a new class TextureMapperSolidColorLayer to draw a solid
layer for the primary layer and contents layer.

* platform/TextureMapper.cmake:
* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::setBackgroundColor): Added.
(WebCore::GraphicsLayerTextureMapper::setContentsToSolidColor):
(WebCore::GraphicsLayerTextureMapper::commitLayerChanges):
* platform/graphics/texmap/GraphicsLayerTextureMapper.h:
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::paintSelf):
(WebCore::TextureMapperLayer::setBackgroundColor):
(WebCore::blendWithOpacity): Deleted.
* platform/graphics/texmap/TextureMapperLayer.h:
* platform/graphics/texmap/TextureMapperSolidColorLayer.h: Added.
(WebCore::TextureMapperSolidColorLayer::setColor):

Source/WebKit:

* GPUProcess/graphics/wc/WCScene.cpp:
(WebKit::WCScene::update):
* WebProcess/WebPage/wc/GraphicsLayerWC.cpp:
(WebKit::GraphicsLayerWC::setBackgroundColor):
(WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly):
* 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 (286045 => 286046)


--- trunk/Source/WebCore/ChangeLog	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebCore/ChangeLog	2021-11-19 06:26:43 UTC (rev 286046)
@@ -1,3 +1,31 @@
+2021-11-18  Fujii Hironori  <[email protected]>
+
+        [TextureMapper][GraphicsLayerTextureMapper][GraphicsLayerWC] setBackgroundColor support
+        https://bugs.webkit.org/show_bug.cgi?id=233244
+
+        Reviewed by Don Olmstead.
+
+        TextureMapper, GraphicsLayerTextureMapper and GraphicsLayerWC
+        didn't support setBackgroundColor. setBackgroundColor is used for
+        "painting flush" feature of Web Inspector Elements tab.
+
+        Added a new class TextureMapperSolidColorLayer to draw a solid
+        layer for the primary layer and contents layer.
+
+        * platform/TextureMapper.cmake:
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore::GraphicsLayerTextureMapper::setBackgroundColor): Added.
+        (WebCore::GraphicsLayerTextureMapper::setContentsToSolidColor):
+        (WebCore::GraphicsLayerTextureMapper::commitLayerChanges):
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::paintSelf):
+        (WebCore::TextureMapperLayer::setBackgroundColor):
+        (WebCore::blendWithOpacity): Deleted.
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        * platform/graphics/texmap/TextureMapperSolidColorLayer.h: Added.
+        (WebCore::TextureMapperSolidColorLayer::setColor):
+
 2021-11-18  Ben Nham  <[email protected]>
 
         Add support for onpushsubscriptionchange event handler

Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (286045 => 286046)


--- trunk/Source/WebCore/platform/TextureMapper.cmake	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake	2021-11-19 06:26:43 UTC (rev 286046)
@@ -35,6 +35,7 @@
     platform/graphics/texmap/TextureMapperPlatformLayer.h
     platform/graphics/texmap/TextureMapperPlatformLayerProxy.h
     platform/graphics/texmap/TextureMapperPlatformLayerProxyProvider.h
+    platform/graphics/texmap/TextureMapperSolidColorLayer.h
     platform/graphics/texmap/TextureMapperTile.h
     platform/graphics/texmap/TextureMapperTiledBackingStore.h
 )

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (286045 => 286046)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2021-11-19 06:26:43 UTC (rev 286046)
@@ -255,6 +255,14 @@
     notifyChange(BackfaceVisibilityChange);
 }
 
+void GraphicsLayerTextureMapper::setBackgroundColor(const Color& value)
+{
+    if (value == backgroundColor())
+        return;
+    GraphicsLayer::setBackgroundColor(value);
+    notifyChange(BackgroundColorChange);
+}
+
 void GraphicsLayerTextureMapper::setOpacity(float value)
 {
     if (value == opacity())
@@ -286,7 +294,7 @@
         return;
 
     m_solidColor = color;
-    notifyChange(BackgroundColorChange);
+    notifyChange(SolidColorChange);
 }
 
 void GraphicsLayerTextureMapper::setContentsToImage(Image* image)
@@ -475,10 +483,13 @@
     if (m_changeMask & BackfaceVisibilityChange)
         m_layer.setBackfaceVisibility(backfaceVisibility());
 
+    if (m_changeMask & BackgroundColorChange)
+        m_layer.setBackgroundColor(backgroundColor());
+
     if (m_changeMask & OpacityChange)
         m_layer.setOpacity(opacity());
 
-    if (m_changeMask & BackgroundColorChange)
+    if (m_changeMask & SolidColorChange)
         m_layer.setSolidColor(m_solidColor);
 
     if (m_changeMask & FilterChange)

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h (286045 => 286046)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h	2021-11-19 06:26:43 UTC (rev 286046)
@@ -59,6 +59,7 @@
     void setContentsVisible(bool) override;
     void setContentsOpaque(bool) override;
     void setBackfaceVisibility(bool) override;
+    void setBackgroundColor(const Color&) override;
     void setOpacity(float) override;
     bool setFilters(const FilterOperations&) override;
     bool setBackdropFilters(const FilterOperations&) override;
@@ -149,6 +150,7 @@
 
         AnimationStarted =          (1L << 26),
         BackdropLayerChange =       (1L << 27),
+        SolidColorChange =          (1L << 28),
     };
     void notifyChange(ChangeMask);
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (286045 => 286046)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2021-11-19 06:26:43 UTC (rev 286046)
@@ -144,18 +144,13 @@
     paintRecursive(options);
 }
 
-static Color blendWithOpacity(const Color& color, float opacity)
-{
-    if (color.isOpaque() && opacity == 1.)
-        return color;
-
-    return color.colorWithAlphaMultipliedBy(opacity);
-}
-
 void TextureMapperLayer::paintSelf(TextureMapperPaintOptions& options)
 {
     if (!m_state.visible || !m_state.contentsVisible)
         return;
+    auto targetRect = layerRect();
+    if (targetRect.isEmpty())
+        return;
 
     // We apply the following transform to compensate for painting into a surface, and then apply the offset so that the painting fits in the target rect.
     TransformationMatrix transform;
@@ -163,28 +158,31 @@
     transform.multiply(options.transform);
     transform.multiply(m_layerTransforms.combined);
 
-    if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() && m_state.solidColor.isVisible()) {
-        options.textureMapper.drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, options.opacity), true);
-        if (m_state.showDebugBorders)
-            options.textureMapper.drawBorder(m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
-        return;
+    TextureMapperSolidColorLayer solidColorLayer;
+    TextureMapperBackingStore* backingStore = m_backingStore;
+    if (m_state.backgroundColor.isValid()) {
+        solidColorLayer.setColor(m_state.backgroundColor);
+        backingStore = &solidColorLayer;
     }
 
     options.textureMapper.setWrapMode(TextureMapper::StretchWrap);
     options.textureMapper.setPatternTransform(TransformationMatrix());
 
-    if (m_backingStore) {
-        FloatRect targetRect = layerRect();
-        ASSERT(!targetRect.isEmpty());
-        m_backingStore->paintToTextureMapper(options.textureMapper, targetRect, transform, options.opacity);
+    if (backingStore) {
+        backingStore->paintToTextureMapper(options.textureMapper, targetRect, transform, options.opacity);
         if (m_state.showDebugBorders)
-            m_backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, targetRect, transform);
+            backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, targetRect, transform);
         // Only draw repaint count for the main backing store.
         if (m_state.showRepaintCounter)
-            m_backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, targetRect, transform);
+            backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, targetRect, transform);
     }
 
-    if (!m_contentsLayer)
+    TextureMapperPlatformLayer* contentsLayer = m_contentsLayer;
+    if (m_state.solidColor.isValid() && m_state.solidColor.isVisible()) {
+        solidColorLayer.setColor(m_state.solidColor);
+        contentsLayer = &solidColorLayer;
+    }
+    if (!contentsLayer)
         return;
 
     if (!m_state.contentsTileSize.isEmpty()) {
@@ -195,20 +193,18 @@
         options.textureMapper.setPatternTransform(patternTransform);
     }
 
-    ASSERT(!layerRect().isEmpty());
-
     bool shouldClip = m_state.contentsClippingRect.isRounded() || !m_state.contentsClippingRect.rect().contains(m_state.contentsRect);
     if (shouldClip) {
         options.textureMapper.beginClip(transform, m_state.contentsClippingRect);
     }
 
-    m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity);
+    contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity);
 
     if (shouldClip)
         options.textureMapper.endClip();
 
     if (m_state.showDebugBorders)
-        m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
+        contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
 }
 
 void TextureMapperLayer::sortByZOrder(Vector<TextureMapperLayer* >& array)
@@ -679,6 +675,11 @@
     m_state.solidColor = color;
 }
 
+void TextureMapperLayer::setBackgroundColor(const Color& color)
+{
+    m_state.backgroundColor = color;
+}
+
 void TextureMapperLayer::setFilters(const FilterOperations& filters)
 {
     m_state.filters = filters;

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h (286045 => 286046)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2021-11-19 06:26:43 UTC (rev 286046)
@@ -23,7 +23,7 @@
 #include "FloatRect.h"
 #include "NicosiaAnimation.h"
 #include "TextureMapper.h"
-#include "TextureMapperBackingStore.h"
+#include "TextureMapperSolidColorLayer.h"
 #include <wtf/WeakPtr.h>
 
 #if USE(COORDINATED_GRAPHICS)
@@ -77,6 +77,7 @@
     void setBackfaceVisibility(bool);
     void setOpacity(float);
     void setSolidColor(const Color&);
+    void setBackgroundColor(const Color&);
     void setContentsTileSize(const FloatSize&);
     void setContentsTilePhase(const FloatSize&);
     void setContentsClippingRect(const FloatRoundedRect&);
@@ -178,6 +179,7 @@
         WeakPtr<TextureMapperLayer> backdropLayer;
         FloatRoundedRect backdropFiltersRect;
         Color solidColor;
+        Color backgroundColor;
         FilterOperations filters;
         Color debugBorderColor;
         float debugBorderWidth;

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


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperSolidColorLayer.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperSolidColorLayer.h	2021-11-19 06:26:43 UTC (rev 286046)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2021 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "TextureMapperBackingStore.h"
+
+namespace WebCore {
+
+class TextureMapperSolidColorLayer : public TextureMapperBackingStore {
+public:
+    void setColor(Color color) { m_color = color; }
+
+    void paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity) override
+    {
+        textureMapper.drawSolidColor(targetRect, transform, m_color.colorWithAlphaMultipliedBy(opacity), true);
+    }
+
+private:
+    Color m_color;
+};
+
+} // namespace WebCore

Modified: trunk/Source/WebKit/ChangeLog (286045 => 286046)


--- trunk/Source/WebKit/ChangeLog	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebKit/ChangeLog	2021-11-19 06:26:43 UTC (rev 286046)
@@ -1,3 +1,20 @@
+2021-11-18  Fujii Hironori  <[email protected]>
+
+        [TextureMapper][GraphicsLayerTextureMapper][GraphicsLayerWC] setBackgroundColor support
+        https://bugs.webkit.org/show_bug.cgi?id=233244
+
+        Reviewed by Don Olmstead.
+
+        * GPUProcess/graphics/wc/WCScene.cpp:
+        (WebKit::WCScene::update):
+        * WebProcess/WebPage/wc/GraphicsLayerWC.cpp:
+        (WebKit::GraphicsLayerWC::setBackgroundColor):
+        (WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly):
+        * WebProcess/WebPage/wc/GraphicsLayerWC.h:
+        * WebProcess/WebPage/wc/WCUpateInfo.h:
+        (WebKit::WCLayerUpateInfo::encode const):
+        (WebKit::WCLayerUpateInfo::decode):
+
 2021-11-18  Alex Christensen  <[email protected]>
 
         Allow all redirect schemes when compiling a content rule list

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


--- trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp	2021-11-19 06:26:43 UTC (rev 286046)
@@ -137,6 +137,8 @@
             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/GraphicsLayerWC.cpp (286045 => 286046)


--- trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp	2021-11-19 06:26:43 UTC (rev 286046)
@@ -216,6 +216,14 @@
     updateDebugIndicators();
 }
 
+void GraphicsLayerWC::setBackgroundColor(const WebCore::Color& value)
+{
+    if (value == backgroundColor())
+        return;
+    GraphicsLayer::setBackgroundColor(value);
+    noteLayerPropertyChanged(WCLayerChange::BackgroundColor);
+}
+
 void GraphicsLayerWC::setOpacity(float value)
 {
     if (value == opacity())
@@ -446,6 +454,8 @@
         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)

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


--- trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h	2021-11-19 06:26:43 UTC (rev 286046)
@@ -67,6 +67,7 @@
     void setChildrenTransform(const WebCore::TransformationMatrix&) override;
     void setPreserves3D(bool) override;
     void setMasksToBounds(bool) override;
+    void setBackgroundColor(const WebCore::Color&) override;
     void setOpacity(float) override;
     void setContentsRect(const WebCore::FloatRect&) override;
     void setContentsClippingRect(const WebCore::FloatRoundedRect&) override;

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


--- trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h	2021-11-19 06:06:32 UTC (rev 286045)
+++ trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h	2021-11-19 06:26:43 UTC (rev 286046)
@@ -55,6 +55,7 @@
     Filters                 = 1 << 17,
     BackdropFilters         = 1 << 18,
     PlatformLayer           = 1 << 19,
+    BackgroundColor         = 1 << 20,
 };
 
 struct WCLayerUpateInfo {
@@ -74,6 +75,7 @@
     bool backfaceVisibility;
     bool preserves3D;
     WebCore::Color solidColor;
+    WebCore::Color backgroundColor;
     WebCore::Color debugBorderColor;
     float opacity;
     float debugBorderWidth;
@@ -119,6 +121,8 @@
             encoder << contentsRect;
         if (changes & WCLayerChange::ContentsClippingRect)
             encoder << contentsClippingRect;
+        if (changes & WCLayerChange::BackgroundColor)
+            encoder << backgroundColor;
         if (changes & WCLayerChange::Opacity)
             encoder << opacity;
         if (changes & WCLayerChange::BackingStore)
@@ -206,6 +210,10 @@
             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;
@@ -296,7 +304,8 @@
         WebKit::WCLayerChange::ChildrenTransform,
         WebKit::WCLayerChange::Filters,
         WebKit::WCLayerChange::BackdropFilters,
-        WebKit::WCLayerChange::PlatformLayer
+        WebKit::WCLayerChange::PlatformLayer,
+        WebKit::WCLayerChange::BackgroundColor
     >;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to