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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-webgl-preserveDrawingBuffer.html

Issue 2627793003: Make OffscreenCanvas Webgl Context work with preserveDrawingBuffer flag (Closed)
Patch Set: Created 3 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 <canvas id="withoutPreserve" width="50" height="50"></canvas>
2 <canvas id="withPreserve" width="50" height="50"></canvas>
Justin Novosad 2017/01/11 21:40:04 You don't need these.
xlai (Olivia) 2017/01/12 20:04:47 Done.
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <script>
6
7 function getPixelsFromOffscreenWebgl(placeHolderCanvasId, preserveFlag) {
8 var canvas = document.getElementById(placeHolderCanvasId);
Justin Novosad 2017/01/11 21:40:04 Just do: var canvas = document.createElement('canv
xlai (Olivia) 2017/01/12 20:04:47 Done.
9 var offscreenCanvas = canvas.transferControlToOffscreen();
10 var gl = offscreenCanvas.getContext("webgl", {preserveDrawingBuffer: preserveF lag});
11
12 // Draw some color on gl and commit
13 gl.clearColor(1, 0, 1, 1);
14 gl.clear(gl.COLOR_BUFFER_BIT);
15 gl.commit();
16
17 var pixels = new Uint8Array(50 * 50 * 4);
18 gl.readPixels(0, 0, 50, 50, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
19 return pixels;
20 }
21
22 test(function() {
23 var pixelsPreserve = getPixelsFromOffscreenWebgl("withPreserve", true);
24 assert_equals(pixelsPreserve[0], 255);
25 assert_equals(pixelsPreserve[1], 0);
26 assert_equals(pixelsPreserve[2], 255);
27 assert_equals(pixelsPreserve[3], 255);
28 }, "test if OffscreenCanvas.webgl retains context if preserveDrawingBuffer is tr ue.");
29
30 test(function() {
31 var pixelsNoPreserve = getPixelsFromOffscreenWebgl("withoutPreserve", false);
32 assert_equals(pixelsNoPreserve[0], 0);
33 assert_equals(pixelsNoPreserve[1], 0);
34 assert_equals(pixelsNoPreserve[2], 0);
35 assert_equals(pixelsNoPreserve[3], 0);
36 }, "test if OffscreenCanvas.webgl loses context if presereDrawingbuffer is false .");
37 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698