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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-2d-globalAlpha.html

Issue 2526693003: Make OffscreenCanvas 2D context support globalAlpha (Closed)
Patch Set: Created 4 years, 1 month 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 | third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-2d-globalAlpha.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-2d-globalAlpha.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-2d-globalAlpha.html
new file mode 100644
index 0000000000000000000000000000000000000000..bb20ad238b2c6da756b918629bb3058d7b6882d4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-2d-globalAlpha.html
@@ -0,0 +1,21 @@
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+test(function() {
+ function assertPixelApprox(ctx, x, y, r, g, b, a, pos, colour, tolerance) {
+ var imgdata = ctx.getImageData(x, y, 1, 1);
+ var diff = Math.max(Math.abs(r-imgdata.data[0]), Math.abs(g-imgdata.data[1]), Math.abs(b-imgdata.data[2]), Math.abs(a-imgdata.data[3]));
+ assert_less_than_equal(diff, tolerance);
+ }
+ var offscreenCanvas = new OffscreenCanvas(100, 100);
+ var ctx = offscreenCanvas.getContext('2d');
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 100, 100);
+ ctx.globalAlpha = 0.01; // avoid any potential alpha = 0 optimisations.
xlai (Olivia) 2016/11/23 17:26:43 Could you use a more obvious number like 0.2, 0.7
+ ctx.beginPath();
+ ctx.fillStyle = '#f00';
+ ctx.rect(0, 0, 100, 100);
+ ctx.fill();
+ assertPixelApprox(ctx, 50, 25, 2, 253, 0, 255, "50,25", "2,253,0,255", 2);
+});
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698