summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/reftest/webgl-utils.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /dom/canvas/test/reftest/webgl-utils.js
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/reftest/webgl-utils.js')
-rw-r--r--dom/canvas/test/reftest/webgl-utils.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/dom/canvas/test/reftest/webgl-utils.js b/dom/canvas/test/reftest/webgl-utils.js
new file mode 100644
index 0000000000..798e7fee0f
--- /dev/null
+++ b/dom/canvas/test/reftest/webgl-utils.js
@@ -0,0 +1,82 @@
+"use strict";
+
+function parseArgs() {
+ var query = window.location.search.substring(1);
+
+ var split = query.split("&");
+
+ var args = {}
+ for (var i = 0; i < split.length; i++) {
+ var pair = split[i].split("=");
+
+ var key = pair[0];
+ var value = true;
+ if (pair.length >= 2) {
+ eval("value = " + decodeURIComponent(pair[1]) + ";");
+ }
+
+ args[key] = value;
+ }
+
+ return args;
+}
+
+var gArgs = null;
+function arg(key, defaultVal) {
+ if (gArgs === null) {
+ gArgs = parseArgs();
+ }
+
+ if (!(key in gArgs))
+ return defaultVal;
+
+ return gArgs[key];
+}
+
+function initGL(canvas) {
+ if (arg("nogl"))
+ return null;
+
+ var gl = null;
+
+ var withAA = arg("aa", false);
+ var withAlpha = arg("alpha", false);
+ var withDepth = arg("depth", false);
+ var withPremult = arg("premult", false);
+ var withPreserve = arg("preserve", false);
+ var withStencil = arg("stencil", false);
+
+ try {
+ var argDict = {
+ alpha: withAlpha,
+ depth: withDepth,
+ stencil: withStencil,
+ antialias: withAA,
+ premultipliedAlpha: withPremult,
+ preserveDrawingBuffer: withPreserve,
+ };
+ gl = canvas.getContext("webgl", argDict);
+ } catch(e) {}
+
+ return gl;
+}
+
+function rAF(func) {
+ var raf = window.requestAnimationFrame;
+ raf(func);
+}
+
+var MAX_WAIT_FOR_COMPOSITE_DELAY_MS = 500;
+
+function waitForComposite(func) {
+ var isDone = false;
+ var doneFunc = function () {
+ if (isDone)
+ return;
+ isDone = true;
+ func();
+ };
+
+ rAF(doneFunc);
+ setTimeout(doneFunc, MAX_WAIT_FOR_COMPOSITE_DELAY_MS);
+}