diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clear-srgb-color-buffer.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clear-srgb-color-buffer.html')
-rw-r--r-- | dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clear-srgb-color-buffer.html | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clear-srgb-color-buffer.html b/dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clear-srgb-color-buffer.html new file mode 100644 index 0000000000..b88518635e --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clear-srgb-color-buffer.html @@ -0,0 +1,89 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Clear sRGB Color Buffer</title> +<link rel="stylesheet" href="../../resources/js-test-style.css"/> +<script src="../../js/js-test-pre.js"></script> +<script src="../../js/webgl-test-utils.js"></script> +</head> +<body> +<canvas id="example" width="8" height="8"></canvas> +<div id="description"></div> +<div id="console"></div> + +<script> +"use strict"; + +var wtu = WebGLTestUtils; +description("This test verifies the functionality of clearing srgb color buffer."); + +var gl = wtu.create3DContext("example", undefined, 2); + +var tex = gl.createTexture(); +var fbo = gl.createFramebuffer(); +var size = 8; + +if (!gl) { + testFailed("WebGL context does not exist"); +} else { + testPassed("WebGL context exists"); + + // Create a srgb color buffer + init(); + + clear_srgb_color_buffer(0); + clear_srgb_color_buffer(1); +} + +function init() { + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.SRGB8_ALPHA8, size, size, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0); + if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) { + testFailed("Framebuffer incomplete."); + return; + } else { + testPassed("framebuffer complete!"); + } +} + +function clear_srgb_color_buffer(iter) { + debug(""); + debug("Clear sRGB color buffer through glClear or glClearBufferfv"); + + var color = [0x33, 0x88, 0xbb, 0xff]; + gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); + + if (iter == 0) { + gl.clearColor(color[0] / 255, color[1] / 255, color[2] / 255, color[3] / 255); + gl.clear(gl.COLOR_BUFFER_BIT); + } else { + var data = new Float32Array([color[0] / 255, color[1] / 255, color[2] / 255, color[3] / 255]); + gl.clearBufferfv(gl.COLOR, 0, data); + } + + var color_ref = wtu.linearToSRGB(color); + var tolerance = 3; + var msg = ""; + wtu.checkCanvasRect(gl, 0, 0, size, size, color_ref, msg, tolerance); +} + +gl.bindTexture(gl.TEXTURE_2D, null); +gl.bindFramebuffer(gl.FRAMEBUFFER, null); +gl.deleteTexture(tex); +gl.deleteFramebuffer(fbo); + +var successfullyParsed = true; +</script> +<script src="../../js/js-test-post.js"></script> + +</body> +</html> |