Title: [124042] trunk
Revision
124042
Author
[email protected]
Date
2012-07-30 10:22:35 -0700 (Mon, 30 Jul 2012)

Log Message

[chromium] Refactor the computation of resampled bitmap size in
drawImage and drawPattern.
https://bugs.webkit.org/show_bug.cgi?id=92408

Reviewed by Adrienne Walker.

Source/WebCore: 

We used to have a special-purpose function called TransformDimensions()
which did pretty much the same thing as SkRect::mapRect() does.  This
change unifies the drawPattern code to use mapRect() in the same way
that drawImage() does.

Covered by existing tests, e.g., fast/backgrounds/size/*.

* platform/graphics/skia/ImageSkia.cpp:
(WebCore):
(WebCore::Image::drawPattern):
Note:  we're now doing using the original (float) source rect, and
converting to int only after applying the matrix transform.  This
might result in different decisions about resampling mode, but it's
more correct anyway.

LayoutTests: 

Mark a test as expected to fail (will need rebaseline).

* platform/chromium/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (124041 => 124042)


--- trunk/LayoutTests/ChangeLog	2012-07-30 17:19:18 UTC (rev 124041)
+++ trunk/LayoutTests/ChangeLog	2012-07-30 17:22:35 UTC (rev 124042)
@@ -1,3 +1,15 @@
+2012-07-26  Stephen White  <[email protected]>
+
+        [chromium] Refactor the computation of resampled bitmap size in
+        drawImage and drawPattern.
+        https://bugs.webkit.org/show_bug.cgi?id=92408
+
+        Reviewed by Adrienne Walker.
+
+        Mark a test as expected to fail (will need rebaseline).
+
+        * platform/chromium/TestExpectations:
+
 2012-07-30  Dominik Röttsches  <[email protected]>
 
         [EFL][DRT] fast/text/font-variant-ligatures.html fails with missing rendering output

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (124041 => 124042)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2012-07-30 17:19:18 UTC (rev 124041)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2012-07-30 17:22:35 UTC (rev 124042)
@@ -3045,6 +3045,9 @@
 BUGWK81145 LION : fast/writing-mode/broken-ideographic-font.html = CRASH
 BUGWK81145 LION : fast/writing-mode/japanese-rl-text-with-broken-font.html = CRASH
 
+// Needs rebaseline.
+BUGWK92059 : fast/gradients/background-clipped.html = IMAGE
+
 BUGYANGGUO MAC : fast/repaint/moving-shadow-on-container.html = TEXT
 
 BUGWK81537 : fast/events/touch/gesture/pad-gesture-fling.html = TEXT PASS

Modified: trunk/Source/WebCore/ChangeLog (124041 => 124042)


--- trunk/Source/WebCore/ChangeLog	2012-07-30 17:19:18 UTC (rev 124041)
+++ trunk/Source/WebCore/ChangeLog	2012-07-30 17:22:35 UTC (rev 124042)
@@ -1,3 +1,26 @@
+2012-07-26  Stephen White  <[email protected]>
+
+        [chromium] Refactor the computation of resampled bitmap size in
+        drawImage and drawPattern.
+        https://bugs.webkit.org/show_bug.cgi?id=92408
+
+        Reviewed by Adrienne Walker.
+
+        We used to have a special-purpose function called TransformDimensions()
+        which did pretty much the same thing as SkRect::mapRect() does.  This
+        change unifies the drawPattern code to use mapRect() in the same way
+        that drawImage() does.
+
+        Covered by existing tests, e.g., fast/backgrounds/size/*.
+
+        * platform/graphics/skia/ImageSkia.cpp:
+        (WebCore):
+        (WebCore::Image::drawPattern):
+        Note:  we're now doing using the original (float) source rect, and
+        converting to int only after applying the matrix transform.  This
+        might result in different decisions about resampling mode, but it's
+        more correct anyway.
+
 2012-07-30  Vineet Chaudhary  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=92642

Modified: trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp (124041 => 124042)


--- trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp	2012-07-30 17:19:18 UTC (rev 124041)
+++ trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp	2012-07-30 17:22:35 UTC (rev 124042)
@@ -274,25 +274,6 @@
     platformContext->didDrawRect(destRect, paint, &bitmap.bitmap());
 }
 
-// Transforms the given dimensions with the given matrix. Used to see how big
-// images will be once transformed.
-static void TransformDimensions(const SkMatrix& matrix, float srcWidth, float srcHeight, float* destWidth, float* destHeight)
-{
-    // Transform 3 points to see how long each side of the bitmap will be.
-    SkPoint srcPoints[3]; // (0, 0), (width, 0), (0, height).
-    srcPoints[0].set(0, 0);
-    srcPoints[1].set(SkFloatToScalar(srcWidth), 0);
-    srcPoints[2].set(0, SkFloatToScalar(srcHeight));
-
-    // Now measure the length of the two transformed vectors relative to the
-    // transformed origin to see how big the bitmap will be. Note: for skews,
-    // this isn't the best thing, but we don't have skews.
-    SkPoint destPoints[3];
-    matrix.mapPoints(destPoints, srcPoints, 3);
-    *destWidth = SkScalarToFloat((destPoints[1] - destPoints[0]).length());
-    *destHeight = SkScalarToFloat((destPoints[2] - destPoints[0]).length());
-}
-
 // A helper method for translating negative width and height values.
 FloatRect normalizeRect(const FloatRect& rect)
 {
@@ -350,10 +331,12 @@
     // Figure out what size the bitmap will be in the destination. The
     // destination rect is the bounds of the pattern, we need to use the
     // matrix to see how big it will be.
-    float destBitmapWidth, destBitmapHeight;
-    TransformDimensions(totalMatrix, srcRect.width(), srcRect.height(),
-                        &destBitmapWidth, &destBitmapHeight);
+    SkRect destRectTarget;
+    totalMatrix.mapRect(&destRectTarget, normSrcRect);
 
+    float destBitmapWidth = SkScalarToFloat(destRectTarget.width());
+    float destBitmapHeight = SkScalarToFloat(destRectTarget.height());
+
     // Compute the resampling mode.
     ResamplingMode resampling;
     if (context->platformContext()->isAccelerated() || context->platformContext()->printing())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to