Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE html> |
| 2 <!-- Test based on that found at | 2 <!-- Test based on that found at |
| 3 http://http://philip.html5.org/tests/canvas/suite/tests/index.2d.composite. globalAlpha.html | 3 http://philip.html5.org/tests/canvas/suite/tests/index.2d.composite.globalA lpha.html |
| 4 --> | 4 --> |
| 5 <html> | 5 <title>The test to ensure correct sync behaviour with globalAlpha and fillPath() in accelerated-2d-canvas mode.</title> |
|
fs
2016/08/25 11:16:48
Nit: Drop "The test to ensure" (and capitalize "co
sivag
2016/08/25 13:29:27
Done.
| |
| 6 <head> | 6 <script src="../../resources/testharness.js"></script> |
| 7 <script src="../../resources/js-test.js"></script> | 7 <script src="../../resources/testharnessreport.js"></script> |
| 8 </head> | 8 <canvas width="100" height="100"></canvas> |
| 9 <body> | |
| 10 <canvas id="canvas" width="100" height="100"></canvas> | |
| 11 <script> | 9 <script> |
| 12 | 10 test(function() { |
| 13 function assertPixelApprox(ctx, x,y, r,g,b,a, pos, colour, tolerance) | 11 function assertPixelApprox(ctx, x,y, r,g,b,a, pos, colour, tolerance) { |
| 14 { | 12 var imgdata = ctx.getImageData(x, y, 1, 1); |
| 15 var imgdata = ctx.getImageData(x, y, 1, 1); | 13 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])); |
| 16 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])); | 14 assert_greater_than(diff, tolerance); |
|
fs
2016/08/25 11:16:48
Actually, the assertion should be the other way ar
sivag
2016/08/25 13:29:27
Done.
| |
| 17 shouldBeFalse((diff > tolerance).toString()); | 15 } |
| 18 } | 16 var ctx = document.querySelector('canvas').getContext('2d'); |
| 19 | 17 ctx.fillStyle = '#0f0'; |
| 20 description("The test to ensure correct sync behaviour with globalAlpha and fill Path() in accelerated-2d-canvas mode."); | 18 ctx.fillRect(0, 0, 100, 100); |
| 21 var ctx = document.getElementById('canvas').getContext('2d'); | 19 ctx.globalAlpha = 0.01; // avoid any potential alpha = 0 optimisations. |
| 22 | 20 ctx.beginPath(); |
| 23 ctx.fillStyle = '#0f0'; | 21 ctx.fillStyle = '#f00'; |
| 24 ctx.fillRect(0, 0, 100, 100); | 22 ctx.rect(0, 0, 100, 100); |
| 25 ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations | 23 ctx.fill(); |
| 26 ctx.beginPath(); | 24 assertPixelApprox(ctx, 50,25, 2,253,0,255, "50,25", "2,253,0,255", 2); |
| 27 ctx.fillStyle = '#f00'; | 25 }); |
| 28 ctx.rect(0, 0, 100, 100); | |
| 29 ctx.fill(); | |
| 30 assertPixelApprox(ctx, 50,25, 2,253,0,255, "50,25", "2,253,0,255", 2); | |
| 31 | |
| 32 </script> | 26 </script> |
| 33 </body> | |
| 34 </html> | |
| 35 | |
| OLD | NEW |