- Revision
- 252486
- Author
- [email protected]
- Date
- 2019-11-15 08:58:59 -0800 (Fri, 15 Nov 2019)
Log Message
The image is flashing if falls out and has an animation transform: rotate
https://bugs.webkit.org/show_bug.cgi?id=203613
Reviewed by Antti Koivisto.
Source/WebCore:
Code added in r218735 that maps the animation extent through the current animating transform
worked for translations, but not rotation where anchor point matters. This matrix
needs to take anchor point into account.
Shared some code that applies anchor point to a matrix.
Test: compositing/backing/backing-store-attachment-with-rotation.html
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::layerTransform const):
(WebCore::GraphicsLayerCA::transformByApplyingAnchorPoint const):
(WebCore::GraphicsLayerCA::setVisibleAndCoverageRects):
* platform/graphics/ca/GraphicsLayerCA.h:
LayoutTests:
* compositing/backing/backing-store-attachment-with-rotation-expected.txt: Added.
* compositing/backing/backing-store-attachment-with-rotation.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (252485 => 252486)
--- trunk/LayoutTests/ChangeLog 2019-11-15 16:39:25 UTC (rev 252485)
+++ trunk/LayoutTests/ChangeLog 2019-11-15 16:58:59 UTC (rev 252486)
@@ -1,3 +1,13 @@
+2019-11-15 Simon Fraser <[email protected]>
+
+ The image is flashing if falls out and has an animation transform: rotate
+ https://bugs.webkit.org/show_bug.cgi?id=203613
+
+ Reviewed by Antti Koivisto.
+
+ * compositing/backing/backing-store-attachment-with-rotation-expected.txt: Added.
+ * compositing/backing/backing-store-attachment-with-rotation.html: Added.
+
2019-11-14 Wenson Hsieh <[email protected]>
Crash when setting HTMLInputElement.checked for a disconnected radio button in a shadow root
Added: trunk/LayoutTests/compositing/backing/backing-store-attachment-with-rotation-expected.txt (0 => 252486)
--- trunk/LayoutTests/compositing/backing/backing-store-attachment-with-rotation-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/backing/backing-store-attachment-with-rotation-expected.txt 2019-11-15 16:58:59 UTC (rev 252486)
@@ -0,0 +1,24 @@
+top left
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 950.00 600.00)
+ (backingStoreAttached 1)
+ (children 1
+ (GraphicsLayer
+ (bounds 950.00 600.00)
+ (contentsOpaque 1)
+ (backingStoreAttached 1)
+ (children 1
+ (GraphicsLayer
+ (position 550.00 13.00)
+ (bounds 400.00 400.00)
+ (contentsOpaque 1)
+ (drawsContent 1)
+ (backingStoreAttached 1)
+ (transform [-0.00 1.00 0.00 0.00] [-1.00 -0.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 0.00 0.00 1.00])
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/compositing/backing/backing-store-attachment-with-rotation.html (0 => 252486)
--- trunk/LayoutTests/compositing/backing/backing-store-attachment-with-rotation.html (rev 0)
+++ trunk/LayoutTests/compositing/backing/backing-store-attachment-with-rotation.html 2019-11-15 16:58:59 UTC (rev 252486)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+ <style>
+ body {
+ overflow: hidden;
+ }
+
+ @keyframes rotate {
+ 0% {
+ transform: rotate(90deg);
+ }
+ 100% {
+ transform: rotate(90.001deg);
+ }
+ }
+
+ .box {
+ position: absolute;
+ right: -150px;
+ width: 400px;
+ height: 400px;
+ animation: rotate 1000s linear infinite;
+ will-change: transform;
+ background-color: gray;
+ font-size: 24pt;
+ color: white;
+ padding: 20px;
+ box-sizing: border-box;
+ }
+ </style>
+ <script>
+ if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ }
+
+ function dumpLayers()
+ {
+ var layersResult = document.getElementById('layers');
+ if (window.testRunner)
+ layersResult.innerText = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED);
+ }
+
+ window.addEventListener('load', () => {
+ requestAnimationFrame(() => {
+ requestAnimationFrame(() => {
+ dumpLayers();
+ if (window.testRunner)
+ testRunner.notifyDone();
+ });
+ });
+ }, false);
+ </script>
+</head>
+<body>
+ <div class="box">
+ top left
+ </div>
+<pre id="layers"></pre>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (252485 => 252486)
--- trunk/Source/WebCore/ChangeLog 2019-11-15 16:39:25 UTC (rev 252485)
+++ trunk/Source/WebCore/ChangeLog 2019-11-15 16:58:59 UTC (rev 252486)
@@ -1,3 +1,24 @@
+2019-11-15 Simon Fraser <[email protected]>
+
+ The image is flashing if falls out and has an animation transform: rotate
+ https://bugs.webkit.org/show_bug.cgi?id=203613
+
+ Reviewed by Antti Koivisto.
+
+ Code added in r218735 that maps the animation extent through the current animating transform
+ worked for translations, but not rotation where anchor point matters. This matrix
+ needs to take anchor point into account.
+
+ Shared some code that applies anchor point to a matrix.
+
+ Test: compositing/backing/backing-store-attachment-with-rotation.html
+
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::layerTransform const):
+ (WebCore::GraphicsLayerCA::transformByApplyingAnchorPoint const):
+ (WebCore::GraphicsLayerCA::setVisibleAndCoverageRects):
+ * platform/graphics/ca/GraphicsLayerCA.h:
+
2019-11-15 Zalan Bujtas <[email protected]>
[LFC][Invalidation] Introduce LayoutBox::updateStyle
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (252485 => 252486)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2019-11-15 16:39:25 UTC (rev 252485)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2019-11-15 16:58:59 UTC (rev 252486)
@@ -1374,13 +1374,7 @@
else if (m_transform)
currentTransform = *m_transform;
- if (!currentTransform.isIdentity()) {
- FloatPoint3D absoluteAnchorPoint(anchorPoint());
- absoluteAnchorPoint.scale(size().width(), size().height(), 1);
- transform.translate3d(absoluteAnchorPoint.x(), absoluteAnchorPoint.y(), absoluteAnchorPoint.z());
- transform.multiply(currentTransform);
- transform.translate3d(-absoluteAnchorPoint.x(), -absoluteAnchorPoint.y(), -absoluteAnchorPoint.z());
- }
+ transform.multiply(transformByApplyingAnchorPoint(currentTransform));
if (GraphicsLayer* parentLayer = parent()) {
if (parentLayer->hasNonIdentityChildrenTransform()) {
@@ -1396,6 +1390,20 @@
return transform;
}
+TransformationMatrix GraphicsLayerCA::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;
+}
+
GraphicsLayerCA::VisibleAndCoverageRects GraphicsLayerCA::computeVisibleAndCoverageRect(TransformState& state, bool preserves3D, ComputeVisibleRectFlags flags) const
{
FloatPoint position = approximatePosition();
@@ -1486,7 +1494,8 @@
auto bounds = FloatRect(m_boundsOrigin, size());
if (auto extent = animationExtent()) {
// Adjust the animation extent to match the current animation position.
- bounds = rects.animatingTransform.inverse().valueOr(TransformationMatrix()).mapRect(*extent);
+ auto animatingTransformWithAnchorPoint = transformByApplyingAnchorPoint(rects.animatingTransform);
+ bounds = animatingTransformWithAnchorPoint.inverse().valueOr(TransformationMatrix()).mapRect(*extent);
}
// FIXME: we need to take reflections into account when determining whether this layer intersects the coverage rect.
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (252485 => 252486)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2019-11-15 16:39:25 UTC (rev 252485)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2019-11-15 16:58:59 UTC (rev 252486)
@@ -306,6 +306,7 @@
FloatPoint& position, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset) const;
TransformationMatrix layerTransform(const FloatPoint& position, const TransformationMatrix* customTransform = 0) const;
+ TransformationMatrix transformByApplyingAnchorPoint(const TransformationMatrix&) const;
enum ComputeVisibleRectFlag { RespectAnimatingTransforms = 1 << 0 };
typedef unsigned ComputeVisibleRectFlags;