handle WebGL layers

This commit is contained in:
mike-000
2022-02-10 11:40:44 +00:00
committed by GitHub
parent 96de98bfbb
commit bf199bbe38
+13 -9
View File
@@ -917,15 +917,19 @@ function getImageData(layer, frameState) {
} }
const container = renderer.renderFrame(frameState, null); const container = renderer.renderFrame(frameState, null);
let element; let element;
if (container) { if (container instanceof HTMLCanvasElement) {
element = container.firstElementChild; element = container;
} } else {
if (!(element instanceof HTMLCanvasElement)) { if (container) {
throw new Error('Unsupported rendered element: ' + element); element = container.firstElementChild;
} }
if (element.width === width && element.height === height) { if (!(element instanceof HTMLCanvasElement)) {
const context = element.getContext('2d'); throw new Error('Unsupported rendered element: ' + element);
return context.getImageData(0, 0, width, height); }
if (element.width === width && element.height === height) {
const context = element.getContext('2d');
return context.getImageData(0, 0, width, height);
}
} }
if (!sharedContext) { if (!sharedContext) {