Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-imageSmoothing-disabled-scaling-down.html

Issue 2157953002: Change filter quality when scaling-down in drawImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change expected.txt Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-imageSmoothing-disabled-scaling-down.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-imageSmoothing-disabled-scaling-down.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-imageSmoothing-disabled-scaling-down.html
new file mode 100644
index 0000000000000000000000000000000000000000..e40b901b776ed04b09f9531cbca302173687f9a3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-imageSmoothing-disabled-scaling-down.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+function getCanvasDataFromDrawImage(source, disableSmoothing, shouldTransform)
+{
+ var canvas = document.createElement("canvas");
+ canvas.width = 100;
+ canvas.height = 100;
+ var ctx = canvas.getContext("2d");
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ if (disableSmoothing)
+ ctx.imageSmoothingEnabled = false;
+ if (shouldTransform) {
+ ctx.transform(0.5, 0, 0, 0.5, 0, 0); //scaling down
+ ctx.drawImage(source, 0, 0, source.width, source.height, 0, 0, 100, 100);
+ } else {
+ ctx.drawImage(source, 0, 0, source.width, source.height, 0, 0, 50, 50);
+ }
+ var d = ctx.getImageData(0, 0, 100, 100).data;
+ return d;
+}
+
+test(function() {
+ var canvas = document.createElement('canvas');
+ canvas.height = 100;
+ canvas.width = 100;
+ var ctx = canvas.getContext('2d');
+ ctx.fillStyle = '#FF0000';
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ var data1 = getCanvasDataFromDrawImage(canvas, false, false);
+ var data2 = getCanvasDataFromDrawImage(canvas, true, false);
+ var data3 = getCanvasDataFromDrawImage(canvas, true, true);
+ assert_array_equals(data1, data2, "drawImage() should have the same results with imageSmoothingEnabled = true and false when scaling down.");
+ assert_array_equals(data1, data3, "drawImage() should account for canvas transformation when testing whether it is scaling down the source or not");
+}, 'Test drawImage with imageSmoothingEnabled=false and scaling down the source.');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698