Title: [110322] trunk/Source/WebCore
Revision
110322
Author
[email protected]
Date
2012-03-09 13:04:26 -0800 (Fri, 09 Mar 2012)

Log Message

Move TransformationMatrix and TransformState to LayoutUnits.
https://bugs.webkit.org/show_bug.cgi?id=80632

Reviewed by Simon Fraser.

When we move layout to sub-pixel precision, we want to preserve that precision through
transformations. This change readies TransformState and TransformationMatrix to make
use of this additional precision in accumulating transforms, and in returning rects that
preserve it.

No new tests. No change in behavior.

* platform/graphics/transforms/TransformState.cpp:
(WebCore::TransformState::move): Changed to pass along LayoutUnits to the contained
TransformationMatrix. The values of the LayoutUnits will be implicitly converted to
floats to be applied.
* platform/graphics/transforms/TransformState.h:
(WebCore::TransformState::move): Ditto.
(TransformState):
* platform/graphics/transforms/TransformationMatrix.cpp:
(WebCore::clampEdgeValue): Limiting edges to the maximum LayoutUnit value to prevent
overflow..
(WebCore::TransformationMatrix::clampedBoundsOfProjectedQuad): Same as above, but also
returning a LayoutRect which preserves additional precision than the previous IntRect.
(WebCore::TransformationMatrix::mapRect): Adding a version of this method that operates
specifically on FractionalLayoutRects.
(WebCore):
* platform/graphics/transforms/TransformationMatrix.h:
(WebCore):
(TransformationMatrix):
* rendering/LayoutTypes.h:
(WebCore::clampToLayoutUnit):
(WebCore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (110321 => 110322)


--- trunk/Source/WebCore/CMakeLists.txt	2012-03-09 20:53:17 UTC (rev 110321)
+++ trunk/Source/WebCore/CMakeLists.txt	2012-03-09 21:04:26 UTC (rev 110322)
@@ -1121,7 +1121,6 @@
     platform/graphics/BitmapImage.cpp
     platform/graphics/Color.cpp
     platform/graphics/CrossfadeGeneratedImage.cpp
-    platform/graphics/FractionalLayoutSize.cpp
     platform/graphics/FloatPoint.cpp
     platform/graphics/FloatPoint3D.cpp
     platform/graphics/FloatQuad.cpp
@@ -1135,6 +1134,8 @@
     platform/graphics/FontFamily.cpp
     platform/graphics/FontFastPath.cpp
     platform/graphics/FontFeatureSettings.cpp
+    platform/graphics/FractionalLayoutRect.cpp
+    platform/graphics/FractionalLayoutSize.cpp  
     platform/graphics/GeneratorGeneratedImage.cpp
     platform/graphics/GlyphPageTreeNode.cpp
     platform/graphics/Gradient.cpp

Modified: trunk/Source/WebCore/ChangeLog (110321 => 110322)


--- trunk/Source/WebCore/ChangeLog	2012-03-09 20:53:17 UTC (rev 110321)
+++ trunk/Source/WebCore/ChangeLog	2012-03-09 21:04:26 UTC (rev 110322)
@@ -1,3 +1,39 @@
+2012-03-09  Levi Weintraub  <[email protected]>
+
+        Move TransformationMatrix and TransformState to LayoutUnits.
+        https://bugs.webkit.org/show_bug.cgi?id=80632
+
+        Reviewed by Simon Fraser.
+
+        When we move layout to sub-pixel precision, we want to preserve that precision through
+        transformations. This change readies TransformState and TransformationMatrix to make
+        use of this additional precision in accumulating transforms, and in returning rects that
+        preserve it.
+
+        No new tests. No change in behavior.
+
+        * platform/graphics/transforms/TransformState.cpp:
+        (WebCore::TransformState::move): Changed to pass along LayoutUnits to the contained
+        TransformationMatrix. The values of the LayoutUnits will be implicitly converted to
+        floats to be applied.
+        * platform/graphics/transforms/TransformState.h:
+        (WebCore::TransformState::move): Ditto.
+        (TransformState):
+        * platform/graphics/transforms/TransformationMatrix.cpp:
+        (WebCore::clampEdgeValue): Limiting edges to the maximum LayoutUnit value to prevent
+        overflow..
+        (WebCore::TransformationMatrix::clampedBoundsOfProjectedQuad): Same as above, but also
+        returning a LayoutRect which preserves additional precision than the previous IntRect.
+        (WebCore::TransformationMatrix::mapRect): Adding a version of this method that operates
+        specifically on FractionalLayoutRects.
+        (WebCore):
+        * platform/graphics/transforms/TransformationMatrix.h:
+        (WebCore):
+        (TransformationMatrix):
+        * rendering/LayoutTypes.h:
+        (WebCore::clampToLayoutUnit):
+        (WebCore):
+
 2012-03-09  Ryosuke Niwa  <[email protected]>
 
         Remove a bogus assertion. This condition is no longer true for non-document tree scopes.

Modified: trunk/Source/WebCore/Target.pri (110321 => 110322)


--- trunk/Source/WebCore/Target.pri	2012-03-09 20:53:17 UTC (rev 110321)
+++ trunk/Source/WebCore/Target.pri	2012-03-09 21:04:26 UTC (rev 110322)
@@ -1083,6 +1083,8 @@
     platform/graphics/FontData.cpp \
     platform/graphics/Font.cpp \
     platform/graphics/FontCache.cpp \
+    platform/graphics/FractionalLayoutRect.cpp \
+    platform/graphics/FractionalLayoutSize.cpp \
     platform/graphics/GeneratorGeneratedImage.cpp \
     platform/graphics/Gradient.cpp \
     platform/graphics/GraphicsContext.cpp \

Modified: trunk/Source/WebCore/WebCore.gypi (110321 => 110322)


--- trunk/Source/WebCore/WebCore.gypi	2012-03-09 20:53:17 UTC (rev 110321)
+++ trunk/Source/WebCore/WebCore.gypi	2012-03-09 21:04:26 UTC (rev 110322)
@@ -350,6 +350,8 @@
             'platform/graphics/FontSmoothingMode.h',
             'platform/graphics/FontTraitsMask.h',
             'platform/graphics/FontWidthVariant.h',
+            'platform/graphics/FractionalLayoutRect.h',
+            'platform/graphics/FractionalLayoutSize.h',
             'platform/graphics/Generator.h',
             'platform/graphics/Glyph.h',
             'platform/graphics/GlyphBuffer.h',
@@ -3214,6 +3216,8 @@
             'platform/graphics/FontFastPath.cpp',
             'platform/graphics/FontPlatformData.cpp',
             'platform/graphics/FontPlatformData.h',
+            'platform/graphics/FractionalLayoutRect.cpp',
+            'platform/graphics/FractionalLayoutSize.cpp',
             'platform/graphics/GeneratorGeneratedImage.cpp',
             'platform/graphics/GeneratedImage.h',
             'platform/graphics/GlyphPageTreeNode.cpp',

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


--- trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp	2012-03-09 20:53:17 UTC (rev 110321)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformState.cpp	2012-03-09 21:04:26 UTC (rev 110322)
@@ -49,7 +49,7 @@
     return *this;
 }
 
