[Skia] Computing the resampling mode ignores scale applied to the canvas
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jun 2012 19:37:20 +0000 (19:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jun 2012 19:37:20 +0000 (19:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72073

Patch by Zeev Lieber <zlieber@chromium.org> on 2012-06-28
Reviewed by Stephen White.

Source/WebCore:

Re-basing earlier patch by Daniel Sievers; updated tests.

Take into account canvas scale when computing image resampling mode.

When drawing a bitmap and computing the best resampling mode based
on the requested scale, take into account CSS scale and page scale
that are applied to the canvas. This allows for single-pass scaling
in potentially better quality (RESAMPLE_AWESOME) and also takes
better advantage of the scaled image cache in that codepath.

Existing tests updated to expect different resampling method (and
therefore a different image) whenever canvas scaling changes.

* platform/graphics/skia/ImageSkia.cpp:
(WebCore::paintSkBitmap):

LayoutTests:

Updated tests to expect different image when resampling method changed.

* platform/chromium-linux/fast/borders/border-image-scale-transform-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorEnd-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorMiddle-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorStart-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorEnd-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorMiddle-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorStart-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorEnd-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorMiddle-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorStart-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorEnd-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorMiddle-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorStart-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorEnd-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorMiddle-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorStart-expected.png:
* platform/chromium-linux/svg/W3C-I18N/text-anchor-no-markup-expected.png:
* platform/chromium-linux/svg/W3C-SVG-1.1/render-groups-01-b-expected.png:
* platform/chromium-linux/svg/W3C-SVG-1.1/render-groups-03-t-expected.png:
* platform/chromium-linux/svg/W3C-SVG-1.1/struct-symbol-01-b-expected.png:
* platform/chromium-linux/svg/carto.net/scrollbar-expected.png:
* platform/chromium-linux/svg/custom/image-small-width-height-expected.png:
* platform/chromium-linux/svg/custom/scrolling-embedded-svg-file-image-repaint-problem-expected.png:
* platform/chromium-linux/transitions/cross-fade-background-image-expected.png:
* platform/chromium/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121452 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium-linux/fast/borders/border-image-scale-transform-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorEnd-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorMiddle-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorStart-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorEnd-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorMiddle-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorStart-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorEnd-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorMiddle-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorStart-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorEnd-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorMiddle-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorStart-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorEnd-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorMiddle-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorStart-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-no-markup-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-SVG-1.1/render-groups-01-b-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-SVG-1.1/render-groups-03-t-expected.png
LayoutTests/platform/chromium-linux/svg/W3C-SVG-1.1/struct-symbol-01-b-expected.png
LayoutTests/platform/chromium-linux/svg/carto.net/scrollbar-expected.png
LayoutTests/platform/chromium-linux/svg/custom/image-small-width-height-expected.png
LayoutTests/platform/chromium-linux/svg/custom/scrolling-embedded-svg-file-image-repaint-problem-expected.png
LayoutTests/platform/chromium-linux/transitions/cross-fade-background-image-expected.png
LayoutTests/platform/chromium/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/skia/ImageSkia.cpp

index acb53a1..6664541 100644 (file)
@@ -1,3 +1,38 @@
+2012-06-28  Zeev Lieber  <zlieber@chromium.org>
+
+        [Skia] Computing the resampling mode ignores scale applied to the canvas
+        https://bugs.webkit.org/show_bug.cgi?id=72073
+
+        Reviewed by Stephen White.
+
+        Updated tests to expect different image when resampling method changed.
+
+        * platform/chromium-linux/fast/borders/border-image-scale-transform-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorEnd-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorMiddle-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorStart-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorEnd-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorMiddle-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorStart-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorEnd-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorMiddle-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorStart-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorEnd-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorMiddle-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorStart-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorEnd-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorMiddle-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorStart-expected.png:
+        * platform/chromium-linux/svg/W3C-I18N/text-anchor-no-markup-expected.png:
+        * platform/chromium-linux/svg/W3C-SVG-1.1/render-groups-01-b-expected.png:
+        * platform/chromium-linux/svg/W3C-SVG-1.1/render-groups-03-t-expected.png:
+        * platform/chromium-linux/svg/W3C-SVG-1.1/struct-symbol-01-b-expected.png:
+        * platform/chromium-linux/svg/carto.net/scrollbar-expected.png:
+        * platform/chromium-linux/svg/custom/image-small-width-height-expected.png:
+        * platform/chromium-linux/svg/custom/scrolling-embedded-svg-file-image-repaint-problem-expected.png:
+        * platform/chromium-linux/transitions/cross-fade-background-image-expected.png:
+        * platform/chromium/TestExpectations:
+
 2012-06-28  Tony Chang  <tony@chromium.org>
 
         Split flex into flex-grow/flex-shrink/flex-basis
index 34f43f4..35a9ecd 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/fast/borders/border-image-scale-transform-expected.png and b/LayoutTests/platform/chromium-linux/fast/borders/border-image-scale-transform-expected.png differ
index 75cc7d0..103dec5 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorEnd-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorEnd-expected.png differ
index a1e343a..4414fd3 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorMiddle-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorMiddle-expected.png differ
index 686efa0..604fb85 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorStart-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirLTR-anchorStart-expected.png differ
index 75cc7d0..103dec5 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorEnd-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorEnd-expected.png differ
index a1e343a..4414fd3 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorMiddle-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorMiddle-expected.png differ
index 686efa0..604fb85 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorStart-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirNone-anchorStart-expected.png differ
index 686efa0..604fb85 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorEnd-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorEnd-expected.png differ
index a1e343a..4414fd3 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorMiddle-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorMiddle-expected.png differ
index 75cc7d0..103dec5 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorStart-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-dirRTL-anchorStart-expected.png differ
index 75cc7d0..103dec5 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorEnd-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorEnd-expected.png differ
index a1e343a..4414fd3 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorMiddle-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorMiddle-expected.png differ
index 686efa0..604fb85 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorStart-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorStart-expected.png differ
index 686efa0..604fb85 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorEnd-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorEnd-expected.png differ
index a1e343a..4414fd3 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorMiddle-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorMiddle-expected.png differ
index 75cc7d0..103dec5 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorStart-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorStart-expected.png differ
index 686efa0..604fb85 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-no-markup-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-I18N/text-anchor-no-markup-expected.png differ
index 99382e2..fefc497 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-SVG-1.1/render-groups-01-b-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-SVG-1.1/render-groups-01-b-expected.png differ
index ffe89d6..2fcc2c7 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-SVG-1.1/render-groups-03-t-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-SVG-1.1/render-groups-03-t-expected.png differ
index 45a14da..ede8ac6 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/W3C-SVG-1.1/struct-symbol-01-b-expected.png and b/LayoutTests/platform/chromium-linux/svg/W3C-SVG-1.1/struct-symbol-01-b-expected.png differ
index 78c293e..78f6487 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/carto.net/scrollbar-expected.png and b/LayoutTests/platform/chromium-linux/svg/carto.net/scrollbar-expected.png differ
index 6e8a8a5..0c8febf 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/custom/image-small-width-height-expected.png and b/LayoutTests/platform/chromium-linux/svg/custom/image-small-width-height-expected.png differ
index f04477f..f8e34c2 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/svg/custom/scrolling-embedded-svg-file-image-repaint-problem-expected.png and b/LayoutTests/platform/chromium-linux/svg/custom/scrolling-embedded-svg-file-image-repaint-problem-expected.png differ
index 62e919f..1e92908 100644 (file)
Binary files a/LayoutTests/platform/chromium-linux/transitions/cross-fade-background-image-expected.png and b/LayoutTests/platform/chromium-linux/transitions/cross-fade-background-image-expected.png differ
index a82aa43..685f872 100644 (file)
@@ -161,6 +161,33 @@ BUGWK85262 SKIP : fast/css/image-resolution = PASS
 // Chromium needs larger media files to test buffering this way.
 BUGWK88172 SKIP : http/tests/media/video-buffered.html = PASS
 
+// Remove after rebaselined images are available.
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorStart.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-dirRTL-anchorStart.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-dirLTR-anchorEnd.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-dirRTL-anchorEnd.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorMiddle.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-dirLTR-anchorStart.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorMiddle.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorEnd.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-dirNone-anchorStart.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-dirLTR-anchorMiddle.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-dirNone-anchorMiddle.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-dirNone-anchorEnd.svg = IMAGE
+BUGWK72073 MAC WIN : fast/borders/border-image-scale-transform.html = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-inherited-dirLTR-anchorEnd.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-dirRTL-anchorMiddle.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-SVG-1.1/render-groups-03-t.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-no-markup.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-SVG-1.1/render-groups-01-b.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-SVG-1.1/render-groups-03-t.svg = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-SVG-1.1/struct-symbol-01-b.svg = IMAGE
+BUGWK72073 MAC WIN : svg/carto.net/scrollbar.svg = IMAGE
+BUGWK72073 MAC WIN : svg/custom/image-small-width-height.svg = IMAGE
+BUGWK72073 MAC WIN : svg/custom/scrolling-embedded-svg-file-image-repaint-problem.html = IMAGE
+BUGWK72073 MAC WIN : transitions/cross-fade-background-image.html = IMAGE
+BUGWK72073 MAC WIN : svg/W3C-I18N/text-anchor-inherited-dirRTL-anchorStart.svg = IMAGE
+
 // -----------------------------------------------------------------
 // WONTFIX TESTS
 // -----------------------------------------------------------------
index 9a9ac70..8f6f38e 100644 (file)
@@ -1,3 +1,26 @@
+2012-06-28  Zeev Lieber  <zlieber@chromium.org>
+
+        [Skia] Computing the resampling mode ignores scale applied to the canvas
+        https://bugs.webkit.org/show_bug.cgi?id=72073
+
+        Reviewed by Stephen White.
+
+        Re-basing earlier patch by Daniel Sievers; updated tests.
+
+        Take into account canvas scale when computing image resampling mode.
+
+        When drawing a bitmap and computing the best resampling mode based
+        on the requested scale, take into account CSS scale and page scale
+        that are applied to the canvas. This allows for single-pass scaling
+        in potentially better quality (RESAMPLE_AWESOME) and also takes
+        better advantage of the scaled image cache in that codepath.
+
+        Existing tests updated to expect different resampling method (and
+        therefore a different image) whenever canvas scaling changes.
+
+        * platform/graphics/skia/ImageSkia.cpp:
+        (WebCore::paintSkBitmap):
+
 2012-06-28  James Robinson  <jamesr@chromium.org>
 
         [chromium] Should schedule a commit when dropping contents textures
index 81dfa3a..6a4bcb0 100644 (file)
@@ -251,9 +251,18 @@ static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImag
     ResamplingMode resampling;
     if (platformContext->isAccelerated())
         resampling = RESAMPLE_LINEAR;
-    else
-        resampling = platformContext->printing() ? RESAMPLE_NONE :
-            computeResamplingMode(platformContext, bitmap, srcRect.width(), srcRect.height(), SkScalarToFloat(destRect.width()), SkScalarToFloat(destRect.height()));
+    else if (platformContext->printing())
+        resampling = RESAMPLE_NONE;
+    else {
+        // Take into account scale applied to the canvas when computing sampling mode (e.g. CSS scale or page scale).
+        SkRect destRectTarget = destRect;
+        if (!(canvas->getTotalMatrix().getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)))
+            canvas->getTotalMatrix().mapRect(&destRectTarget, destRect);
+
+        resampling = computeResamplingMode(platformContext, bitmap, srcRect.width(), srcRect.height(),
+                                           SkScalarToFloat(destRectTarget.width()), SkScalarToFloat(destRectTarget.height()));
+    }
+
     if (resampling == RESAMPLE_NONE) {
       // FIXME: This is to not break tests (it results in the filter bitmap flag
       // being set to true). We need to decide if we respect RESAMPLE_NONE