@@ -320,15 +320,16 @@ class WebGLTextureUtils {
320320 setTextureParameters ( textureType , texture ) {
321321
322322 const { gl, extensions, backend } = this ;
323+ const { state } = this . backend ;
323324
324325 const workingPrimaries = ColorManagement . getPrimaries ( ColorManagement . workingColorSpace ) ;
325326 const texturePrimaries = texture . colorSpace === NoColorSpace ? null : ColorManagement . getPrimaries ( texture . colorSpace ) ;
326327 const unpackConversion = texture . colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? gl . NONE : gl . BROWSER_DEFAULT_WEBGL ;
327328
328- gl . pixelStorei ( gl . UNPACK_FLIP_Y_WEBGL , texture . flipY ) ;
329- gl . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , texture . premultiplyAlpha ) ;
330- gl . pixelStorei ( gl . UNPACK_ALIGNMENT , texture . unpackAlignment ) ;
331- gl . pixelStorei ( gl . UNPACK_COLORSPACE_CONVERSION_WEBGL , unpackConversion ) ;
329+ state . pixelStorei ( gl . UNPACK_FLIP_Y_WEBGL , texture . flipY ) ;
330+ state . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , texture . premultiplyAlpha ) ;
331+ state . pixelStorei ( gl . UNPACK_ALIGNMENT , texture . unpackAlignment ) ;
332+ state . pixelStorei ( gl . UNPACK_COLORSPACE_CONVERSION_WEBGL , unpackConversion ) ;
332333
333334 gl . texParameteri ( textureType , gl . TEXTURE_WRAP_S , wrappingToGL [ texture . wrapS ] ) ;
334335 gl . texParameteri ( textureType , gl . TEXTURE_WRAP_T , wrappingToGL [ texture . wrapT ] ) ;
@@ -470,6 +471,7 @@ class WebGLTextureUtils {
470471 copyBufferToTexture ( buffer , texture ) {
471472
472473 const { gl, backend } = this ;
474+ const { state } = backend ;
473475
474476 const { textureGPU, glTextureType, glFormat, glType } = backend . get ( texture ) ;
475477
@@ -479,8 +481,8 @@ class WebGLTextureUtils {
479481
480482 backend . state . bindTexture ( glTextureType , textureGPU ) ;
481483
482- gl . pixelStorei ( gl . UNPACK_FLIP_Y_WEBGL , false ) ;
483- gl . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , false ) ;
484+ state . pixelStorei ( gl . UNPACK_FLIP_Y_WEBGL , false ) ;
485+ state . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , false ) ;
484486 gl . texSubImage2D ( glTextureType , 0 , 0 , 0 , width , height , glFormat , glType , 0 ) ;
485487
486488 gl . bindBuffer ( gl . PIXEL_UNPACK_BUFFER , null ) ;
@@ -832,22 +834,22 @@ class WebGLTextureUtils {
832834
833835 }
834836
835- gl . pixelStorei ( gl . UNPACK_FLIP_Y_WEBGL , dstTexture . flipY ) ;
836- gl . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , dstTexture . premultiplyAlpha ) ;
837- gl . pixelStorei ( gl . UNPACK_ALIGNMENT , dstTexture . unpackAlignment ) ;
837+ state . pixelStorei ( gl . UNPACK_FLIP_Y_WEBGL , dstTexture . flipY ) ;
838+ state . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , dstTexture . premultiplyAlpha ) ;
839+ state . pixelStorei ( gl . UNPACK_ALIGNMENT , dstTexture . unpackAlignment ) ;
838840
839841 // used for copying data from cpu
840- const currentUnpackRowLen = gl . getParameter ( gl . UNPACK_ROW_LENGTH ) ;
841- const currentUnpackImageHeight = gl . getParameter ( gl . UNPACK_IMAGE_HEIGHT ) ;
842- const currentUnpackSkipPixels = gl . getParameter ( gl . UNPACK_SKIP_PIXELS ) ;
843- const currentUnpackSkipRows = gl . getParameter ( gl . UNPACK_SKIP_ROWS ) ;
844- const currentUnpackSkipImages = gl . getParameter ( gl . UNPACK_SKIP_IMAGES ) ;
845-
846- gl . pixelStorei ( gl . UNPACK_ROW_LENGTH , image . width ) ;
847- gl . pixelStorei ( gl . UNPACK_IMAGE_HEIGHT , image . height ) ;
848- gl . pixelStorei ( gl . UNPACK_SKIP_PIXELS , minX ) ;
849- gl . pixelStorei ( gl . UNPACK_SKIP_ROWS , minY ) ;
850- gl . pixelStorei ( gl . UNPACK_SKIP_IMAGES , minZ ) ;
842+ const currentUnpackRowLen = state . getParameter ( gl . UNPACK_ROW_LENGTH ) ;
843+ const currentUnpackImageHeight = state . getParameter ( gl . UNPACK_IMAGE_HEIGHT ) ;
844+ const currentUnpackSkipPixels = state . getParameter ( gl . UNPACK_SKIP_PIXELS ) ;
845+ const currentUnpackSkipRows = state . getParameter ( gl . UNPACK_SKIP_ROWS ) ;
846+ const currentUnpackSkipImages = state . getParameter ( gl . UNPACK_SKIP_IMAGES ) ;
847+
848+ state . pixelStorei ( gl . UNPACK_ROW_LENGTH , image . width ) ;
849+ state . pixelStorei ( gl . UNPACK_IMAGE_HEIGHT , image . height ) ;
850+ state . pixelStorei ( gl . UNPACK_SKIP_PIXELS , minX ) ;
851+ state . pixelStorei ( gl . UNPACK_SKIP_ROWS , minY ) ;
852+ state . pixelStorei ( gl . UNPACK_SKIP_IMAGES , minZ ) ;
851853
852854 // set up the src texture
853855 const isSrc3D = srcTexture . isDataArrayTexture || srcTexture . isData3DTexture || dstTexture . isArrayTexture ;
@@ -981,11 +983,11 @@ class WebGLTextureUtils {
981983 }
982984
983985 // reset values
984- gl . pixelStorei ( gl . UNPACK_ROW_LENGTH , currentUnpackRowLen ) ;
985- gl . pixelStorei ( gl . UNPACK_IMAGE_HEIGHT , currentUnpackImageHeight ) ;
986- gl . pixelStorei ( gl . UNPACK_SKIP_PIXELS , currentUnpackSkipPixels ) ;
987- gl . pixelStorei ( gl . UNPACK_SKIP_ROWS , currentUnpackSkipRows ) ;
988- gl . pixelStorei ( gl . UNPACK_SKIP_IMAGES , currentUnpackSkipImages ) ;
986+ state . pixelStorei ( gl . UNPACK_ROW_LENGTH , currentUnpackRowLen ) ;
987+ state . pixelStorei ( gl . UNPACK_IMAGE_HEIGHT , currentUnpackImageHeight ) ;
988+ state . pixelStorei ( gl . UNPACK_SKIP_PIXELS , currentUnpackSkipPixels ) ;
989+ state . pixelStorei ( gl . UNPACK_SKIP_ROWS , currentUnpackSkipRows ) ;
990+ state . pixelStorei ( gl . UNPACK_SKIP_IMAGES , currentUnpackSkipImages ) ;
989991
990992 // Generate mipmaps only when copying level 0
991993 if ( dstLevel === 0 && dstTexture . generateMipmaps ) {
0 commit comments