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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-2d-clip-anti-aliasing.html

Issue 2359843003: Turning on clip anti-aliasing by default in Chrome. (Closed)
Patch Set: Addressing comments. Created 4 years, 3 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 | « content/renderer/render_view_impl.cc ('k') | third_party/WebKit/Source/core/frame/Settings.in » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-2d-clip-anti-aliasing.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-2d-clip-anti-aliasing.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-2d-clip-anti-aliasing.html
new file mode 100644
index 0000000000000000000000000000000000000000..0d0b6c58532755b33feff8ea81fdd75699b8c383
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-2d-clip-anti-aliasing.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<canvas id="myCanvas" width="240" height="240" style="border:1px solid #d3d3d3;"></canvas>
+
+<script>
+
+test(function() {
+ var c = document.getElementById("myCanvas");
+ var ctx = c.getContext("2d");
+
+ ctx.beginPath();
+ ctx.moveTo(120, 20);
+ ctx.lineTo(220, 120);
+ ctx.lineTo(120, 220);
+ ctx.lineTo(20, 120);
+ ctx.lineTo(120, 20);
+ ctx.closePath();
+ ctx.clip();
+
+ ctx.lineWidth = 1;
+ ctx.strokeStyle="#FF0000";
+ ctx.stroke();
+
+ // Verifies that a stroke inside a clip of the same path displays correctly.
+ // Some sides of the shape may be clipped-out if stroking is anti-aliased
+ // but not clipping, or if clipping it is not properly aligned.
+ // We check pixels located on the vertices and in the middle of each edge.
+ var pixels = [ [120, 20], [170, 70], [220, 120], [170, 170],
+ [120, 220], [70, 170], [20, 120], [70, 70] ];
+
+ // There can be false alarms if we look at the exact points (specially the
+ // vertices) as the anti-aliasing algorithm may find it enough to draw some
+ // surrounding points. Therefore, we look at a 3x3 rectangle surrounding
+ // each point.
+ for(i = 0; i < 8; i++) {
+ var pixelDrawn = false;
+ for(j = -1; j <=1; j++) {
+ for(k = -1; k <=1; k++) {
+ var colorData = ctx.getImageData(pixels[i][0] + j, pixels[i][1] + k, 1, 1).data;
+ if(colorData[0] == 255 && colorData[3] > 0) {
+ pixelDrawn = true;
+ }
+ }
+ }
+
+ assert_equals(pixelDrawn, true);
+ }
+
+}, 'This test verifies that stroke inside a clip of the same path displays correctly.');
+
+</script>
+
+
+
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | third_party/WebKit/Source/core/frame/Settings.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698