Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <body> | 3 <body> |
| 4 <span id="description" style="color: white"> | 4 <span id="description" style="color: white"> |
| 5 This test checks for drawing webgl to canvas 2d. The test process is as follows: | 5 This test checks for drawing webgl to canvas 2d. The test process is as follows: |
| 6 1. draw a green rect on a webgl context. | 6 1. draw a green rect on a webgl context. |
| 7 2. draw a red rect on a canvas 2d context, and check a pixel (should be red). | 7 2. draw a red rect on a canvas 2d context, and check a pixel (should be red). |
| 8 3. draw the webgl contents on the canvas 2d context, and check a pixel (should b e green). | 8 3. draw the webgl contents on the canvas 2d context, and check a pixel (should b e green). |
| 9 4. wait for few frames. | 9 4. wait for few frames. |
| 10 5. draw a red rect on the canvas 2d context, and check a pixel (should be red). | 10 5. draw a red rect on the canvas 2d context, and check a pixel (should be red). |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 } else { | 79 } else { |
| 80 shouldBe("imgdata[0]", "0"); | 80 shouldBe("imgdata[0]", "0"); |
| 81 shouldBe("imgdata[1]", "255"); | 81 shouldBe("imgdata[1]", "255"); |
| 82 shouldBe("imgdata[2]", "0"); | 82 shouldBe("imgdata[2]", "0"); |
| 83 } | 83 } |
| 84 | 84 |
| 85 if (isDrawingBufferUndefined && window.testRunner) | 85 if (isDrawingBufferUndefined && window.testRunner) |
| 86 testRunner.notifyDone(); | 86 testRunner.notifyDone(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 function asyncTest() { | |
| 90 debug("Check for drawing webgl to canvas 2d several frames after drawing web gl contents.") | |
| 91 debug("1) when drawingBuffer is preserved.") | |
| 92 drawWebGLToCanvas2D(preserve_ctx2D, preserve_canvas3D, false); | |
| 93 debug("2) when drawingBuffer is not preserved. It leads to undefined behavio r.") | |
| 94 drawWebGLToCanvas2D(nonpreserve_ctx2D, nonpreserve_canvas3D, true); | |
| 95 } | |
| 96 | |
| 89 window.onload = function () { | 97 window.onload = function () { |
| 90 // create both canvas 2d and webgl contexts. | 98 // create both canvas 2d and webgl contexts. |
| 91 createContexts(); | 99 createContexts(); |
| 92 // prepare webgl contents. | 100 // prepare webgl contents. |
| 93 renderWebGL(preserve_gl); | 101 renderWebGL(preserve_gl); |
| 94 renderWebGL(nonpreserve_gl); | 102 renderWebGL(nonpreserve_gl); |
| 95 | 103 |
| 96 debug("Check for drawing webgl to canvas 2d on the same frame.") | 104 debug("Check for drawing webgl to canvas 2d on the same frame.") |
| 97 debug("1) when drawingBuffer is preserved.") | 105 debug("1) when drawingBuffer is preserved.") |
| 98 drawWebGLToCanvas2D(preserve_ctx2D, preserve_canvas3D, false); | 106 drawWebGLToCanvas2D(preserve_ctx2D, preserve_canvas3D, false); |
| 99 debug("2) when drawingBuffer is not preserved.") | 107 debug("2) when drawingBuffer is not preserved.") |
| 100 drawWebGLToCanvas2D(nonpreserve_ctx2D, nonpreserve_canvas3D, false); | 108 drawWebGLToCanvas2D(nonpreserve_ctx2D, nonpreserve_canvas3D, false); |
| 101 | 109 |
| 102 setTimeout(function () { | 110 if (window.testRunner) { |
| 103 debug("Check for drawing webgl to canvas 2d several frames after drawing webgl contents.") | 111 testRunner.waitUntilDone(); |
| 104 debug("1) when drawingBuffer is preserved.") | 112 testRunner.displayAsyncThen(asyncTest); |
| 105 drawWebGLToCanvas2D(preserve_ctx2D, preserve_canvas3D, false); | 113 } else { |
| 106 debug("2) when drawingBuffer is not preserved. It leads to undefined beh avior.") | 114 setTimeout(asyncTest, 100); |
|
Ken Russell (switch to Gerrit)
2014/10/16 03:05:03
Can this code path use requestAnimationFrame inste
| |
| 107 drawWebGLToCanvas2D(nonpreserve_ctx2D, nonpreserve_canvas3D, true); | 115 } |
| 108 }, 50); | |
| 109 } | 116 } |
| 110 | 117 |
| 111 </script> | 118 </script> |
| 112 </body> | 119 </body> |
| 113 </html> | 120 </html> |
| OLD | NEW |