Skip to content

Commit

Permalink
Use arrow function in library_webgl.js. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Jan 30, 2024
1 parent 4aefde3 commit 5ffcf20
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
33 changes: 15 additions & 18 deletions src/library_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
emscripten_webgl_enable_WEBGL_multi_draw: (ctx) => webgl_enable_WEBGL_multi_draw(GL.contexts[ctx].GLctx),

$getEmscriptenSupportedExtensions__internal: true,
$getEmscriptenSupportedExtensions: function(ctx) {
$getEmscriptenSupportedExtensions: (ctx) => {
// Restrict the list of advertised extensions to those that we actually
// support.
var supportedExtensions = [
Expand Down Expand Up @@ -287,7 +287,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
// glGetError() to fetch it. As per GLES2 spec, only the first error is
// remembered, and subsequent errors are discarded until the user has
// cleared the stored error by a call to glGetError().
recordError: function recordError(errorCode) {
recordError: (errorCode) => {
#if GL_TRACK_ERRORS
if (!GL.lastError) {
GL.lastError = errorCode;
Expand Down Expand Up @@ -377,7 +377,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
}
},

getTempVertexBuffer: function getTempVertexBuffer(sizeBytes) {
getTempVertexBuffer: (sizeBytes) => {
var idx = GL.log2ceilLookup(sizeBytes);
var ringbuffer = GL.currentContext.tempVertexBuffers1[idx];
var nextFreeBufferIndex = GL.currentContext.tempVertexBufferCounters1[idx];
Expand All @@ -394,7 +394,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
return ringbuffer[nextFreeBufferIndex];
},

getTempIndexBuffer: function getTempIndexBuffer(sizeBytes) {
getTempIndexBuffer: (sizeBytes) => {
var idx = GL.log2ceilLookup(sizeBytes);
var ibo = GL.currentContext.tempIndexBuffers[idx];
if (ibo) {
Expand All @@ -412,7 +412,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
// doublebuffered temp VB memory pointers, so that every second frame
// utilizes different set of temp buffers. The aim is to keep the set of
// buffers being rendered, and the set of buffers being updated disjoint.
newRenderingFrameStarted: function newRenderingFrameStarted() {
newRenderingFrameStarted: () => {
if (!GL.currentContext) {
return;
}
Expand Down Expand Up @@ -457,13 +457,13 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};

#if GL_FFP_ONLY
enabledClientAttribIndices: [],
enableVertexAttribArray: function enableVertexAttribArray(index) {
enableVertexAttribArray: (index) => {
if (!GL.enabledClientAttribIndices[index]) {
GL.enabledClientAttribIndices[index] = true;
GLctx.enableVertexAttribArray(index);
}
},
disableVertexAttribArray: function disableVertexAttribArray(index) {
disableVertexAttribArray: (index) => {
if (GL.enabledClientAttribIndices[index]) {
GL.enabledClientAttribIndices[index] = false;
GLctx.disableVertexAttribArray(index);
Expand All @@ -472,7 +472,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
#endif

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

usedTempBuffers: [],

preDrawHandleClientVertexAttribBindings: function preDrawHandleClientVertexAttribBindings(count) {
preDrawHandleClientVertexAttribBindings: (count) => {
GL.resetBufferBinding = false;

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

postDrawHandleClientVertexAttribBindings: function postDrawHandleClientVertexAttribBindings() {
postDrawHandleClientVertexAttribBindings: () => {
if (GL.resetBufferBinding) {
GLctx.bindBuffer(0x8892 /*GL_ARRAY_BUFFER*/, GL.buffers[GLctx.currentArrayBufferBinding]);
}
Expand Down Expand Up @@ -3680,7 +3680,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
, '$emulGlGenVertexArrays'
#endif
],
glGenVertexArrays: function (n, arrays) {
glGenVertexArrays: (n, arrays) => {
#if LEGACY_GL_EMULATION
emulGlGenVertexArrays(n, arrays);
#else
Expand Down Expand Up @@ -4211,13 +4211,13 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
'SDL_GL_GetProcAddress',
'eglGetProcAddress',
'glfwGetProcAddress'
].forEach(function(name) {
LibraryGL[name] = function(name) { abort(); return 0; };
].forEach((name) => {
LibraryGL[name] = (name) => { abort(); return 0; };
// Due to the two pass nature of compiling .js files,
// in INCLUDE_FULL_LIBRARY mode, we must include the above
// stub functions, but not their __deps message handlers.
#if !INCLUDE_FULL_LIBRARY
LibraryGL[name + '__deps'] = [function() {
LibraryGL[name + '__deps'] = [() => {
error(`linker: Undefined symbol: ${name}(). Please pass -sGL_ENABLE_GET_PROC_ADDRESS at link time to link in ${name}().`);
}];
#endif
Expand All @@ -4242,15 +4242,12 @@ function createGLPassthroughFunctions(lib, funcs) {
const num = data[0];
const names = data[1];
const args = range(num).map((i) => 'x' + i ).join(', ');
const plainStub = `(function(${args}) { GLctx.NAME(${args}) })`;
const returnStub = `(function(${args}) { return GLctx.NAME(${args}) })`;
const stub = `(${args}) => GLctx.NAME(${args})`;
const sigEnd = range(num).map(() => 'i').join('');
names.split(' ').forEach((name) => {
let stub = plainStub;
let sig;
if (name.endsWith('*')) {
name = name.slice(0, -1);
stub = returnStub;
sig = 'i' + sigEnd;
} else {
sig = 'v' + sigEnd;
Expand Down
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl2_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 569,
"a.html.gz": 379,
"a.js": 4584,
"a.js.gz": 2351,
"a.js": 4540,
"a.js.gz": 2345,
"a.wasm": 10451,
"a.wasm.gz": 6724,
"total": 15604,
"total_gz": 9454
"total": 15560,
"total_gz": 9448
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl2_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 567,
"a.html.gz": 379,
"a.js": 17790,
"a.js.gz": 7987,
"a.js": 17746,
"a.js.gz": 7982,
"a.mem": 3123,
"a.mem.gz": 2693,
"total": 21480,
"total_gz": 11059
"total": 21436,
"total_gz": 11054
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 569,
"a.html.gz": 379,
"a.js": 4071,
"a.js.gz": 2179,
"a.js": 4027,
"a.js.gz": 2173,
"a.wasm": 10451,
"a.wasm.gz": 6724,
"total": 15091,
"total_gz": 9282
"total": 15047,
"total_gz": 9276
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 567,
"a.html.gz": 379,
"a.js": 17263,
"a.js.gz": 7819,
"a.js": 17219,
"a.js.gz": 7814,
"a.mem": 3123,
"a.mem.gz": 2693,
"total": 20953,
"total_gz": 10891
"total": 20909,
"total_gz": 10886
}

0 comments on commit 5ffcf20

Please sign in to comment.