mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 02:21:53 +01:00
Added noDraw parameter to webGL test.
This commit is contained in:
parent
0225f94890
commit
3e3dbf2698
@ -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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user