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

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

Issue 2627793003: Make OffscreenCanvas Webgl Context work with preserveDrawingBuffer flag (Closed)
Patch Set: fix based on reviewer feedback 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-webgl-preserveDrawingBuffer.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-webgl-preserveDrawingBuffer.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-webgl-preserveDrawingBuffer.html
new file mode 100644
index 0000000000000000000000000000000000000000..cef39a7b73a0d03d9558164116eba634f4347e88
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-webgl-preserveDrawingBuffer.html
@@ -0,0 +1,35 @@
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+
+function getPixelsFromOffscreenWebgl(preserveFlag) {
+ var canvas = document.createElement("canvas");
+ var offscreenCanvas = canvas.transferControlToOffscreen();
+ var gl = offscreenCanvas.getContext("webgl", {preserveDrawingBuffer: preserveFlag});
+
+ // Draw some color on gl and commit
+ gl.clearColor(1, 0, 1, 1);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ gl.commit();
+
+ var pixels = new Uint8Array(50 * 50 * 4);
+ gl.readPixels(0, 0, 50, 50, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
+ return pixels;
+}
+
+test(function() {
+ var pixelsPreserve = getPixelsFromOffscreenWebgl(true);
+ assert_equals(pixelsPreserve[0], 255);
+ assert_equals(pixelsPreserve[1], 0);
+ assert_equals(pixelsPreserve[2], 255);
+ assert_equals(pixelsPreserve[3], 255);
+}, "test if OffscreenCanvas.webgl retains context if preserveDrawingBuffer is true.");
+
+test(function() {
+ var pixelsNoPreserve = getPixelsFromOffscreenWebgl(false);
+ assert_equals(pixelsNoPreserve[0], 0);
+ assert_equals(pixelsNoPreserve[1], 0);
+ assert_equals(pixelsNoPreserve[2], 0);
+ assert_equals(pixelsNoPreserve[3], 0);
+}, "test if OffscreenCanvas.webgl loses context if presereDrawingbuffer is false.");
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698