Added noDraw parameter to webGL test.

This commit is contained in:
kkapsner 2020-06-01 13:53:05 +02:00
parent 0225f94890
commit 3e3dbf2698
1 changed files with 13 additions and 7 deletions

View File

@ -157,6 +157,8 @@
} }
} }
const drawImage = location.search !== "?noDraw";
async function createImageHash(context, hashTable){ async function createImageHash(context, hashTable){
return Promise.all([function(){ return Promise.all([function(){
const canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
@ -173,10 +175,12 @@
if (canvas){ if (canvas){
const hashCell = createHashRow(hashTable, "image" + (canvas.toDataURL? "": " (offscreen)")); const hashCell = createHashRow(hashTable, "image" + (canvas.toDataURL? "": " (offscreen)"));
try { try {
const gl = canvas.getContext(context) || canvas.getContext("experimental-" + context); if (drawImage){
fillWebGlContext(gl); const gl = canvas.getContext(context) || canvas.getContext("experimental-" + context);
fillWebGlContext(gl);
}
if (canvas.convertToBlob || canvas.toBlob){ if (canvas.convertToBlob || canvas.toBlob){
const blob = await (canvas.convertToBlob? canvas.convertToBlob(): (canvas.toBlob.length? const blob = await (canvas.convertToBlob? canvas.convertToBlob(): (canvas.toBlob.length?
new Promise(function(resolve){canvas.toBlob(resolve);}): new Promise(function(resolve){canvas.toBlob(resolve);}):
canvas.toBlob() canvas.toBlob()
)); ));
@ -195,10 +199,12 @@
if (window.Worker && window.OffscreenCanvas){ if (window.Worker && window.OffscreenCanvas){
const hashCell = createHashRow(hashTable, "image (offscreen worker)"); const hashCell = createHashRow(hashTable, "image (offscreen worker)");
const url = new URL("./testAPI.js", location); const url = new URL("./testAPI.js", location);
hashCell.textContent = await testAPI.runInWorker(async function getHash(contextType){ hashCell.textContent = await testAPI.runInWorker(async function getHash(contextType, drawImage){
const canvas = new OffscreenCanvas(300, 150); const canvas = new OffscreenCanvas(300, 150);
const context = canvas.getContext(contextType); if (drawImage){
fillWebGlContext(context); const context = canvas.getContext(contextType);
fillWebGlContext(context);
}
return await testAPI.hash( return await testAPI.hash(
await testAPI.readBlob( await testAPI.readBlob(
canvas.convertToBlob? canvas.convertToBlob?
@ -206,7 +212,7 @@
await canvas.toBlob() await canvas.toBlob()
) )
); );
}, [context], [url, fillWebGlContext]); }, [context, drawImage], [url, fillWebGlContext]);
} }
} }