-void TransformState::move(int x, int y, TransformAccumulation accumulate)
+void TransformState::move(LayoutUnit x, LayoutUnit y, TransformAccumulation accumulate)
 {
     if (m_accumulatingTransform && m_accumulatedTransform) {
         // If we're accumulating into an existing transform, apply the translation.

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


--- trunk/Source/WebCore/platform/graphics/transforms/TransformState.h	2012-03-09 20:53:17 UTC (rev 110321)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformState.h	2012-03-09 21:04:26 UTC (rev 110322)
@@ -30,6 +30,7 @@
 #include "FloatPoint.h"
 #include "FloatQuad.h"
 #include "IntSize.h"
+#include "LayoutTypes.h"
 #include "TransformationMatrix.h"
 #include <wtf/OwnPtr.h>
 
@@ -74,12 +75,12 @@
     
     void setQuad(const FloatQuad& quad) { m_lastPlanarQuad = quad; }
     
-    void move(const IntSize& s, TransformAccumulation accumulate = FlattenTransform)
+    void move(const LayoutSize& s, TransformAccumulation accumulate = FlattenTransform)
     {
         move(s.width(), s.height(), accumulate);
     }
     
-    void move(int x, int y, TransformAccumulation = FlattenTransform);
+    void move(LayoutUnit x, LayoutUnit y, TransformAccumulation = FlattenTransform);
     void applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation = FlattenTransform);
     void applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation = FlattenTransform);
     void flatten();

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


--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp	2012-03-09 20:53:17 UTC (rev 110321)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp	2012-03-09 21:04:26 UTC (rev 110322)
@@ -28,6 +28,7 @@
 #include "TransformationMatrix.h"
 
 #include "AffineTransform.h"
+#include "FractionalLayoutRect.h"
 #include "FloatPoint3D.h"
 #include "FloatRect.h"
 #include "FloatQuad.h"
