From 920bd16ebd34de8d0064bc4a3554d55b1aa5a376 Mon Sep 17 00:00:00 2001 From: Arindam Bose Date: Fri, 13 Dec 2019 11:43:42 -0800 Subject: [PATCH] Fix ImageBitmap instances not being passed to appropriate gl.texImage2D call (#9103) --- src/render/texture.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/render/texture.js b/src/render/texture.js index efd5ad7af36..39e5369a7f5 100644 --- a/src/render/texture.js +++ b/src/render/texture.js @@ -1,7 +1,7 @@ // @flow import window from '../util/window'; -const {HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageData} = window; +const {HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageData, ImageBitmap} = window; import type Context from '../gl/context'; import type {RGBAImage, AlphaImage} from '../util/image'; @@ -31,7 +31,8 @@ export type TextureImage = | HTMLCanvasElement | HTMLVideoElement | ImageData - | EmptyImage; + | EmptyImage + | ImageBitmap; class Texture { context: Context; @@ -65,7 +66,7 @@ class Texture { if (resize) { this.size = [width, height]; - if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData) { + if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || (ImageBitmap && image instanceof ImageBitmap)) { gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, gl.UNSIGNED_BYTE, image); } else { gl.texImage2D(gl.TEXTURE_2D, 0, this.format, width, height, 0, this.format, gl.UNSIGNED_BYTE, image.data); @@ -73,7 +74,7 @@ class Texture { } else { const {x, y} = position || {x: 0, y: 0}; - if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData) { + if (image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof HTMLVideoElement || image instanceof ImageData || (ImageBitmap && image instanceof ImageBitmap)) { gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, gl.RGBA, gl.UNSIGNED_BYTE, image); } else { gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, image.data);