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

Side by Side 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: TC. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Canvas.drawImage with narrow destination.</title>
3 <script src="../resources/js-test.js"></script>
4 <script>
5 function verifyCovered(imgData, offset, stride, length) {
6 while (length) {
7 if (imgData[offset + 3] === 0)
8 break;
Justin Novosad 2014/03/25 14:35:07 Nit: I think it would be more readable if you just
fs 2014/03/25 17:18:51 Done.
9 offset += stride * 4;
10 length--;
11 }
12 return length === 0;
13 }
14
15 ImageData.prototype.pixelOffset = function(x, y) {
16 return (x + y * this.width) * 4;
17 }
18
19 var sourceImage = document.createElement("canvas");
20 sourceImage.height = sourceImage.width = 1;
21 sourceImage.getContext("2d").fillRect(0, 0, 1, 1);
22
23 var c = document.createElement("canvas");
24 c.width = c.height = 100;
25 var ctx = c.getContext("2d");
26
27 // Thin horizontal image.
28 ctx.drawImage(sourceImage, 10, 5.5, 10, 0.95);
29
30 // Thin vertical image.
31 ctx.drawImage(sourceImage, 5.5, 5, 0.95, 10);
32
33 // Rotated 90 degrees
34 ctx.save();
35 ctx.translate(20, 15);
36 ctx.rotate(Math.PI / 2);
37 ctx.drawImage(sourceImage, 0, -.5, 10, 0.95);
38 ctx.restore();
39
40 // Rotated -90 degrees
41 ctx.save();
42 ctx.translate(25, 15);
43 ctx.rotate(-Math.PI / 2);
44 ctx.drawImage(sourceImage, -.5, 0, 0.95, 10);
45 ctx.restore();
46
47 imgData = ctx.getImageData(0, 0, c.width, c.height);
48 shouldBeTrue("verifyCovered(imgData.data, imgData.pixelOffset(10, 5), 1, 10)");
49 shouldBeTrue("verifyCovered(imgData.data, imgData.pixelOffset(5, 5), imgData.wid th, 10)");
50 shouldBeTrue("verifyCovered(imgData.data, imgData.pixelOffset(25, 15), 1, 10)");
51 shouldBeTrue("verifyCovered(imgData.data, imgData.pixelOffset(20, 15), imgData.w idth, 10)");
52
53 successfullyParsed = true;
54 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/canvas/thin-drawImages-expected.txt » ('j') | Source/platform/graphics/skia/NativeImageSkia.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698