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

Unified Diff: LayoutTests/canvas/thin-drawImages.html

Issue 210043004: Draw thin slices of an image w/ anti-aliasing for 2D <canvas> (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Clarifications. Created 6 years, 9 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
« no previous file with comments | « no previous file | LayoutTests/canvas/thin-drawImages-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/canvas/thin-drawImages.html
diff --git a/LayoutTests/canvas/thin-drawImages.html b/LayoutTests/canvas/thin-drawImages.html
new file mode 100644
index 0000000000000000000000000000000000000000..e9e23d69670f221ffcce78c5f4d34260c3f029f0
--- /dev/null
+++ b/LayoutTests/canvas/thin-drawImages.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<title>Canvas.drawImage with narrow destination.</title>
+<script src="../resources/js-test.js"></script>
+<script>
+function verifyCovered(imgData, offset, stride, length) {
+ while (length) {
+ if (imgData[offset + 3] === 0)
+ return false;
+ offset += stride * 4;
+ length--;
+ }
+ return true;
+}
+
+ImageData.prototype.pixelOffset = function(x, y) {
+ return (x + y * this.width) * 4;
+}
+
+var sourceImage = document.createElement("canvas");
+sourceImage.height = sourceImage.width = 1;
+sourceImage.getContext("2d").fillRect(0, 0, 1, 1);
+
+var c = document.createElement("canvas");
+c.width = c.height = 100;
+var ctx = c.getContext("2d");
+
+// Thin horizontal image.
+ctx.drawImage(sourceImage, 10, 5.5, 10, 0.95);
+
+// Thin vertical image.
+ctx.drawImage(sourceImage, 5.5, 5, 0.95, 10);
+
+// Rotated 90 degrees
+ctx.save();
+ctx.translate(20, 15);
+ctx.rotate(Math.PI / 2);
+ctx.drawImage(sourceImage, 0, -.5, 10, 0.95);
+ctx.restore();
+
+// Rotated -90 degrees
+ctx.save();
+ctx.translate(25, 15);
+ctx.rotate(-Math.PI / 2);
+ctx.drawImage(sourceImage, -.5, 0, 0.95, 10);
+ctx.restore();
+
+imgData = ctx.getImageData(0, 0, c.width, c.height);
+shouldBeTrue("verifyCovered(imgData.data, imgData.pixelOffset(10, 5), 1, 10)");
+shouldBeTrue("verifyCovered(imgData.data, imgData.pixelOffset(5, 5), imgData.width, 10)");
+shouldBeTrue("verifyCovered(imgData.data, imgData.pixelOffset(25, 15), 1, 10)");
+shouldBeTrue("verifyCovered(imgData.data, imgData.pixelOffset(20, 15), imgData.width, 10)");
+
+successfullyParsed = true;
+</script>
« no previous file with comments | « no previous file | LayoutTests/canvas/thin-drawImages-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698