forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1751205 - Part 2. Ensure we y-flip surfaces with OffscreenCanvas …
…if needed. r=gfx-reviewers,jgilbert On the path that we need to read the pixels from the canvas for display purposes, instead of using a platform buffer handle, we need to take into account the need to y-flip for WebGL. This patch ensures that we do so. Differential Revision: https://phabricator.services.mozilla.com/D136504
- Loading branch information
Showing
6 changed files
with
221 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
dom/canvas/test/reftest/webgl-color-offscreen-test.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<!DOCTYPE html> | ||
<meta charset='UTF-8'> | ||
<!-- | ||
Color Test | ||
Clear the four quadrants of the canvas as follows: | ||
+------+------+ | ||
| blue |black | | ||
| | | | ||
+------+------+ | ||
| red |green | | ||
| | | | ||
+------+------+ | ||
Clear with a given alpha value. What effect this has depends on the | ||
context-creation args passed to this page. | ||
--> | ||
<html class='reftest-wait'> | ||
|
||
<head> | ||
<script type='text/javascript' src='webgl-utils.js'></script> | ||
<script type='text/javascript'> | ||
'use strict'; | ||
|
||
var COLOR_VALUE = 127.0 / 255.0; | ||
var ALPHA_VALUE = 127.0 / 255.0; | ||
|
||
function renderFrame(gl) { | ||
gl.enable(gl.SCISSOR_TEST); | ||
|
||
gl.scissor(0, 0, 100, 100); | ||
gl.clearColor(COLOR_VALUE, 0.0, 0.0, ALPHA_VALUE); | ||
gl.clear(gl.COLOR_BUFFER_BIT); | ||
|
||
gl.scissor(100, 0, 100, 100); | ||
gl.clearColor(0.0, COLOR_VALUE, 0.0, ALPHA_VALUE); | ||
gl.clear(gl.COLOR_BUFFER_BIT); | ||
|
||
gl.scissor(0, 100, 100, 100); | ||
gl.clearColor(0.0, 0.0, COLOR_VALUE, ALPHA_VALUE); | ||
gl.clear(gl.COLOR_BUFFER_BIT); | ||
|
||
gl.scissor(100, 100, 100, 100); | ||
gl.clearColor(0.0, 0.0, 0.0, ALPHA_VALUE); | ||
gl.clear(gl.COLOR_BUFFER_BIT); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// Boilerplate | ||
|
||
var TIMEOUT_MS = 30 * 1000; | ||
|
||
function setStatus(text) { | ||
var elem = document.getElementById('status'); | ||
elem.innerHTML = text; | ||
} | ||
|
||
var gIsComplete = false; | ||
|
||
function markComplete(statusText) { | ||
if (!statusText) | ||
statusText = ''; | ||
|
||
if (gIsComplete) | ||
return; | ||
gIsComplete = true; | ||
|
||
setStatus(statusText); | ||
document.documentElement.removeAttribute('class'); | ||
} | ||
|
||
function markError(text) { | ||
markComplete('Error: ' + text); | ||
} | ||
|
||
function markTimedOut() { | ||
markError('Timed out waiting on test completion.'); | ||
} | ||
|
||
function runFrame(gl, frameCount, maxFrameCount) { | ||
renderFrame(gl); | ||
frameCount++; | ||
|
||
if (frameCount >= maxFrameCount) { | ||
console.log('Rendered ' + frameCount + ' frames.'); | ||
markComplete(); | ||
return; | ||
} | ||
|
||
requestAnimationFrame(function(){ | ||
runFrame(gl, frameCount, maxFrameCount); | ||
}); | ||
} | ||
|
||
function runTest() { | ||
var canvas = document.getElementById('canvas'); | ||
var offscreenCanvas = canvas.transferControlToOffscreen(); | ||
|
||
var gl = initGL(offscreenCanvas); | ||
if (!gl) { | ||
markError('WebGL context creation failed.'); | ||
return; | ||
} | ||
|
||
var maxFrameCount = arg('frame', 1); | ||
if (maxFrameCount < 1) { | ||
markError('Invalid `frame` arg: ' + maxFrameCount); | ||
return; | ||
} | ||
|
||
setStatus('Waiting...'); | ||
|
||
runFrame(gl, 0, maxFrameCount); | ||
setTimeout(markTimedOut, TIMEOUT_MS); | ||
} | ||
</script> | ||
</head> | ||
|
||
<body onload='runTest();'> | ||
<canvas id='canvas' width='200' height='200'></canvas> | ||
<div id='status'></div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters