Title: [260174] trunk/Source
Revision
260174
Author
[email protected]
Date
2020-04-16 00:11:40 -0700 (Thu, 16 Apr 2020)

Log Message

TextureMapper renders video element with "object-fit: cover" incorrectly
https://bugs.webkit.org/show_bug.cgi?id=210544

Patch by Tomoki Imai <[email protected]> on 2020-04-16
Reviewed by Žan Doberšek.

Propagate GraphicsLayer::contentsClippingRect information to TextureMapperLayer
to properly clip the outside of DOM element when the element has "object-fit: cover".

Unfortunately, the test is disabled on WebKitGTK due to bug 177536, bug 163528.
Test: compositing/video/video-object-fit.html

Source/WebCore:

* platform/graphics/nicosia/NicosiaPlatformLayer.h:
(Nicosia::CompositionLayer::flushState):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::paintSelf): Clip using propagated contentsClippingRect when rendering m_contentsLayer.
(WebCore::TextureMapperLayer::setContentsClippingRect):
* platform/graphics/texmap/TextureMapperLayer.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setContentsClippingRect):
(WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:

Source/WebKit:

* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::CoordinatedGraphicsScene::updateSceneState):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (260173 => 260174)


--- trunk/Source/WebCore/ChangeLog	2020-04-16 05:57:41 UTC (rev 260173)
+++ trunk/Source/WebCore/ChangeLog	2020-04-16 07:11:40 UTC (rev 260174)
@@ -1,3 +1,27 @@
+2020-04-16  Tomoki Imai  <[email protected]>
+
+        TextureMapper renders video element with "object-fit: cover" incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=210544
+
+        Reviewed by Žan Doberšek.
+
+        Propagate GraphicsLayer::contentsClippingRect information to TextureMapperLayer
+        to properly clip the outside of DOM element when the element has "object-fit: cover".
+
+        Unfortunately, the test is disabled on WebKitGTK due to bug 177536, bug 163528.
+        Test: compositing/video/video-object-fit.html
+
+        * platform/graphics/nicosia/NicosiaPlatformLayer.h:
+        (Nicosia::CompositionLayer::flushState):
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::paintSelf): Clip using propagated contentsClippingRect when rendering m_contentsLayer.
+        (WebCore::TextureMapperLayer::setContentsClippingRect):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::setContentsClippingRect):
+        (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+
 2020-04-15  Myles C. Maxfield  <[email protected]>
 
         [Cocoa] Password obscuring dots drawn with the system font are too small

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


--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h	2020-04-16 05:57:41 UTC (rev 260173)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h	2020-04-16 07:11:40 UTC (rev 260174)
@@ -117,6 +117,7 @@
                     bool childrenTransformChanged : 1;
                     bool contentsRectChanged : 1;
                     bool contentsTilingChanged : 1;
+                    bool contentsClippingRectChanged : 1;
                     bool opacityChanged : 1;
                     bool solidColorChanged : 1;
                     bool filtersChanged : 1;
@@ -166,6 +167,7 @@
         WebCore::FloatRect contentsRect;
         WebCore::FloatSize contentsTilePhase;
         WebCore::FloatSize contentsTileSize;
+        WebCore::FloatRoundedRect contentsClippingRect;
 
         float opacity { 0 };
         WebCore::Color solidColor;
@@ -231,6 +233,8 @@
             staging.contentsTilePhase = pending.contentsTilePhase;
             staging.contentsTileSize = pending.contentsTileSize;
         }
+        if (pending.delta.contentsClippingRectChanged)
+            staging.contentsClippingRect = pending.contentsClippingRect;
 
         if (pending.delta.opacityChanged)
             staging.opacity = pending.opacity;

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


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2020-04-16 05:57:41 UTC (rev 260173)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2020-04-16 07:11:40 UTC (rev 260174)
@@ -189,7 +189,12 @@
     }
 
     ASSERT(!layerRect().isEmpty());
+
+    // FIXME: TextureMapper::beginClip doesn't support FloatRoundedRect, so we need to convert m_state.contentsClippingRect to FloatRect.
+    options.textureMapper.beginClip(transform, m_state.contentsClippingRect.rect());
     m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity);
+    options.textureMapper.endClip();
+
     if (m_state.showDebugBorders)
         m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
 }
@@ -587,6 +592,11 @@
     m_state.contentsTilePhase = phase;
 }
 
+void TextureMapperLayer::setContentsClippingRect(const FloatRoundedRect& contentsClippingRect)
+{
+    m_state.contentsClippingRect = contentsClippingRect;
+}
+
 void TextureMapperLayer::setMasksToBounds(bool masksToBounds)
 {
     m_state.masksToBounds = masksToBounds;

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


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2020-04-16 05:57:41 UTC (rev 260173)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2020-04-16 07:11:40 UTC (rev 260174)
@@ -81,6 +81,7 @@
     void setSolidColor(const Color&);
     void setContentsTileSize(const FloatSize&);
     void setContentsTilePhase(const FloatSize&);
+    void setContentsClippingRect(const FloatRoundedRect&);
     void setFilters(const FilterOperations&);
 
     bool hasFilters() const
@@ -166,6 +167,7 @@
         FloatRect contentsRect;
         FloatSize contentsTileSize;
         FloatSize contentsTilePhase;
+        FloatRoundedRect contentsClippingRect;
         WeakPtr<TextureMapperLayer> maskLayer;
         WeakPtr<TextureMapperLayer> replicaLayer;
         Color solidColor;

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


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2020-04-16 05:57:41 UTC (rev 260173)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2020-04-16 07:11:40 UTC (rev 260174)
@@ -428,6 +428,16 @@
     notifyFlushRequired();
 }
 
+void CoordinatedGraphicsLayer::setContentsClippingRect(const FloatRoundedRect& roundedRect)
+{
+    if (contentsClippingRect() == roundedRect)
+        return;
+
+    GraphicsLayer::setContentsClippingRect(roundedRect);
+    m_nicosia.delta.contentsClippingRectChanged = true;
+    notifyFlushRequired();
+}
+
 bool GraphicsLayer::supportsContentsTiling()
 {
     return true;
@@ -863,6 +873,8 @@
                     state.contentsTilePhase = contentsTilePhase();
                     state.contentsTileSize = contentsTileSize();
                 }
+                if (localDelta.contentsClippingRectChanged)
+                    state.contentsClippingRect = contentsClippingRect();
 
                 if (localDelta.opacityChanged)
                     state.opacity = opacity();

Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h (260173 => 260174)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h	2020-04-16 05:57:41 UTC (rev 260173)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h	2020-04-16 07:11:40 UTC (rev 260174)
@@ -90,6 +90,7 @@
     void setContentsRect(const FloatRect&) override;
     void setContentsTilePhase(const FloatSize&) override;
     void setContentsTileSize(const FloatSize&) override;
+    void setContentsClippingRect(const FloatRoundedRect&) override;
     void setContentsToImage(Image*) override;
     void setContentsToSolidColor(const Color&) override;
     void setShowDebugBorder(bool) override;

Modified: trunk/Source/WebKit/ChangeLog (260173 => 260174)


--- trunk/Source/WebKit/ChangeLog	2020-04-16 05:57:41 UTC (rev 260173)
+++ trunk/Source/WebKit/ChangeLog	2020-04-16 07:11:40 UTC (rev 260174)
@@ -1,3 +1,19 @@
+2020-04-16  Tomoki Imai  <[email protected]>
+
+        TextureMapper renders video element with "object-fit: cover" incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=210544
+
+        Reviewed by Žan Doberšek.
+
+        Propagate GraphicsLayer::contentsClippingRect information to TextureMapperLayer
+        to properly clip the outside of DOM element when the element has "object-fit: cover".
+
+        Unfortunately, the test is disabled on WebKitGTK due to bug 177536, bug 163528.
+        Test: compositing/video/video-object-fit.html
+
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
+        (WebKit::CoordinatedGraphicsScene::updateSceneState):
+
 2020-04-15  Jer Noble  <[email protected]>
 
         REGRESSION (r260102): ASSERTION FAILED: m_arbitrators.contains(proxy) in WebKit::SharedArbitrator::endRoutingArbitrationForArbitrator

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp (260173 => 260174)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp	2020-04-16 05:57:41 UTC (rev 260173)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp	2020-04-16 07:11:40 UTC (rev 260174)
@@ -294,6 +294,8 @@
                             layer.setContentsTilePhase(layerState.contentsTilePhase);
                             layer.setContentsTileSize(layerState.contentsTileSize);
                         }
+                        if (layerState.delta.contentsClippingRectChanged)
+                            layer.setContentsClippingRect(layerState.contentsClippingRect);
 
                         if (layerState.delta.opacityChanged)
                             layer.setOpacity(layerState.opacity);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to