From 733dae987efd553b4af1ee11ac33bcd2ab6130d8 Mon Sep 17 00:00:00 2001 From: jerrywwl Date: Fri, 26 Apr 2019 11:51:50 +0800 Subject: [PATCH] using uint8array instead of ArrayBufferView --- cocos/gfx/webgl/webgl-commands.ts | 8 ++++---- cocos/gfx/webgl2/webgl2-commands.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cocos/gfx/webgl/webgl-commands.ts b/cocos/gfx/webgl/webgl-commands.ts index b9573e0f2b..e1ec1f23da 100644 --- a/cocos/gfx/webgl/webgl-commands.ts +++ b/cocos/gfx/webgl/webgl-commands.ts @@ -797,7 +797,7 @@ export function WebGLCmdFuncCreateTexture (device: WebGLGFXDevice, gpuTexture: W } else { for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1); - const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 }; + const view: Uint8Array = new Uint8Array(imgSize); gl.compressedTexImage2D(WebGLRenderingContext.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, view); w = Math.max(1, w >> 1); h = Math.max(1, h >> 1); @@ -854,7 +854,7 @@ export function WebGLCmdFuncCreateTexture (device: WebGLGFXDevice, gpuTexture: W let h = gpuTexture.height; for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1); - const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 }; + const view: Uint8Array = new Uint8Array(imgSize); gl.compressedTexImage2D(WebGLRenderingContext.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, view); w = Math.max(1, w >> 1); h = Math.max(1, h >> 1); @@ -933,7 +933,7 @@ export function WebGLCmdFuncResizeTexture (device: WebGLGFXDevice, gpuTexture: W } else { for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1); - const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 }; + const view: Uint8Array = new Uint8Array(imgSize); gl.compressedTexImage2D(gl.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, view); w = Math.max(1, w >> 1); h = Math.max(1, h >> 1); @@ -969,7 +969,7 @@ export function WebGLCmdFuncResizeTexture (device: WebGLGFXDevice, gpuTexture: W let h = gpuTexture.height; for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1); - const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 }; + const view: Uint8Array = new Uint8Array(imgSize); gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, view); w = Math.max(1, w >> 1); h = Math.max(1, h >> 1); diff --git a/cocos/gfx/webgl2/webgl2-commands.ts b/cocos/gfx/webgl2/webgl2-commands.ts index 0b2de19cf1..970a63c69e 100644 --- a/cocos/gfx/webgl2/webgl2-commands.ts +++ b/cocos/gfx/webgl2/webgl2-commands.ts @@ -973,7 +973,7 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2GFXDevice, gpuTexture: } else { for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1); - const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 }; + const view: Uint8Array = new Uint8Array(imgSize); gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, view); w = Math.max(1, w >> 1); h = Math.max(1, h >> 1); @@ -1039,7 +1039,7 @@ export function WebGL2CmdFuncCreateTexture (device: WebGL2GFXDevice, gpuTexture: let h = gpuTexture.height; for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1); - const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 }; + const view: Uint8Array = new Uint8Array(imgSize); gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, view); w = Math.max(1, w >> 1); h = Math.max(1, h >> 1); @@ -1119,7 +1119,7 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2GFXDevice, gpuTexture: } else { for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1); - const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 }; + const view: Uint8Array = new Uint8Array(imgSize); gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_2D, i, gpuTexture.glInternelFmt, w, h, 0, view); w = Math.max(1, w >> 1); h = Math.max(1, h >> 1); @@ -1166,7 +1166,7 @@ export function WebGL2CmdFuncResizeTexture (device: WebGL2GFXDevice, gpuTexture: let h = gpuTexture.height; for (let i = 0; i < gpuTexture.mipLevel; ++i) { const imgSize = GFXFormatSize(gpuTexture.format, w, h, 1); - const view: ArrayBufferView = { buffer: new ArrayBuffer(imgSize), byteLength: imgSize, byteOffset: 0 }; + const view: Uint8Array = new Uint8Array(imgSize); gl.compressedTexImage2D(WebGL2RenderingContext.TEXTURE_CUBE_MAP_POSITIVE_X + f, i, gpuTexture.glInternelFmt, w, h, 0, view); w = Math.max(1, w >> 1); h = Math.max(1, h >> 1);