Title: [133056] trunk
Revision
133056
Author
[email protected]
Date
2012-10-31 12:01:40 -0700 (Wed, 31 Oct 2012)

Log Message

REGRESSION (tile cache layers): bits of tiled layers are missing with certain 3D transforms
https://bugs.webkit.org/show_bug.cgi?id=100808
<rdar://problem/12562541>

Reviewed by Dean Jackson.

Source/WebCore:

When projecting rects down into transformed layers, the projection can fail with severe
3D rotations if the computed w component in TransformationMatrix::projectPoint() is negative.
In this case we already clamp, but the fact that we clamped doesn't make it out to
GraphicsLayerCA::computeVisibleRect() which resulted in incorrect visible rects being
computed.

Fix by propagating the fact that clamping occurred out of the TransformState functions
which can clamp. In computeVisibleRect(), simply consider the entire layer bounds
to be visible if clamping occurred.

Tests: compositing/tiling/rotated-tiled-clamped.html
       compositing/tiling/rotated-tiled-preserve3d-clamped.html

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::computeVisibleRect): If either the applyTransform()
or the state.mappedQuad() clamped, use our bounds as the visible rect.
* platform/graphics/transforms/TransformState.cpp:
(WebCore::TransformState::applyTransform): Pass out clamping state.
(WebCore::TransformState::flatten): Ditto.
(WebCore::TransformState::mappedPoint): Ditto.
(WebCore::TransformState::mappedQuad): Ditto.
(WebCore::TransformState::flattenWithTransform): Ditto. No need to initialize
wasClamped, since this function is internal.
* platform/graphics/transforms/TransformState.h:
(TransformState):
* platform/graphics/transforms/TransformationMatrix.cpp:
(WebCore::TransformationMatrix::projectQuad): If any point projection clamped,
set the flag to say we clamped.
* platform/graphics/transforms/TransformationMatrix.h:
(TransformationMatrix):

LayoutTests:

Two tests for visible rect computation under clamping, one of which tests 'applyWasClamped',
and the other 'mapWasClamped'.

* compositing/tiling/rotated-tiled-clamped-expected.png: Added.
* compositing/tiling/rotated-tiled-clamped-expected.txt: Added.
* compositing/tiling/rotated-tiled-clamped.html: Added.
* compositing/tiling/rotated-tiled-preserve3d-clamped-expected.png: Added.
* compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt: Added.
* compositing/tiling/rotated-tiled-preserve3d-clamped.html: Added.
* platform/chromium/TestExpectations:
* platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt: Added.
* platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (133055 => 133056)


--- trunk/LayoutTests/ChangeLog	2012-10-31 19:01:37 UTC (rev 133055)
+++ trunk/LayoutTests/ChangeLog	2012-10-31 19:01:40 UTC (rev 133056)
@@ -1,3 +1,24 @@
+2012-10-31  Simon Fraser  <[email protected]>
+
+        REGRESSION (tile cache layers): bits of tiled layers are missing with certain 3D transforms
+        https://bugs.webkit.org/show_bug.cgi?id=100808
+        <rdar://problem/12562541>
+
+        Reviewed by Dean Jackson.
+
+        Two tests for visible rect computation under clamping, one of which tests 'applyWasClamped',
+        and the other 'mapWasClamped'.
+
+        * compositing/tiling/rotated-tiled-clamped-expected.png: Added.
+        * compositing/tiling/rotated-tiled-clamped-expected.txt: Added.
+        * compositing/tiling/rotated-tiled-clamped.html: Added.
+        * compositing/tiling/rotated-tiled-preserve3d-clamped-expected.png: Added.
+        * compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt: Added.
+        * compositing/tiling/rotated-tiled-preserve3d-clamped.html: Added.
+        * platform/chromium/TestExpectations:
+        * platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt: Added.
+        * platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt: Added.
+
 2012-10-31  Adam Barth  <[email protected]>
 
         [V8] Garbage collection should use opaque roots rather than implicit references

Added: trunk/LayoutTests/compositing/tiling/rotated-tiled-clamped-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/compositing/tiling/rotated-tiled-clamped-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/compositing/tiling/rotated-tiled-clamped-expected.txt (0 => 133056)


--- trunk/LayoutTests/compositing/tiling/rotated-tiled-clamped-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/tiling/rotated-tiled-clamped-expected.txt	2012-10-31 19:01:40 UTC (rev 133056)
@@ -0,0 +1,32 @@
+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (children 1
+        (GraphicsLayer
+          (position 58.00 50.00)
+          (bounds 502.00 302.00)
+          (visible rect 0.00, 0.00 502.00 x 302.00)
+          (children 1
+            (GraphicsLayer
+              (position 1.00 1.00)
+              (bounds 500.00 300.00)
+              (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 -0.00] [0.00 0.00 0.00 1.00])
+              (children 1
+                (GraphicsLayer
+                  (position -1250.00 0.00)
+                  (anchor 0.54 0.50)
+                  (bounds 2800.00 300.00)
+                  (drawsContent 1)
+                  (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
Property changes on: trunk/LayoutTests/compositing/tiling/rotated-tiled-clamped-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/tiling/rotated-tiled-clamped.html (0 => 133056)


--- trunk/LayoutTests/compositing/tiling/rotated-tiled-clamped.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/tiling/rotated-tiled-clamped.html	2012-10-31 19:01:40 UTC (rev 133056)
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            overflow: hidden; /* hide body scrollbars */
+        }
+        .scene {
+            position: relative;
+            -webkit-perspective: 600px;
+            width: 500px;
+            height: 300px;
+            margin: 50px;
+            overflow: hidden;
+            border: 1px solid black;
+        }
+        .tiled {
+            position: absolute;
+            left: -1250px;
+            height: 300px;
+            width: 2500px;
+            background-color: silver;
+            border-right: 300px solid green; /* this should be visible */
+            -webkit-transform: rotateY(80deg);
+            -webkit-transform-origin: 1500px 50%;
+        }
+        
+        #layers {
+            opacity: 0; /* hide from pixel result */
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText(true);
+
+        function doTest()
+        {
+            if (window.internals) {
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document,
+                    internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+            }
+        }
+    
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<div class="scene">
+    <div class="tiled"></div>
+</div>
+<pre id="layers">Layer tree goes here</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/tiling/rotated-tiled-clamped.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt (0 => 133056)


--- trunk/LayoutTests/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt	2012-10-31 19:01:40 UTC (rev 133056)
@@ -0,0 +1,38 @@
+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (children 1
+        (GraphicsLayer
+          (position 58.00 50.00)
+          (bounds 502.00 302.00)
+          (children 1
+            (GraphicsLayer
+              (position 1.00 1.00)
+              (bounds 500.00 300.00)
+              (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 -0.00] [0.00 0.00 0.00 1.00])
+              (children 1
+                (GraphicsLayer
+                  (bounds 500.00 0.00)
+                  (preserves3D 1)
+                  (visible rect 0.00, 0.00 0.00 x 0.00)
+                  (children 1
+                    (GraphicsLayer
+                      (position -1250.00 0.00)
+                      (anchor 0.54 0.50)
+                      (bounds 2800.00 300.00)
+                      (drawsContent 1)
+                      (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
+                    )
+                  )
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
Property changes on: trunk/LayoutTests/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/tiling/rotated-tiled-preserve3d-clamped.html (0 => 133056)


--- trunk/LayoutTests/compositing/tiling/rotated-tiled-preserve3d-clamped.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/tiling/rotated-tiled-preserve3d-clamped.html	2012-10-31 19:01:40 UTC (rev 133056)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            overflow: hidden; /* hide body scrollbars */
+        }
+        .scene {
+            position: relative;
+            -webkit-perspective: 600px;
+            width: 500px;
+            height: 300px;
+            margin: 50px;
+            overflow: hidden;
+            border: 1px solid black;
+        }
+        .container {
+            -webkit-transform-style: preserve-3d;
+        }
+        .tiled {
+            position: absolute;
+            left: -1250px;
+            height: 300px;
+            width: 2500px;
+            background-color: silver;
+            border-right: 300px solid green; /* this should be visible */
+            -webkit-transform: rotateY(80deg);
+            -webkit-transform-origin: 1500px 50%;
+        }
+        
+        #layers {
+            opacity: 0; /* hide from pixel result */
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText(true);
+
+        function doTest()
+        {
+            if (window.internals) {
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document,
+                    internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+            }
+        }
+    
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<div class="scene">
+    <div class="container">
+        <div class="tiled"></div>
+    </div>
+</div>
+<pre id="layers">Layer tree goes here</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/tiling/rotated-tiled-preserve3d-clamped.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (133055 => 133056)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2012-10-31 19:01:37 UTC (rev 133055)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2012-10-31 19:01:40 UTC (rev 133056)
@@ -3021,6 +3021,12 @@
 webkit.org/b/48454 compositing/tiling/huge-layer-img.html [ Skip ]
 webkit.org/b/48454 platform/chromium/virtual/softwarecompositing/tiling/huge-layer-img.html [ Skip ]
 
+# Need image baselines for Chromium
+webkit.org/b/100808 compositing/tiling/tiling/rotated-tiled-clamped.html [ ImageOnlyFailure ]
+webkit.org/b/100808 platform/chromium/virtual/softwarecompositing/tiling/tiling/rotated-tiled-clamped.html [ ImageOnlyFailure ]
+webkit.org/b/100808 compositing/tiling/tiling/rotated-tiled-preserve3d-clamped.html [ ImageOnlyFailure ]
+webkit.org/b/100808 platform/chromium/virtual/softwarecompositing/tiling/tiling/rotated-tiled-preserve3d-clamped.html [ ImageOnlyFailure ]
+
 webkit.org/b/75932 fast/js/array-defineOwnProperty.html [ Failure ]
 webkit.org/b/75932 fast/js/mozilla/strict/15.4.4.6.html [ Failure ]
 

Added: trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt (0 => 133056)


--- trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt	2012-10-31 19:01:40 UTC (rev 133056)
@@ -0,0 +1,39 @@
+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (children 1
+        (GraphicsLayer
+          (position 58.00 50.00)
+          (bounds 502.00 302.00)
+          (visible rect 0.00, 0.00 502.00 x 302.00)
+          (children 1
+            (GraphicsLayer
+              (position 1.00 1.00)
+              (bounds 500.00 300.00)
+              (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 -0.00] [0.00 0.00 0.00 1.00])
+              (visible rect 0.00, 0.00 500.00 x 300.00)
+              (children 1
+                (GraphicsLayer
+                  (position -1250.00 0.00)
+                  (anchor 0.54 0.50)
+                  (bounds 2800.00 300.00)
+                  (usingTiledLayer 1)
+                  (drawsContent 1)
+                  (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
+                  (visible rect 0.00, 0.00 2800.00 x 300.00)
+                  (tile cache coverage 0, 0 2800 x 300)
+                  (tile size 512 x 512)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
Property changes on: trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt (0 => 133056)


--- trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt	2012-10-31 19:01:40 UTC (rev 133056)
@@ -0,0 +1,46 @@
+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (children 1
+        (GraphicsLayer
+          (position 58.00 50.00)
+          (bounds 502.00 302.00)
+          (visible rect 0.00, 0.00 502.00 x 302.00)
+          (children 1
+            (GraphicsLayer
+              (position 1.00 1.00)
+              (bounds 500.00 300.00)
+              (childrenTransform [1.00 0.00 0.00 0.00] [0.00 1.00 0.00 0.00] [0.00 0.00 1.00 -0.00] [0.00 0.00 0.00 1.00])
+              (visible rect 0.00, 0.00 500.00 x 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 500.00 0.00)
+                  (preserves3D 1)
+                  (visible rect 0.00, 0.00 0.00 x 0.00)
+                  (children 1
+                    (GraphicsLayer
+                      (position -1250.00 0.00)
+                      (anchor 0.54 0.50)
+                      (bounds 2800.00 300.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (transform [0.17 0.00 -0.98 0.00] [0.00 1.00 0.00 0.00] [0.98 0.00 0.17 0.00] [0.00 0.00 0.00 1.00])
+                      (visible rect 0.00, 0.00 2800.00 x 300.00)
+                      (tile cache coverage 0, 0 2800 x 300)
+                      (tile size 512 x 512)
+                    )
+                  )
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
Property changes on: trunk/LayoutTests/platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (133055 => 133056)


--- trunk/Source/WebCore/ChangeLog	2012-10-31 19:01:37 UTC (rev 133055)
+++ trunk/Source/WebCore/ChangeLog	2012-10-31 19:01:40 UTC (rev 133056)
@@ -1,3 +1,42 @@
+2012-10-31  Simon Fraser  <[email protected]>
+
+        REGRESSION (tile cache layers): bits of tiled layers are missing with certain 3D transforms
+        https://bugs.webkit.org/show_bug.cgi?id=100808
+        <rdar://problem/12562541>
+
+        Reviewed by Dean Jackson.
+
+        When projecting rects down into transformed layers, the projection can fail with severe
+        3D rotations if the computed w component in TransformationMatrix::projectPoint() is negative.
+        In this case we already clamp, but the fact that we clamped doesn't make it out to
+        GraphicsLayerCA::computeVisibleRect() which resulted in incorrect visible rects being
+        computed.
+        
+        Fix by propagating the fact that clamping occurred out of the TransformState functions
+        which can clamp. In computeVisibleRect(), simply consider the entire layer bounds
+        to be visible if clamping occurred.
+
+        Tests: compositing/tiling/rotated-tiled-clamped.html
+               compositing/tiling/rotated-tiled-preserve3d-clamped.html
+
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::computeVisibleRect): If either the applyTransform()
+        or the state.mappedQuad() clamped, use our bounds as the visible rect.
+        * platform/graphics/transforms/TransformState.cpp:
+        (WebCore::TransformState::applyTransform): Pass out clamping state.
+        (WebCore::TransformState::flatten): Ditto.
+        (WebCore::TransformState::mappedPoint): Ditto.
+        (WebCore::TransformState::mappedQuad): Ditto.
+        (WebCore::TransformState::flattenWithTransform): Ditto. No need to initialize
+        wasClamped, since this function is internal.
+        * platform/graphics/transforms/TransformState.h:
+        (TransformState):
+        * platform/graphics/transforms/TransformationMatrix.cpp:
+        (WebCore::TransformationMatrix::projectQuad): If any point projection clamped,
+        set the flag to say we clamped.
+        * platform/graphics/transforms/TransformationMatrix.h:
+        (TransformationMatrix):
+
 2012-10-31  Tiancheng Jiang  <[email protected]>
 
         Change bubble message style to BB10 UX spec.

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (133055 => 133056)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2012-10-31 19:01:37 UTC (rev 133055)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2012-10-31 19:01:40 UTC (rev 133056)
@@ -943,11 +943,14 @@
         }
     }
 
-    state.applyTransform(layerTransform, accumulation);
+    bool applyWasClamped;
+    state.applyTransform(layerTransform, accumulation, &applyWasClamped);
     
-    FloatRect clipRectForChildren = state.mappedQuad().boundingBox();
+    bool mapWasClamped;
+    FloatRect clipRectForChildren = state.mappedQuad(&mapWasClamped).boundingBox();
     FloatRect clipRectForSelf(0, 0, m_size.width(), m_size.height());
-    clipRectForSelf.intersect(clipRectForChildren);
+    if (!applyWasClamped && !mapWasClamped)
+        clipRectForSelf.intersect(clipRectForChildren);
     
     if (masksToBounds()) {
         ASSERT(accumulation == TransformState::FlattenTransform);

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp (133055 => 133056)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp	2012-10-31 19:01:37 UTC (rev 133055)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp	2012-10-31 19:01:40 UTC (rev 133056)
@@ -76,13 +76,16 @@
 }
 
 // FIXME: We transform AffineTransform to TransformationMatrix. This is rather inefficient.
-void TransformState::applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation accumulate)
+void TransformState::applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation accumulate, bool* wasClamped)
 {
-    applyTransform(transformFromContainer.toTransformationMatrix(), accumulate);
+    applyTransform(transformFromContainer.toTransformationMatrix(), accumulate, wasClamped);
 }
 
-void TransformState::applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation accumulate)
+void TransformState::applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation accumulate, bool* wasClamped)
 {
+    if (wasClamped)
+        *wasClamped = false;
+
     // If we have an accumulated transform from last time, multiply in this transform
     if (m_accumulatedTransform) {
         if (m_direction == ApplyTransformDirection)
@@ -96,44 +99,53 @@
     
     if (accumulate == FlattenTransform) {
         const TransformationMatrix* finalTransform = m_accumulatedTransform ? m_accumulatedTransform.get() : &transformFromContainer;
-        flattenWithTransform(*finalTransform);
+        flattenWithTransform(*finalTransform, wasClamped);
     }
     m_accumulatingTransform = accumulate == AccumulateTransform;
 }
 
-void TransformState::flatten()
+void TransformState::flatten(bool* wasClamped)
 {
+    if (wasClamped)
+        *wasClamped = false;
+
     if (!m_accumulatedTransform) {
         m_accumulatingTransform = false;
         return;
     }
     
-    flattenWithTransform(*m_accumulatedTransform);
+    flattenWithTransform(*m_accumulatedTransform, wasClamped);
 }
 
-FloatPoint TransformState::mappedPoint() const
+FloatPoint TransformState::mappedPoint(bool* wasClamped) const
 {
+    if (wasClamped)
+        *wasClamped = false;
+
     if (!m_accumulatedTransform)
         return m_lastPlanarPoint;
 
     if (m_direction == ApplyTransformDirection)
         return m_accumulatedTransform->mapPoint(m_lastPlanarPoint);
 
-    return m_accumulatedTransform->inverse().projectPoint(m_lastPlanarPoint);
+    return m_accumulatedTransform->inverse().projectPoint(m_lastPlanarPoint, wasClamped);
 }
 
-FloatQuad TransformState::mappedQuad() const
+FloatQuad TransformState::mappedQuad(bool* wasClamped) const
 {
+    if (wasClamped)
+        *wasClamped = false;
+
     if (!m_accumulatedTransform)
         return m_lastPlanarQuad;
 
     if (m_direction == ApplyTransformDirection)
         return m_accumulatedTransform->mapQuad(m_lastPlanarQuad);
 
-    return m_accumulatedTransform->inverse().projectQuad(m_lastPlanarQuad);
+    return m_accumulatedTransform->inverse().projectQuad(m_lastPlanarQuad, wasClamped);
 }
 
-void TransformState::flattenWithTransform(const TransformationMatrix& t)
+void TransformState::flattenWithTransform(const TransformationMatrix& t, bool* wasClamped)
 {
     if (m_direction == ApplyTransformDirection) {
         if (m_mapPoint)
@@ -145,7 +157,7 @@
         if (m_mapPoint)
             m_lastPlanarPoint = inverseTransform.projectPoint(m_lastPlanarPoint);
         if (m_mapQuad)
-            m_lastPlanarQuad = inverseTransform.projectQuad(m_lastPlanarQuad);
+            m_lastPlanarQuad = inverseTransform.projectQuad(m_lastPlanarQuad, wasClamped);
     }
 
     // We could throw away m_accumulatedTransform if we wanted to here, but that

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformState.h (133055 => 133056)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformState.h	2012-10-31 19:01:37 UTC (rev 133055)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformState.h	2012-10-31 19:01:40 UTC (rev 133056)
@@ -81,20 +81,20 @@
     }
     
     void move(LayoutUnit x, LayoutUnit y, TransformAccumulation = FlattenTransform);
-    void applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation = FlattenTransform);
-    void applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation = FlattenTransform);
-    void flatten();
+    void applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = 0);
+    void applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = 0);
+    void flatten(bool* wasClamped = 0);
 
     // Return the coords of the point or quad in the last flattened layer
     FloatPoint lastPlanarPoint() const { return m_lastPlanarPoint; }
     FloatQuad lastPlanarQuad() const { return m_lastPlanarQuad; }
 
     // Return the point or quad mapped through the current transform
-    FloatPoint mappedPoint() const;
-    FloatQuad mappedQuad() const;
+    FloatPoint mappedPoint(bool* wasClamped = 0) const;
+    FloatQuad mappedQuad(bool* wasClamped = 0) const;
 
 private:
-    void flattenWithTransform(const TransformationMatrix&);
+    void flattenWithTransform(const TransformationMatrix&, bool* wasClamped);
     
     FloatPoint m_lastPlanarPoint;
     FloatQuad m_lastPlanarQuad;

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp (133055 => 133056)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp	2012-10-31 19:01:37 UTC (rev 133055)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp	2012-10-31 19:01:40 UTC (rev 133056)
@@ -589,7 +589,7 @@
     return FloatPoint(static_cast<float>(outX), static_cast<float>(outY));
 }
 
-FloatQuad TransformationMatrix::projectQuad(const FloatQuad& q) const
+FloatQuad TransformationMatrix::projectQuad(const FloatQuad& q, bool* clamped) const
 {
     FloatQuad projectedQuad;
 
@@ -603,6 +603,9 @@
     projectedQuad.setP3(projectPoint(q.p3(), &clamped3));
     projectedQuad.setP4(projectPoint(q.p4(), &clamped4));
 
+    if (clamped)
+        *clamped = clamped1 || clamped2 || clamped3 || clamped4;
+        
     // If all points on the quad had w < 0, then the entire quad would not be visible to the projected surface.
     bool everythingWasClipped = clamped1 && clamped2 && clamped3 && clamped4;
     if (everythingWasClipped)

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h (133055 => 133056)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h	2012-10-31 19:01:37 UTC (rev 133055)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h	2012-10-31 19:01:40 UTC (rev 133056)
@@ -166,7 +166,7 @@
     // with the destination plane.
     FloatPoint projectPoint(const FloatPoint&, bool* clamped = 0) const;
     // Projects the four corners of the quad
-    FloatQuad projectQuad(const FloatQuad&) const;
+    FloatQuad projectQuad(const FloatQuad&,  bool* clamped = 0) const;
     // Projects the four corners of the quad and takes a bounding box,
     // while sanitizing values created when the w component is negative.
     FractionalLayoutRect clampedBoundsOfProjectedQuad(const FloatQuad&) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to