Title: [123285] trunk
Revision
123285
Author
[email protected]
Date
2012-07-20 19:50:29 -0700 (Fri, 20 Jul 2012)

Log Message

Source/WebCore: [chromium] Take current transformation matrix into account when
deciding on resize algorithm for drawPattern.
https://bugs.webkit.org/show_bug.cgi?id=90624

Reviewed by Adrienne Walker.

Since the pattern shader uses both the current transformation matrix
and the pattern matrix when transforming pixels, we need to
do the same when computing the resampling mode.  Also removed the
resampling hint code, added in r60658, since it appears to be dead
(caller was removed in r76379).

Covered by existing tests, such as
fast/borders/border-image-scale-transform.html.

* platform/graphics/skia/ImageSkia.cpp:
(WebCore::computeResamplingMode):
Pass in the matrix to be used for computing the destination width and
height (for awesome resampling).  Remove the image resampling hint code.
(WebCore::paintSkBitmap):
Pass in the CTM to computeResamplingMode().
(WebCore::Image::drawPattern):
Concatenate the CTM and the pattern matrix, and pass that to
computeResamplingMode() and TransformDimensions().  Invert the
CTM's scale and apply it to the pattern transform, so their
concatenation gives identity scale.
* platform/graphics/skia/PlatformContextSkia.cpp:
* platform/graphics/skia/PlatformContextSkia.h:
Remove the image resampling hint (dead code).

LayoutTests: [chromium] Mark a test as needing a rebaseline due to image change.
https://bugs.webkit.org/show_bug.cgi?id=90624

Reviewed by Adrienne Walker.

* platform/chromium/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (123284 => 123285)


--- trunk/LayoutTests/ChangeLog	2012-07-21 02:46:29 UTC (rev 123284)
+++ trunk/LayoutTests/ChangeLog	2012-07-21 02:50:29 UTC (rev 123285)
@@ -1,3 +1,12 @@
+2012-07-20  Stephen White  <[email protected]>
+
+        [chromium] Mark a test as needing a rebaseline due to image change.
+        https://bugs.webkit.org/show_bug.cgi?id=90624
+
+        Reviewed by Adrienne Walker.
+
+        * platform/chromium/TestExpectations:
+
 2012-07-20  Tony Chang  <[email protected]>
 
         [chromium] Unreviewed, one more new baselines after r123272 (I missed SL).

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (123284 => 123285)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2012-07-21 02:46:29 UTC (rev 123284)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2012-07-21 02:50:29 UTC (rev 123285)
@@ -3611,6 +3611,9 @@
 
 BUGWK91183 : http/tests/w3c/webperf/approved/navigation-timing/html/test_performance_attributes_exist_in_object.html = PASS TEXT
 
+// Needs rebaseline.
+BUGWK90624 : fast/borders/border-image-scale-transform.html = IMAGE
+
 // Fails on Mac 10.7
 BUGWK91255 LION : fast/multicol/table-vertical-align.html = TEXT
 

Modified: trunk/Source/WebCore/ChangeLog (123284 => 123285)


--- trunk/Source/WebCore/ChangeLog	2012-07-21 02:46:29 UTC (rev 123284)
+++ trunk/Source/WebCore/ChangeLog	2012-07-21 02:50:29 UTC (rev 123285)
@@ -1,3 +1,35 @@
+2012-07-20  Stephen White  <[email protected]>
+
+        [chromium] Take current transformation matrix into account when
+        deciding on resize algorithm for drawPattern.
+        https://bugs.webkit.org/show_bug.cgi?id=90624
+
+        Reviewed by Adrienne Walker.
+
+        Since the pattern shader uses both the current transformation matrix
+        and the pattern matrix when transforming pixels, we need to
+        do the same when computing the resampling mode.  Also removed the
+        resampling hint code, added in r60658, since it appears to be dead
+        (caller was removed in r76379).
+
+        Covered by existing tests, such as
+        fast/borders/border-image-scale-transform.html.
+
+        * platform/graphics/skia/ImageSkia.cpp:
+        (WebCore::computeResamplingMode):
+        Pass in the matrix to be used for computing the destination width and
+        height (for awesome resampling).  Remove the image resampling hint code.
+        (WebCore::paintSkBitmap):
+        Pass in the CTM to computeResamplingMode().
+        (WebCore::Image::drawPattern):
+        Concatenate the CTM and the pattern matrix, and pass that to 
+        computeResamplingMode() and TransformDimensions().  Invert the
+        CTM's scale and apply it to the pattern transform, so their
+        concatenation gives identity scale.
+        * platform/graphics/skia/PlatformContextSkia.cpp:
+        * platform/graphics/skia/PlatformContextSkia.h:
+        Remove the image resampling hint (dead code).
+
 2012-07-20  Kwang Yul Seo  <[email protected]>
 
         Anything else in the "in table" insertion mode is a parse error

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


--- trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp	2012-07-21 02:46:29 UTC (rev 123284)
+++ trunk/Source/WebCore/platform/graphics/skia/ImageSkia.cpp	2012-07-21 02:50:29 UTC (rev 123285)
@@ -70,18 +70,8 @@
     RESAMPLE_AWESOME,
 };
 
-static ResamplingMode computeResamplingMode(PlatformContextSkia* platformContext, const NativeImageSkia& bitmap, int srcWidth, int srcHeight, float destWidth, float destHeight)
+static ResamplingMode computeResamplingMode(const SkMatrix& matrix, const NativeImageSkia& bitmap, int srcWidth, int srcHeight, float destWidth, float destHeight)
 {
-    if (platformContext->hasImageResamplingHint()) {
-        IntSize srcSize;
-        FloatSize dstSize;
-        platformContext->getImageResamplingHint(&srcSize, &dstSize);
-        srcWidth = srcSize.width();
-        srcHeight = srcSize.height();
-        destWidth = dstSize.width();
-        destHeight = dstSize.height();
-    }
-
     int destIWidth = static_cast<int>(destWidth);
     int destIHeight = static_cast<int>(destHeight);
 
@@ -147,7 +137,7 @@
 
     // Everything else gets resampled.
     // High quality interpolation only enabled for scaling and translation.
-    if (!(platformContext->canvas()->getTotalMatrix().getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)))
+    if (!(matrix.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)))
         return RESAMPLE_AWESOME;
     
     return RESAMPLE_LINEAR;
@@ -259,7 +249,7 @@
         if (!(canvas->getTotalMatrix().getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)))
             canvas->getTotalMatrix().mapRect(&destRectTarget, destRect);
 
-        resampling = computeResamplingMode(platformContext, bitmap, srcRect.width(), srcRect.height(),
+        resampling = computeResamplingMode(canvas->getTotalMatrix(), bitmap, srcRect.width(), srcRect.height(),
                                            SkScalarToFloat(destRectTarget.width()), SkScalarToFloat(destRectTarget.height()));
     }
 
@@ -353,12 +343,15 @@
         return;
 
     SkIRect srcRect = enclosingIntRect(normSrcRect);
+    SkMatrix ctm = context->platformContext()->canvas()->getTotalMatrix();
+    SkMatrix totalMatrix;
+    totalMatrix.setConcat(ctm, patternTransform);
 
     // 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(patternTransform, srcRect.width(), srcRect.height(),
+    TransformDimensions(totalMatrix, srcRect.width(), srcRect.height(),
                         &destBitmapWidth, &destBitmapHeight);
 
     // Compute the resampling mode.
@@ -366,7 +359,7 @@
     if (context->platformContext()->isAccelerated() || context->platformContext()->printing())
         resampling = RESAMPLE_LINEAR;
     else
-        resampling = computeResamplingMode(context->platformContext(), *bitmap, srcRect.width(), srcRect.height(), destBitmapWidth, destBitmapHeight);
+        resampling = computeResamplingMode(totalMatrix, *bitmap, srcRect.width(), srcRect.height(), destBitmapWidth, destBitmapHeight);
     resampling = limitResamplingMode(context->platformContext(), resampling);
 
     // Load the transform WebKit requested.
