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

Side by Side Diff: LayoutTests/compositing/webgl/webgl-copy-image.html

Issue 389273002: Fix copyImage for WebGL elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: added test for negative input Created 6 years, 5 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
« no previous file with comments | « no previous file | LayoutTests/compositing/webgl/webgl-copy-image-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!-- This is a test for crbug.com/392765, in which Copy image for
2 WebGL elements were crashing. Must be run with the threaded
3 compositor enabled. -->
4 <head>
5 <script src="../../resources/js-test.js"></script>
6 <script>
7 var gl;
8
9 function main()
10 {
11 if (!window.testRunner) {
12 testFailed("Requires window.testRunner");
13 } else {
14 testRunner.waitUntilDone();
15 testRunner.dumpAsText();
16 window.requestAnimationFrame(initTest);
17 }
18 }
19
20 var tolerance = 1;
21
22 function initTest() {
23 var canvas = document.getElementById("c");
24 gl = canvas.getContext("webgl");
25 if (!gl) {
26 testFailed("Test requires WebGL");
27 testRunner.notifyDone();
28 return;
29 }
30
31 gl.clearColor(1, 0, 0, 1);
32 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
33
34 window.requestAnimationFrame(runTest);
35 }
36
37 var testsAndExpectations = [
38 { 'point': [50, 50], 'expected': 'exists' },
39 { 'point': [400, 400], 'expected': 'does not exist' }
40 ];
41
42 var testIndex = 0;
43 function runTest() {
44 if (testIndex >= testsAndExpectations.length) {
45 testRunner.notifyDone();
46 return;
47 }
48
49 try {
50 var test = testsAndExpectations[testIndex];
51 var point = test['point'];
52 testRunner.copyImageAtAndCapturePixelsAsyncThen(point[0], point[1], completi onCallback);
53 } catch (e) {
54 debug('error in runTest');
55 debug(e);
56 testRunner.notifyDone();
57 }
58 }
59
60 var pixel;
61 function fetchPixelAt(x, y, width, height, snapshot) {
62 var data = new Uint8Array(snapshot);
63 pixel = [
64 data[4 * (width * y + x) + 0],
65 data[4 * (width * y + x) + 1],
66 data[4 * (width * y + x) + 2],
67 data[4 * (width * y + x) + 3]
68 ];
69 }
70
71 function completionCallback(width, height, snapshot) {
72 try {
73 var test = testsAndExpectations[testIndex];
74 var point = test['point'];
75 debug('Test ' + testIndex + ": WebGL element " + test['expected'] + ' at ' + point);
76
77 if (width > 0 && height > 0) {
Ken Russell (switch to Gerrit) 2014/07/17 21:32:31 This doesn't actually verify that the attempt to f
hj.r.chung 2014/07/18 06:31:39 Done.
78 fetchPixelAt(50, 50, width, height, snapshot);
79 shouldBeCloseTo('pixel[0]', 255, tolerance);
80 shouldBeCloseTo('pixel[1]', 0, tolerance);
81 shouldBeCloseTo('pixel[2]', 0, tolerance);
82 }
83 } catch (e) {
84 debug('error in completionCallback');
85 debug(e);
86 testRunner.notifyDone();
87 return;
88 }
89
90 ++testIndex;
91 window.requestAnimationFrame(runTest);
92 }
93
94 main();
95 </script>
96 </head>
97 <body>
98 <canvas id="c" width="200" height="200" class="nomargin"></canvas>
99 <div id="console"></div>
100 </body>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/compositing/webgl/webgl-copy-image-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698