提交 16128d24 编写于 作者: M Mr.doob

WebGLTextures: Moved createCanvas function outside of resizeImage.

上级 df0e4c06
......@@ -12,6 +12,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
//
var useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined';
function createCanvas( width, height ) {
// Use OffscreenCanvas when available. Specially needed in web workers
return useOffscreenCanvas ?
new OffscreenCanvas( width, height ) :
document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
}
function resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {
var scale = 1;
......@@ -32,18 +44,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if ( image instanceof ImageBitmap || image instanceof HTMLImageElement || image instanceof HTMLCanvasElement ) {
// Use an offscreen canvas to resize the image if available, otherwise a canvas element will be created but this won't work in web workers
var useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined';
function createCanvas( width, height ) {
return useOffscreenCanvas ?
new OffscreenCanvas( width, height ) :
document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
}
var floor = needsPowerOfTwo ? _Math.floorPowerOfTwo : Math.floor;
var width = floor( scale * image.width );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册