Skip to content

Commit c35cdb3

Browse files
committed
[GL] Prefix internal WebGL functions with an underscore
Prefix internal WebGL helper functions (`_emscripten_webgl_do_*`, `_emscripten_webgl_make_context_current_calling_thread`, and `_emscripten_webgl_create_context_proxied`) with a leading underscore to make it clear that they are internal symbols.
1 parent 97370e8 commit c35cdb3

5 files changed

Lines changed: 42 additions & 42 deletions

File tree

‎src/lib/libhtml5_webgl.js‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@ var LibraryHtml5WebGL = {
2828
#if PTHREADS && OFFSCREEN_FRAMEBUFFER
2929
// In offscreen framebuffer mode, we implement a proxied version of the
3030
// emscripten_webgl_create_context() function in JS.
31-
emscripten_webgl_create_context_proxied__proxy: 'sync',
32-
emscripten_webgl_create_context_proxied__deps: ['emscripten_webgl_do_create_context'],
33-
emscripten_webgl_create_context_proxied: (target, attributes) =>
34-
_emscripten_webgl_do_create_context(target, attributes),
31+
_emscripten_webgl_create_context_proxied__proxy: 'sync',
32+
_emscripten_webgl_create_context_proxied__deps: ['_emscripten_webgl_do_create_context'],
33+
_emscripten_webgl_create_context_proxied: (target, attributes) =>
34+
__emscripten_webgl_do_create_context(target, attributes),
3535

3636
// The other proxied GL commands are defined in C (guarded by the
3737
// __EMSCRIPTEN_OFFSCREEN_FRAMEBUFFER__ definition).
3838
#else
3939
// When not in offscreen framebuffer mode, these functions are implemented
4040
// in JS and forwarded without any proxying.
41-
emscripten_webgl_create_context: 'emscripten_webgl_do_create_context',
41+
emscripten_webgl_create_context: '_emscripten_webgl_do_create_context',
4242

43-
emscripten_webgl_get_current_context: 'emscripten_webgl_do_get_current_context',
43+
emscripten_webgl_get_current_context: '_emscripten_webgl_do_get_current_context',
4444

45-
emscripten_webgl_commit_frame: 'emscripten_webgl_do_commit_frame',
45+
emscripten_webgl_commit_frame: '_emscripten_webgl_do_commit_frame',
4646

47-
emscripten_webgl_destroy_context: 'emscripten_webgl_do_destroy_context',
47+
emscripten_webgl_destroy_context: '_emscripten_webgl_do_destroy_context',
4848
#endif
4949

5050
#if OFFSCREENCANVAS_SUPPORT
51-
emscripten_webgl_do_create_context__postset: `
51+
_emscripten_webgl_do_create_context__postset: `
5252
registerPreMainLoop(() => {
5353
// If the current GL context is an OffscreenCanvas, but it was initialized
5454
// with implicit swap mode, perform the swap on behalf of the user.
@@ -58,18 +58,18 @@ var LibraryHtml5WebGL = {
5858
});`,
5959
#endif
6060

61-
emscripten_webgl_do_create_context__deps: [
61+
_emscripten_webgl_do_create_context__deps: [
6262
#if OFFSCREENCANVAS_SUPPORT
6363
'$registerPreMainLoop',
6464
'malloc',
6565
'emscripten_supports_offscreencanvas',
6666
#endif
6767
#if PTHREADS && OFFSCREEN_FRAMEBUFFER
68-
'emscripten_webgl_create_context_proxied',
68+
'_emscripten_webgl_create_context_proxied',
6969
#endif
7070
'$webglPowerPreferences', '$findCanvasEventTarget'],
7171
// This function performs proxying manually, depending on the style of context that is to be created.
72-
emscripten_webgl_do_create_context: (target, attributes) => {
72+
_emscripten_webgl_do_create_context: (target, attributes) => {
7373
#if ASSERTIONS
7474
assert(attributes);
7575
#endif
@@ -138,7 +138,7 @@ var LibraryHtml5WebGL = {
138138
{{{ makeSetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.renderViaOffscreenBackBuffer, '1', 'i8') }}};
139139
{{{ makeSetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.preserveDrawingBuffer, '1', 'i8') }}};
140140
}
141-
return _emscripten_webgl_create_context_proxied(target, attributes);
141+
return __emscripten_webgl_create_context_proxied(target, attributes);
142142
}
143143
}
144144
#endif
@@ -222,8 +222,8 @@ var LibraryHtml5WebGL = {
222222

223223
#if PTHREADS && OFFSCREEN_FRAMEBUFFER
224224
// Runs on the calling thread, proxies if needed.
225-
emscripten_webgl_make_context_current_calling_thread__sig: 'ip',
226-
emscripten_webgl_make_context_current_calling_thread: (contextHandle) => {
225+
_emscripten_webgl_make_context_current_calling_thread__sig: 'ip',
226+
_emscripten_webgl_make_context_current_calling_thread: (contextHandle) => {
227227
var success = GL.makeContextCurrent(contextHandle);
228228
if (success) GL.currentContextIsProxied = false; // If succeeded above, we will have a local GL context from this thread (worker or main).
229229
return success ? {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}} : {{{ cDefs.EMSCRIPTEN_RESULT_INVALID_PARAM }}};
@@ -256,7 +256,7 @@ var LibraryHtml5WebGL = {
256256
},
257257
#endif
258258

259-
emscripten_webgl_do_get_current_context: () => GL.currentContext ? GL.currentContext.handle : 0,
259+
_emscripten_webgl_do_get_current_context: () => GL.currentContext ? GL.currentContext.handle : 0,
260260

261261
emscripten_webgl_get_drawing_buffer_size__proxy: 'sync_on_webgl_context_handle_thread',
262262
emscripten_webgl_get_drawing_buffer_size: (contextHandle, width, height) => {
@@ -270,10 +270,10 @@ var LibraryHtml5WebGL = {
270270
return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}};
271271
},
272272

273-
emscripten_webgl_do_commit_frame: () => {
273+
_emscripten_webgl_do_commit_frame: () => {
274274
#if TRACE_WEBGL_CALLS
275275
var threadId = (typeof _pthread_self !== 'undefined') ? _pthread_self : () => 1;
276-
err(`[Thread ${threadId()}, GL ctx: ${GL.currentContext.handle}]: emscripten_webgl_do_commit_frame()`);
276+
err(`[Thread ${threadId()}, GL ctx: ${GL.currentContext.handle}]: _emscripten_webgl_do_commit_frame()`);
277277
#endif
278278
if (!GL.currentContext || !GL.currentContext.GLctx) {
279279
#if GL_DEBUG
@@ -333,8 +333,8 @@ var LibraryHtml5WebGL = {
333333
return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}};
334334
},
335335

336-
emscripten_webgl_do_destroy_context__proxy: 'sync_on_webgl_context_handle_thread',
337-
emscripten_webgl_do_destroy_context: (contextHandle) => {
336+
_emscripten_webgl_do_destroy_context__proxy: 'sync_on_webgl_context_handle_thread',
337+
_emscripten_webgl_do_destroy_context: (contextHandle) => {
338338
if (GL.currentContext == contextHandle) GL.currentContext = 0;
339339
GL.deleteContext(contextHandle);
340340
},

‎src/lib/libsigs.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ sigs = {
352352
_emscripten_thread_mailbox_await__sig: 'vp',
353353
_emscripten_thread_set_strongref__sig: 'vp',
354354
_emscripten_throw_longjmp__sig: 'v',
355+
_emscripten_webgl_do_commit_frame__sig: 'i',
356+
_emscripten_webgl_do_create_context__sig: 'ppp',
357+
_emscripten_webgl_do_destroy_context__sig: 'ip',
358+
_emscripten_webgl_do_get_current_context__sig: 'p',
355359
_emval_array_to_memory_view__sig: 'vpp',
356360
_emval_await__sig: 'pp',
357361
_emval_coro_make_promise__sig: 'ppp',
@@ -873,10 +877,6 @@ sigs = {
873877
emscripten_webgl_commit_frame__sig: 'i',
874878
emscripten_webgl_create_context__sig: 'ppp',
875879
emscripten_webgl_destroy_context__sig: 'ip',
876-
emscripten_webgl_do_commit_frame__sig: 'i',
877-
emscripten_webgl_do_create_context__sig: 'ppp',
878-
emscripten_webgl_do_destroy_context__sig: 'ip',
879-
emscripten_webgl_do_get_current_context__sig: 'p',
880880
emscripten_webgl_enable_ANGLE_instanced_arrays__sig: 'ip',
881881
emscripten_webgl_enable_EXT_clip_control__sig: 'ip',
882882
emscripten_webgl_enable_EXT_polygon_offset_clamp__sig: 'ip',

‎system/lib/gl/webgl1.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_create_context(const char *targ
7878
(attributes->proxyContextToMainThread == EMSCRIPTEN_WEBGL_CONTEXT_PROXY_FALLBACK && !emscripten_supports_offscreencanvas())) {
7979
EmscriptenWebGLContextAttributes attrs = *attributes;
8080
attrs.renderViaOffscreenBackBuffer = true;
81-
return (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)emscripten_sync_run_in_main_runtime_thread_ptr(EM_FUNC_SIG_PPP, &emscripten_webgl_do_create_context, target, &attrs);
81+
return (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)emscripten_sync_run_in_main_runtime_thread_ptr(EM_FUNC_SIG_PPP, &_emscripten_webgl_do_create_context, target, &attrs);
8282
} else {
83-
return emscripten_webgl_do_create_context(target, attributes);
83+
return _emscripten_webgl_do_create_context(target, attributes);
8484
}
8585
}
8686

@@ -90,14 +90,14 @@ EMSCRIPTEN_RESULT emscripten_webgl_make_context_current(EMSCRIPTEN_WEBGL_CONTEXT
9090
return EMSCRIPTEN_RESULT_SUCCESS;
9191

9292
if (context && GetOwningThread(context) == pthread_self()) {
93-
EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current_calling_thread(context);
93+
EMSCRIPTEN_RESULT r = _emscripten_webgl_make_context_current_calling_thread(context);
9494
if (r == EMSCRIPTEN_RESULT_SUCCESS) {
9595
pthread_setspecific(currentActiveWebGLContext, (void*)context);
9696
pthread_setspecific(currentThreadOwnsItsWebGLContext, (void*)1);
9797
}
9898
return r;
9999
} else {
100-
EMSCRIPTEN_RESULT r = emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_IP, &emscripten_webgl_make_context_current_calling_thread, context);
100+
EMSCRIPTEN_RESULT r = emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_IP, &_emscripten_webgl_make_context_current_calling_thread, context);
101101
if (r == EMSCRIPTEN_RESULT_SUCCESS) {
102102
pthread_setspecific(currentActiveWebGLContext, (void*)context);
103103
pthread_setspecific(currentThreadOwnsItsWebGLContext, (void*)0);
@@ -114,16 +114,16 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_get_current_context(void) {
114114
EMSCRIPTEN_RESULT emscripten_webgl_commit_frame(void) {
115115
GL_FUNCTION_TRACE();
116116
if (pthread_getspecific(currentThreadOwnsItsWebGLContext))
117-
return emscripten_webgl_do_commit_frame();
117+
return _emscripten_webgl_do_commit_frame();
118118
else
119-
return (EMSCRIPTEN_RESULT)emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_I, &emscripten_webgl_do_commit_frame);
119+
return (EMSCRIPTEN_RESULT)emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_I, &_emscripten_webgl_do_commit_frame);
120120
}
121121

122122
EMSCRIPTEN_RESULT emscripten_webgl_destroy_context(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context) {
123123
GL_FUNCTION_TRACE();
124124
if (emscripten_webgl_get_current_context() == context)
125125
emscripten_webgl_make_context_current(0);
126-
return emscripten_webgl_do_destroy_context(context);
126+
return _emscripten_webgl_do_destroy_context(context);
127127
}
128128

129129
static void *memdup(const void *ptr, size_t sz) {

‎system/lib/gl/webgl_internal.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
*/
77
#pragma once
88

9-
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_do_get_current_context(void);
10-
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_do_create_context(const char *target, const EmscriptenWebGLContextAttributes *attributes);
11-
EMSCRIPTEN_RESULT emscripten_webgl_make_context_current_calling_thread(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context);
12-
EMSCRIPTEN_RESULT emscripten_webgl_do_commit_frame(void);
13-
EMSCRIPTEN_RESULT emscripten_webgl_do_destroy_context(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context);
9+
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE _emscripten_webgl_do_get_current_context(void);
10+
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE _emscripten_webgl_do_create_context(const char *target, const EmscriptenWebGLContextAttributes *attributes);
11+
EMSCRIPTEN_RESULT _emscripten_webgl_make_context_current_calling_thread(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context);
12+
EMSCRIPTEN_RESULT _emscripten_webgl_do_commit_frame(void);
13+
EMSCRIPTEN_RESULT _emscripten_webgl_do_destroy_context(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context);
1414
bool emscripten_supports_offscreencanvas(void);
1515
void _emscripten_proxied_gl_context_activated_from_main_browser_thread(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context);
1616

‎test/codesize/test_codesize_hello_dylink_all.json‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"a.out.js": 272709,
2+
"a.out.js": 272713,
33
"a.out.nodebug.wasm": 588152,
4-
"total": 860861,
4+
"total": 860865,
55
"sent": [
66
"IMG_Init",
77
"IMG_Load",
@@ -300,6 +300,10 @@
300300
"_emscripten_runtime_keepalive_clear",
301301
"_emscripten_system",
302302
"_emscripten_throw_longjmp",
303+
"_emscripten_webgl_do_commit_frame",
304+
"_emscripten_webgl_do_create_context",
305+
"_emscripten_webgl_do_destroy_context",
306+
"_emscripten_webgl_do_get_current_context",
303307
"_glGetActiveAttribOrUniform",
304308
"_gmtime_js",
305309
"_localtime_js",
@@ -957,10 +961,6 @@
957961
"emscripten_webgl_commit_frame",
958962
"emscripten_webgl_create_context",
959963
"emscripten_webgl_destroy_context",
960-
"emscripten_webgl_do_commit_frame",
961-
"emscripten_webgl_do_create_context",
962-
"emscripten_webgl_do_destroy_context",
963-
"emscripten_webgl_do_get_current_context",
964964
"emscripten_webgl_enable_ANGLE_instanced_arrays",
965965
"emscripten_webgl_enable_EXT_clip_control",
966966
"emscripten_webgl_enable_EXT_polygon_offset_clamp",

0 commit comments

Comments
 (0)