@@ -587,10 +588,10 @@
 static float clampEdgeValue(float f)
 {
     ASSERT(!isnan(f));
-    return min<float>(max<float>(f, -numeric_limits<int>::max() / 2), numeric_limits<int>::max() / 2);
+    return min<float>(max<float>(f, -numeric_limits<LayoutUnit>::max() / 2), numeric_limits<LayoutUnit>::max() / 2);
 }
 
-IntRect TransformationMatrix::clampedBoundsOfProjectedQuad(const FloatQuad& q) const
+LayoutRect TransformationMatrix::clampedBoundsOfProjectedQuad(const FloatQuad& q) const
 {
     FloatRect mappedQuadBounds = projectQuad(q).boundingBox();
 
@@ -599,18 +600,18 @@
 
     float right;
     if (isinf(mappedQuadBounds.x()) && isinf(mappedQuadBounds.width()))
-        right = numeric_limits<int>::max() / 2;
+        right = numeric_limits<LayoutUnit>::max() / 2;
     else
         right = clampEdgeValue(ceilf(mappedQuadBounds.maxX()));
 
     float bottom;
     if (isinf(mappedQuadBounds.y()) && isinf(mappedQuadBounds.height()))
-        bottom = numeric_limits<int>::max() / 2;
+        bottom = numeric_limits<LayoutUnit>::max() / 2;
     else
         bottom = clampEdgeValue(ceilf(mappedQuadBounds.maxY()));
     
-    return IntRect(clampToInteger(left), clampToInteger(top), 
-                   clampToInteger(right - left), clampToInteger(bottom - top));
+    return LayoutRect(clampToLayoutUnit(left), clampToLayoutUnit(top), 
+                      clampToLayoutUnit(right - left), clampToLayoutUnit(bottom - top));
 }
 
 FloatPoint TransformationMatrix::mapPoint(const FloatPoint& p) const
@@ -640,6 +641,11 @@
     return enclosingIntRect(mapRect(FloatRect(rect)));
 }
 
+FractionalLayoutRect TransformationMatrix::mapRect(const FractionalLayoutRect& r) const
+{
+    return enclosingFractionalLayoutRect(mapRect(FloatRect(r)));
+}
+
 FloatRect TransformationMatrix::mapRect(const FloatRect& r) const
 {
     if (isIdentityOrTranslation()) {

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


--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h	2012-03-09 20:53:17 UTC (rev 110321)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h	2012-03-09 21:04:26 UTC (rev 110322)
@@ -28,6 +28,7 @@
 
 #include "FloatPoint.h"
 #include "IntPoint.h"
+#include "LayoutTypes.h"
 #include <string.h> //for memcpy
 #include <wtf/FastAllocBase.h>
 
@@ -60,6 +61,7 @@
 
 class AffineTransform;
 class IntRect;
+class FractionalLayoutRect;
 class FloatPoint3D;
 class FloatRect;
 class FloatQuad;
@@ -146,6 +148,7 @@
     // Rounds the resulting mapped rectangle out. This is helpful for bounding
     // box computations but may not be what is wanted in other contexts.
     IntRect mapRect(const IntRect&) const;
+    FractionalLayoutRect mapRect(const FractionalLayoutRect&) const;
 
     // If the matrix has 3D components, the z component of the result is
     // dropped, effectively projecting the quad into the z=0 plane
@@ -161,7 +164,7 @@
     FloatQuad projectQuad(const FloatQuad&) const;
     // Projects the four corners of the quad and takes a bounding box,
     // while sanitizing values created when the w component is negative.
-    IntRect clampedBoundsOfProjectedQuad(const FloatQuad&) const;
+    LayoutRect clampedBoundsOfProjectedQuad(const FloatQuad&) const;
 
     double m11() const { return m_matrix[0][0]; }
     void setM11(double f) { m_matrix[0][0] = f; }

Modified: trunk/Source/WebCore/rendering/LayoutTypes.h (110321 => 110322)


--- trunk/Source/WebCore/rendering/LayoutTypes.h	2012-03-09 20:53:17 UTC (rev 110321)
+++ trunk/Source/WebCore/rendering/LayoutTypes.h	2012-03-09 21:04:26 UTC (rev 110322)
@@ -145,6 +145,11 @@
     return numerator % denominator;
 }
 
+inline LayoutUnit clampToLayoutUnit(double value)
+{
+    return clampToInteger(value);
+}
+
 } // namespace WebCore
 
 #endif // LayoutTypes_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to