@@ -380,10 +373,14 @@
         SkBitmap resampled = bitmap->resizedBitmap(srcRect, width, height);
         shader = SkShader::CreateBitmapShader(resampled, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
 
-        // Since we just resized the bitmap, we need to undo the scale set in
-        // the image transform.
-        matrix.setScaleX(SkIntToScalar(1));
-        matrix.setScaleY(SkIntToScalar(1));
+        // Since we just resized the bitmap, we need to remove the scale 
+        // applied to the pixels in the bitmap shader. This means we need
+        // CTM * patternTransform to have identity scale. Since we
+        // can't modify CTM (or the rectangle will be drawn in the wrong
+        // place), we must set patternTransform's scale to the inverse of
+        // CTM scale.
+        matrix.setScaleX(ctm.getScaleX() ? 1 / ctm.getScaleX() : 1);
+        matrix.setScaleY(ctm.getScaleY() ? 1 / ctm.getScaleY() : 1);
     } else {
         // No need to do nice resampling.
         SkBitmap srcSubset;

Modified: trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp (123284 => 123285)


--- trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	2012-07-21 02:46:29 UTC (rev 123284)
+++ trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	2012-07-21 02:50:29 UTC (rev 123285)
@@ -217,8 +217,6 @@
 
 void PlatformContextSkia::save()
 {
-    ASSERT(!hasImageResamplingHint());
-
     m_stateStack.append(m_state->cloneInheritedProperties());
     m_state = &m_stateStack.last();
 
@@ -606,29 +604,6 @@
 #endif
 }
 
-void PlatformContextSkia::getImageResamplingHint(IntSize* srcSize, FloatSize* dstSize) const
-{
-    *srcSize = m_imageResamplingHintSrcSize;
-    *dstSize = m_imageResamplingHintDstSize;
-}
-
-void PlatformContextSkia::setImageResamplingHint(const IntSize& srcSize, const FloatSize& dstSize)
-{
-    m_imageResamplingHintSrcSize = srcSize;
-    m_imageResamplingHintDstSize = dstSize;
-}
-
-void PlatformContextSkia::clearImageResamplingHint()
-{
-    m_imageResamplingHintSrcSize = IntSize();
-    m_imageResamplingHintDstSize = FloatSize();
-}
-
-bool PlatformContextSkia::hasImageResamplingHint() const
-{
-    return !m_imageResamplingHintSrcSize.isEmpty() && !m_imageResamplingHintDstSize.isEmpty();
-}
-
 void PlatformContextSkia::applyClipFromImage(const SkRect& rect, const SkBitmap& imageBuffer)
 {
     // NOTE: this assumes the image mask contains opaque black for the portions that are to be shown, as such we

Modified: trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h (123284 => 123285)


--- trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h	2012-07-21 02:46:29 UTC (rev 123284)
+++ trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h	2012-07-21 02:50:29 UTC (rev 123285)
@@ -178,11 +178,6 @@
     // if USE(SKIA_TEXT) is enabled, this always returns false
     bool isNativeFontRenderingAllowed();
 
-    void getImageResamplingHint(IntSize* srcSize, FloatSize* dstSize) const;
-    void setImageResamplingHint(const IntSize& srcSize, const FloatSize& dstSize);
-    void clearImageResamplingHint();
-    bool hasImageResamplingHint() const;
-
     bool isAccelerated() const { return m_accelerated; }
     void setAccelerated(bool accelerated) { m_accelerated = accelerated; }
 
@@ -235,10 +230,6 @@
     OpaqueRegionSkia m_opaqueRegion;
     bool m_trackOpaqueRegion;
 
-    // Stores image sizes for a hint to compute image resampling modes.
-    // Values are used in ImageSkia.cpp
-    IntSize m_imageResamplingHintSrcSize;
-    FloatSize m_imageResamplingHintDstSize;
     bool m_printing;
     bool m_accelerated;
     bool m_deferred;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to