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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/webgl/renderbuffer-initialization.html

Issue 1601093008: Remove duplicated WebGL layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../../../resources/js-test.js"></script>
4 <script src="resources/webgl-test.js"></script>
5 <script>
6 function runTest(gl, width, height)
7 {
8
9 debug('Test whether the WebGL internal buffers have been initialized to 0.') ;
10 var totalBytes = width * height * 4;
11 var buf = new Uint8Array(totalBytes);
12 gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
13 if (gl.getError() != gl.NO_ERROR) {
14 testFailed('GL error detected after readPixels().');
15 return false;
16 }
17 for (var i = 0; i < totalBytes; ++i) {
18 if (buf[i] != 0) {
19 testFailed('WebGL internal buffers are dirty.');
20 return false;
21 }
22 }
23 testPassed('Buffers have been initialized to 0.');
24
25 debug('Test whether user created buffers have been initialized to 0.');
26 var fbo = gl.createFramebuffer();
27 gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
28 var colorbuffer = gl.createRenderbuffer();
29 gl.bindRenderbuffer(gl.RENDERBUFFER, colorbuffer);
30 gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, width, height);
31 if (gl.getError() != gl.NO_ERROR) {
32 testFailed('GL error detected after renderbufferStorage(internalformat = RGBA4).');
33 return false;
34 }
35 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBU FFER, colorbuffer);
36 if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
37 testFailed('Framebuffer incomplete.');
38 return false;
39 }
40 gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
41 if (gl.getError() != gl.NO_ERROR) {
42 testFailed('GL error detected after readPixels().');
43 return false;
44 }
45 for (var i = 0; i < totalBytes; ++i) {
46 if (buf[i] != 0) {
47 testFailed('User created buffers are dirty.');
48 return false;
49 }
50 }
51
52 testPassed('Buffers have been initialized to 0.');
53 return true;
54 }
55 </script>
56 </head>
57 <body>
58 <canvas id="testbed" width="400px" height="400px"></canvas>
59 <div id="description"></div>
60 <div id="console"></div>
61 <script>
62
63 description('Verify renderbuffers are initialized to 0 before being read in WebG L');
64
65 var canvas = document.getElementById("testbed");
66 var gl = canvas.getContext("webgl");
67 if (gl) {
68 runTest(gl, canvas.width, canvas.height);
69
70 // Testing that canvas resizing will clear the buffers with 0 instead of the current clear values.
71 gl.clearColor(1, 0, 0, 1);
72 canvas.width += 1;
73 canvas.height += 1;
74 runTest(gl, canvas.width, canvas.height);
75
76 // Testing buffer clearing won't change the clear values.
77 var clearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE);
78 shouldBe("clearColor", "[1, 0, 0, 1]");
79 } else
80 testFailed('canvas.getContext() failed');
81 </script>
82 </body>
83 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698