Skip to content

Commit 657a991

Browse files
committed
Use arrow function in library_webgl.js. NFC
1 parent 72c3be3 commit 657a991

File tree

5 files changed

+31
-34
lines changed

5 files changed

+31
-34
lines changed

src/library_webgl.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
136136
emscripten_webgl_enable_WEBGL_multi_draw: (ctx) => webgl_enable_WEBGL_multi_draw(GL.contexts[ctx].GLctx),
137137

138138
$getEmscriptenSupportedExtensions__internal: true,
139-
$getEmscriptenSupportedExtensions: function(ctx) {
139+
$getEmscriptenSupportedExtensions: (ctx) => {
140140
// Restrict the list of advertised extensions to those that we actually
141141
// support.
142142
var supportedExtensions = [
@@ -280,7 +280,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
280280
// glGetError() to fetch it. As per GLES2 spec, only the first error is
281281
// remembered, and subsequent errors are discarded until the user has
282282
// cleared the stored error by a call to glGetError().
283-
recordError: function recordError(errorCode) {
283+
recordError: (errorCode) => {
284284
#if GL_TRACK_ERRORS
285285
if (!GL.lastError) {
286286
GL.lastError = errorCode;
@@ -370,7 +370,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
370370
}
371371
},
372372

373-
getTempVertexBuffer: function getTempVertexBuffer(sizeBytes) {
373+
getTempVertexBuffer: (sizeBytes) => {
374374
var idx = GL.log2ceilLookup(sizeBytes);
375375
var ringbuffer = GL.currentContext.tempVertexBuffers1[idx];
376376
var nextFreeBufferIndex = GL.currentContext.tempVertexBufferCounters1[idx];
@@ -387,7 +387,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
387387
return ringbuffer[nextFreeBufferIndex];
388388
},
389389

390-
getTempIndexBuffer: function getTempIndexBuffer(sizeBytes) {
390+
getTempIndexBuffer: (sizeBytes) => {
391391
var idx = GL.log2ceilLookup(sizeBytes);
392392
var ibo = GL.currentContext.tempIndexBuffers[idx];
393393
if (ibo) {
@@ -405,7 +405,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
405405
// doublebuffered temp VB memory pointers, so that every second frame
406406
// utilizes different set of temp buffers. The aim is to keep the set of
407407
// buffers being rendered, and the set of buffers being updated disjoint.
408-
newRenderingFrameStarted: function newRenderingFrameStarted() {
408+
newRenderingFrameStarted: () => {
409409
if (!GL.currentContext) {
410410
return;
411411
}
@@ -450,13 +450,13 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
450450

451451
#if GL_FFP_ONLY
452452
enabledClientAttribIndices: [],
453-
enableVertexAttribArray: function enableVertexAttribArray(index) {
453+
enableVertexAttribArray: (index) => {
454454
if (!GL.enabledClientAttribIndices[index]) {
455455
GL.enabledClientAttribIndices[index] = true;
456456
GLctx.enableVertexAttribArray(index);
457457
}
458458
},
459-
disableVertexAttribArray: function disableVertexAttribArray(index) {
459+
disableVertexAttribArray: (index) => {
460460
if (GL.enabledClientAttribIndices[index]) {
461461
GL.enabledClientAttribIndices[index] = false;
462462
GLctx.disableVertexAttribArray(index);
@@ -465,7 +465,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
465465
#endif
466466

467467
#if FULL_ES2
468-
calcBufLength: function calcBufLength(size, type, stride, count) {
468+
calcBufLength: (size, type, stride, count) => {
469469
if (stride > 0) {
470470
return count * stride; // XXXvlad this is not exactly correct I don't think
471471
}
@@ -475,7 +475,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
475475

476476
usedTempBuffers: [],
477477

478-
preDrawHandleClientVertexAttribBindings: function preDrawHandleClientVertexAttribBindings(count) {
478+
preDrawHandleClientVertexAttribBindings: (count) => {
479479
GL.resetBufferBinding = false;
480480

481481
// TODO: initial pass to detect ranges we need to upload, might not need
@@ -499,7 +499,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
499499
}
500500
},
501501

502-
postDrawHandleClientVertexAttribBindings: function postDrawHandleClientVertexAttribBindings() {
502+
postDrawHandleClientVertexAttribBindings: () => {
503503
if (GL.resetBufferBinding) {
504504
GLctx.bindBuffer(0x8892 /*GL_ARRAY_BUFFER*/, GL.buffers[GLctx.currentArrayBufferBinding]);
505505
}
@@ -3673,7 +3673,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
36733673
, '$emulGlGenVertexArrays'
36743674
#endif
36753675
],
3676-
glGenVertexArrays: function (n, arrays) {
3676+
glGenVertexArrays: (n, arrays) => {
36773677
#if LEGACY_GL_EMULATION
36783678
emulGlGenVertexArrays(n, arrays);
36793679
#else
@@ -4204,13 +4204,13 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
42044204
'SDL_GL_GetProcAddress',
42054205
'eglGetProcAddress',
42064206
'glfwGetProcAddress'
4207-
].forEach(function(name) {
4208-
LibraryGL[name] = function(name) { abort(); return 0; };
4207+
].forEach((name) => {
4208+
LibraryGL[name] = (name) => { abort(); return 0; };
42094209
// Due to the two pass nature of compiling .js files,
42104210
// in INCLUDE_FULL_LIBRARY mode, we must include the above
42114211
// stub functions, but not their __deps message handlers.
42124212
#if !INCLUDE_FULL_LIBRARY
4213-
LibraryGL[name + '__deps'] = [function() {
4213+
LibraryGL[name + '__deps'] = [() => {
42144214
error(`linker: Undefined symbol: ${name}(). Please pass -sGL_ENABLE_GET_PROC_ADDRESS at link time to link in ${name}().`);
42154215
}];
42164216
#endif
@@ -4235,15 +4235,12 @@ function createGLPassthroughFunctions(lib, funcs) {
42354235
const num = data[0];
42364236
const names = data[1];
42374237
const args = range(num).map((i) => 'x' + i ).join(', ');
4238-
const plainStub = `(function(${args}) { GLctx.NAME(${args}) })`;
4239-
const returnStub = `(function(${args}) { return GLctx.NAME(${args}) })`;
4238+
const stub = `(${args}) => GLctx.NAME(${args})`;
42404239
const sigEnd = range(num).map(() => 'i').join('');
42414240
names.split(' ').forEach((name) => {
4242-
let stub = plainStub;
42434241
let sig;
42444242
if (name.endsWith('*')) {
42454243
name = name.slice(0, -1);
4246-
stub = returnStub;
42474244
sig = 'i' + sigEnd;
42484245
} else {
42494246
sig = 'v' + sigEnd;

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": 4681,
5-
"a.js.gz": 2412,
4+
"a.js": 4637,
5+
"a.js.gz": 2408,
66
"a.wasm": 10388,
77
"a.wasm.gz": 6692,
8-
"total": 15638,
9-
"total_gz": 9483
8+
"total": 15594,
9+
"total_gz": 9479
1010
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 567,
33
"a.html.gz": 379,
4-
"a.js": 17917,
5-
"a.js.gz": 8089,
4+
"a.js": 17873,
5+
"a.js.gz": 8080,
66
"a.mem": 3123,
77
"a.mem.gz": 2693,
8-
"total": 21607,
9-
"total_gz": 11161
8+
"total": 21563,
9+
"total_gz": 11152
1010
}

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": 4167,
5-
"a.js.gz": 2236,
4+
"a.js": 4123,
5+
"a.js.gz": 2229,
66
"a.wasm": 10388,
77
"a.wasm.gz": 6692,
8-
"total": 15124,
9-
"total_gz": 9307
8+
"total": 15080,
9+
"total_gz": 9300
1010
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 567,
33
"a.html.gz": 379,
4-
"a.js": 17395,
5-
"a.js.gz": 7900,
4+
"a.js": 17351,
5+
"a.js.gz": 7896,
66
"a.mem": 3123,
77
"a.mem.gz": 2693,
8-
"total": 21085,
9-
"total_gz": 10972
8+
"total": 21041,
9+
"total_gz": 10968
1010
}

0 commit comments

Comments
 (0)