Skip to content

Commit bb77856

Browse files
authored
Another library_webgl.js cleanup. NFC (#21458)
Similar to #21457 but this one actually as a code size saving
1 parent 165133b commit bb77856

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

src/library_webgl.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,16 +1641,18 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
16411641
// those always when possible.
16421642
if (GLctx.currentPixelUnpackBufferBinding) {
16431643
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
1644-
} else if (pixels) {
1644+
return;
1645+
}
1646+
if (pixels) {
16451647
var heap = heapObjectForWebGLType(type);
1646-
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, heap, toTypedArrayIndex(pixels, heap));
1647-
} else {
1648-
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, null);
1648+
var index = toTypedArrayIndex(pixels, heap);
1649+
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, heap, index);
1650+
return;
16491651
}
1650-
return;
16511652
}
16521653
#endif
1653-
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixels ? emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, internalFormat) : null);
1654+
var pixelData = pixels ? emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, internalFormat) : null;
1655+
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixelData);
16541656
},
16551657

16561658
glTexSubImage2D__deps: ['$emscriptenWebGLGetTexPixelData'

test/code_size/hello_webgl2_wasm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 569,
33
"a.html.gz": 379,
4-
"a.js": 4589,
5-
"a.js.gz": 2341,
4+
"a.js": 4539,
5+
"a.js.gz": 2315,
66
"a.wasm": 10451,
77
"a.wasm.gz": 6724,
8-
"total": 15609,
9-
"total_gz": 9444
8+
"total": 15559,
9+
"total_gz": 9418
1010
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"a.html": 354,
33
"a.html.gz": 266,
4-
"a.js": 22323,
5-
"a.js.gz": 11632,
6-
"total": 22677,
7-
"total_gz": 11898
4+
"a.js": 22273,
5+
"a.js.gz": 11608,
6+
"total": 22627,
7+
"total_gz": 11874
88
}

test/code_size/hello_webgl_wasm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 569,
33
"a.html.gz": 379,
4-
"a.js": 4075,
5-
"a.js.gz": 2170,
4+
"a.js": 4056,
5+
"a.js.gz": 2152,
66
"a.wasm": 10451,
77
"a.wasm.gz": 6724,
8-
"total": 15095,
9-
"total_gz": 9273
8+
"total": 15076,
9+
"total_gz": 9255
1010
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"a.html": 354,
33
"a.html.gz": 266,
4-
"a.js": 21794,
5-
"a.js.gz": 11450,
6-
"total": 22148,
7-
"total_gz": 11716
4+
"a.js": 21775,
5+
"a.js.gz": 11436,
6+
"total": 22129,
7+
"total_gz": 11702
88
}

0 commit comments

Comments
 (0)