expo-gl 56.0.2 → 56.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/android/CMakeLists.txt +3 -0
  3. package/android/build.gradle +58 -2
  4. package/android/src/main/cpp/EXGLJniApi.cpp +3 -7
  5. package/common/EXGLContextManager.cpp +3 -1
  6. package/common/EXGLContextManager.h +8 -1
  7. package/common/EXGLImageUtils.cpp +16 -15
  8. package/common/EXGLImageUtils.h +6 -15
  9. package/common/EXGLNativeApi.cpp +3 -3
  10. package/common/EXGLNativeContext.cpp +13 -10
  11. package/common/EXGLNativeContext.h +19 -25
  12. package/common/EXJsiArgsTransform.h +58 -117
  13. package/common/EXJsiUtils.h +24 -23
  14. package/common/EXTypedArrayApi.cpp +79 -63
  15. package/common/EXTypedArrayApi.h +72 -42
  16. package/common/EXWebGLMethods.cpp +22 -1439
  17. package/common/EXWebGLMethods.h +6 -1
  18. package/common/EXWebGLMethodsDraw.cpp +862 -0
  19. package/common/EXWebGLMethodsHelpers.h +31 -40
  20. package/common/EXWebGLMethodsMacros.h +51 -0
  21. package/common/EXWebGLMethodsTextures.cpp +541 -0
  22. package/common/EXWebGLRenderer.cpp +63 -49
  23. package/common/EXWebGLRenderer.h +9 -6
  24. package/common/pch.h +21 -0
  25. package/expo-module.config.json +1 -1
  26. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.aar +0 -0
  27. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.aar.md5 +1 -0
  28. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.aar.sha1 +1 -0
  29. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.aar.sha256 +1 -0
  30. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.aar.sha512 +1 -0
  31. package/local-maven-repo/host/exp/exponent/expo.modules.gl/{56.0.2/expo.modules.gl-56.0.2.module → 56.0.4/expo.modules.gl-56.0.4.module} +17 -17
  32. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.module.md5 +1 -0
  33. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.module.sha1 +1 -0
  34. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.module.sha256 +1 -0
  35. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.module.sha512 +1 -0
  36. package/local-maven-repo/host/exp/exponent/expo.modules.gl/{56.0.2/expo.modules.gl-56.0.2.pom → 56.0.4/expo.modules.gl-56.0.4.pom} +1 -1
  37. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.pom.md5 +1 -0
  38. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.pom.sha1 +1 -0
  39. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.pom.sha256 +1 -0
  40. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.4/expo.modules.gl-56.0.4.pom.sha512 +1 -0
  41. package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml +4 -4
  42. package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.md5 +1 -1
  43. package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.sha1 +1 -1
  44. package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.sha256 +1 -1
  45. package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.sha512 +1 -1
  46. package/package.json +4 -4
  47. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.aar +0 -0
  48. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.aar.md5 +0 -1
  49. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.aar.sha1 +0 -1
  50. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.aar.sha256 +0 -1
  51. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.aar.sha512 +0 -1
  52. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.module.md5 +0 -1
  53. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.module.sha1 +0 -1
  54. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.module.sha256 +0 -1
  55. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.module.sha512 +0 -1
  56. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.pom.md5 +0 -1
  57. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.pom.sha1 +0 -1
  58. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.pom.sha256 +0 -1
  59. package/local-maven-repo/host/exp/exponent/expo.modules.gl/56.0.2/expo.modules.gl-56.0.2.pom.sha512 +0 -1
  60. /package/local-maven-repo/host/exp/exponent/expo.modules.gl/{56.0.2/expo.modules.gl-56.0.2-sources.jar → 56.0.4/expo.modules.gl-56.0.4-sources.jar} +0 -0
  61. /package/local-maven-repo/host/exp/exponent/expo.modules.gl/{56.0.2/expo.modules.gl-56.0.2-sources.jar.md5 → 56.0.4/expo.modules.gl-56.0.4-sources.jar.md5} +0 -0
  62. /package/local-maven-repo/host/exp/exponent/expo.modules.gl/{56.0.2/expo.modules.gl-56.0.2-sources.jar.sha1 → 56.0.4/expo.modules.gl-56.0.4-sources.jar.sha1} +0 -0
  63. /package/local-maven-repo/host/exp/exponent/expo.modules.gl/{56.0.2/expo.modules.gl-56.0.2-sources.jar.sha256 → 56.0.4/expo.modules.gl-56.0.4-sources.jar.sha256} +0 -0
  64. /package/local-maven-repo/host/exp/exponent/expo.modules.gl/{56.0.2/expo.modules.gl-56.0.2-sources.jar.sha512 → 56.0.4/expo.modules.gl-56.0.4-sources.jar.sha512} +0 -0
package/CHANGELOG.md CHANGED
@@ -10,6 +10,14 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 56.0.4 — 2026-05-15
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
17
+ ## 56.0.3 — 2026-05-06
18
+
19
+ _This version does not introduce any user-facing changes._
20
+
13
21
  ## 56.0.2 — 2026-05-06
14
22
 
15
23
  _This version does not introduce any user-facing changes._
@@ -21,6 +21,8 @@ add_library(
21
21
  ${COMMON_DIR}/EXGLContextManager.cpp
22
22
  ${COMMON_DIR}/EXGLContextManager.h
23
23
  ${COMMON_DIR}/EXWebGLMethods.cpp
24
+ ${COMMON_DIR}/EXWebGLMethodsTextures.cpp
25
+ ${COMMON_DIR}/EXWebGLMethodsDraw.cpp
24
26
  ${COMMON_DIR}/EXWebGLMethods.h
25
27
  ${COMMON_DIR}/EXWebGLRenderer.cpp
26
28
  ${COMMON_DIR}/EXWebGLRenderer.h
@@ -46,4 +48,5 @@ target_compile_options(
46
48
  -Wno-unused-parameter
47
49
  -Wshorten-64-to-32
48
50
  -Wstrict-prototypes)
51
+ target_precompile_headers(${PACKAGE_NAME} PRIVATE ${COMMON_DIR}/pch.h)
49
52
  target_link_libraries(${PACKAGE_NAME} ReactAndroid::jsi ${LOG_LIB} ${GLES_LIB} android)
@@ -1,3 +1,5 @@
1
+ import groovy.json.JsonSlurper
2
+
1
3
  plugins {
2
4
  id 'com.android.library'
3
5
  id 'expo-module-gradle-plugin'
@@ -9,7 +11,7 @@ def reactNativeArchitectures() {
9
11
  }
10
12
 
11
13
  group = 'host.exp.exponent'
12
- version = '56.0.2'
14
+ version = '56.0.4'
13
15
 
14
16
  android {
15
17
  if (rootProject.hasProperty("ndkPath")) {
@@ -22,7 +24,7 @@ android {
22
24
  namespace "expo.modules.gl"
23
25
  defaultConfig {
24
26
  versionCode 31
25
- versionName "56.0.2"
27
+ versionName "56.0.4"
26
28
 
27
29
  externalNativeBuild {
28
30
  cmake {
@@ -61,3 +63,57 @@ dependencies {
61
63
  compileOnly 'com.facebook.soloader:soloader:0.8.2'
62
64
  compileOnly 'com.facebook.react:react-android'
63
65
  }
66
+
67
+ // Generates minimal stub PCH files from an empty header so the IDE's C++ engine
68
+ // doesn't fail during sync. Near-instant unlike the full ExpoHeader.pch.
69
+ // The actual build regenerates proper PCH files via ninja.
70
+ def cxxDir = project.file(".cxx")
71
+ def generateStubPCHTask = tasks.register("generateStubPCH") {
72
+ dependsOn("configureCMakeDebug")
73
+
74
+ doLast {
75
+ if (!cxxDir.exists()) {
76
+ return
77
+ }
78
+
79
+ cxxDir.eachFileRecurse { file ->
80
+ if (file.name != "compile_commands.json") {
81
+ return
82
+ }
83
+
84
+ new JsonSlurper().parseText(file.text).each { entry ->
85
+ if (!entry.file.endsWith("cmake_pch.hxx.cxx")) {
86
+ return
87
+ }
88
+
89
+ def pchFile = new File(entry.file.substring(0, entry.file.length() - ".cxx".length()) + ".pch")
90
+
91
+ if (!pchFile.exists() || pchFile.length() == 0) {
92
+ def stubHeader = new File(entry.directory, "stub_pch.hxx")
93
+ stubHeader.text = ""
94
+
95
+ def cmd = entry.command
96
+ // Replace the forced-include path: `-Xclang -include -Xclang <path>/cmake_pch.hxx`
97
+ .replaceAll(/-Xclang -include -Xclang [^\s]+cmake_pch\.hxx(?=\s)/, "-Xclang -include -Xclang ${stubHeader.absolutePath}")
98
+ // Replace the source file operand: `<path>/cmake_pch.hxx.cxx`
99
+ .replaceAll(/[^\s]+cmake_pch\.hxx\.cxx/, stubHeader.absolutePath)
100
+
101
+ def process = new ProcessBuilder(cmd.split(" ").toList())
102
+ .directory(new File(entry.directory))
103
+ .redirectErrorStream(true)
104
+ .start()
105
+ if (process.waitFor() != 0) {
106
+ throw new GradleException("Stub PCH generation failed: ${process.inputStream.text}")
107
+ }
108
+ }
109
+
110
+ // Ensure PCH is older than source so ninja rebuilds the real one during build
111
+ pchFile.setLastModified(new File(entry.file).lastModified() - 1)
112
+ }
113
+ }
114
+ }
115
+ }
116
+
117
+ tasks.register("prepareKotlinBuildScriptModel") {
118
+ dependsOn(generateStubPCHTask)
119
+ }
@@ -1,10 +1,6 @@
1
- #include <stdint.h>
2
-
3
1
  #include <jni.h>
4
2
  #include <thread>
5
- #include <android/log.h>
6
3
 
7
- #include <jsi/jsi.h>
8
4
  #include "EXGLNativeApi.h"
9
5
  #include "EXPlatformUtils.h"
10
6
 
@@ -12,7 +8,7 @@ extern "C" {
12
8
 
13
9
  // JNIEnv is valid only inside the same thread that it was passed from
14
10
  // to support worklet we need register it from UI thread
15
- thread_local JNIEnv* threadLocalEnv;
11
+ thread_local JNIEnv *threadLocalEnv;
16
12
 
17
13
  JNIEXPORT jint JNICALL
18
14
  Java_expo_modules_gl_cpp_EXGL_EXGLContextCreate
@@ -31,7 +27,7 @@ Java_expo_modules_gl_cpp_EXGL_EXGLContextPrepare
31
27
  std::function<void(void)> flushMethod = [glContextRef, flushMethodRef] {
32
28
  threadLocalEnv->CallVoidMethod(glContextRef, flushMethodRef);
33
29
  };
34
- EXGLContextPrepare((void*) jsiPtr, exglCtxId, flushMethod);
30
+ EXGLContextPrepare((void *) jsiPtr, exglCtxId, flushMethod);
35
31
  }
36
32
 
37
33
  JNIEXPORT void JNICALL
@@ -77,7 +73,7 @@ Java_expo_modules_gl_cpp_EXGL_EXGLContextGetObject
77
73
  return EXGLContextGetObject(exglCtxId, exglObjId);
78
74
  }
79
75
 
80
- JNIEXPORT bool JNICALL
76
+ JNIEXPORT jboolean JNICALL
81
77
  Java_expo_modules_gl_cpp_EXGL_EXGLContextNeedsRedraw
82
78
  (JNIEnv *env, jclass clazz, jint exglCtxId) {
83
79
  return EXGLContextNeedsRedraw(exglCtxId);
@@ -1,5 +1,7 @@
1
1
  #include "EXGLContextManager.h"
2
- #include <mutex>
2
+ #include "EXGLNativeContext.h"
3
+ #include <chrono>
4
+ #include <thread>
3
5
 
4
6
  namespace expo {
5
7
  namespace gl_cpp {
@@ -1,15 +1,22 @@
1
1
  #pragma once
2
2
 
3
+ #include "pch.h"
4
+
3
5
  #include <shared_mutex>
4
- #include "EXGLNativeContext.h"
6
+
7
+ #include "EXGLNativeApi.h"
5
8
 
6
9
  namespace expo {
7
10
  namespace gl_cpp {
8
11
 
12
+ class EXGLContext;
13
+
9
14
  using ContextWithLock = std::pair<EXGLContext *, std::shared_lock<std::shared_mutex>>;
10
15
 
11
16
  EXGLContextId ContextCreate();
17
+
12
18
  ContextWithLock ContextGet(EXGLContextId id);
19
+
13
20
  void ContextDestroy(EXGLContextId id);
14
21
 
15
22
  } // namespace gl_cpp
@@ -3,6 +3,7 @@
3
3
  #define STBI_ONLY_JPEG
4
4
  #define STBI_ONLY_PNG
5
5
  #define STB_IMAGE_IMPLEMENTATION
6
+
6
7
  #include "stb_image.h"
7
8
 
8
9
  namespace jsi = facebook::jsi;
@@ -47,14 +48,14 @@ void flipPixels(GLubyte *pixels, size_t bytesPerRow, size_t rows) {
47
48
  return;
48
49
  }
49
50
 
50
- GLuint middle = (GLuint)rows / 2;
51
- GLuint intsPerRow = (GLuint)bytesPerRow / sizeof(GLuint);
52
- GLuint remainingBytes = (GLuint)bytesPerRow - intsPerRow * sizeof(GLuint);
51
+ GLuint middle = (GLuint) rows / 2;
52
+ GLuint intsPerRow = (GLuint) bytesPerRow / sizeof(GLuint);
53
+ GLuint remainingBytes = (GLuint) bytesPerRow - intsPerRow * sizeof(GLuint);
53
54
 
54
- for (GLuint rowTop = 0, rowBottom = (GLuint)rows - 1; rowTop < middle; ++rowTop, --rowBottom) {
55
+ for (GLuint rowTop = 0, rowBottom = (GLuint) rows - 1; rowTop < middle; ++rowTop, --rowBottom) {
55
56
  // Swap in packs of sizeof(GLuint) bytes
56
- GLuint *iTop = (GLuint *)(pixels + rowTop * bytesPerRow);
57
- GLuint *iBottom = (GLuint *)(pixels + rowBottom * bytesPerRow);
57
+ GLuint *iTop = (GLuint *) (pixels + rowTop * bytesPerRow);
58
+ GLuint *iBottom = (GLuint *) (pixels + rowBottom * bytesPerRow);
58
59
  GLuint iTmp;
59
60
  GLuint n = intsPerRow;
60
61
  do {
@@ -64,8 +65,8 @@ void flipPixels(GLubyte *pixels, size_t bytesPerRow, size_t rows) {
64
65
  } while (--n > 0);
65
66
 
66
67
  // Swap remainder bytes
67
- GLubyte *bTop = (GLubyte *)iTop;
68
- GLubyte *bBottom = (GLubyte *)iBottom;
68
+ GLubyte *bTop = (GLubyte *) iTop;
69
+ GLubyte *bBottom = (GLubyte *) iBottom;
69
70
  GLubyte bTmp;
70
71
  switch (remainingBytes) {
71
72
  case 3:
@@ -117,11 +118,11 @@ void decodeURI(char *dst, const char *src) {
117
118
  }
118
119
 
119
120
  std::shared_ptr<uint8_t> loadImage(
120
- jsi::Runtime &runtime,
121
- const jsi::Object &jsPixels,
122
- int *fileWidth,
123
- int *fileHeight,
124
- int *fileComp) {
121
+ jsi::Runtime &runtime,
122
+ const jsi::Object &jsPixels,
123
+ int *fileWidth,
124
+ int *fileHeight,
125
+ int *fileComp) {
125
126
  auto localUriProp = jsPixels.getProperty(runtime, "localUri");
126
127
  if (localUriProp.isString()) {
127
128
  auto localUri = localUriProp.asString(runtime).utf8(runtime);
@@ -132,8 +133,8 @@ std::shared_ptr<uint8_t> loadImage(
132
133
  decodeURI(localPath, localUri.c_str() + 7);
133
134
 
134
135
  return std::shared_ptr<uint8_t>(
135
- stbi_load(localPath, fileWidth, fileHeight, fileComp, STBI_rgb_alpha),
136
- [](void *data) { stbi_image_free(data); });
136
+ stbi_load(localPath, fileWidth, fileHeight, fileComp, STBI_rgb_alpha),
137
+ [](void *data) { stbi_image_free(data); });
137
138
  }
138
139
  return std::shared_ptr<uint8_t>(nullptr);
139
140
  }
@@ -1,15 +1,6 @@
1
1
  #pragma once
2
2
 
3
- #ifdef __ANDROID__
4
- #include <GLES3/gl3.h>
5
- #include <GLES3/gl3ext.h>
6
- #endif
7
- #ifdef __APPLE__
8
- #include <OpenGLES/ES3/gl.h>
9
- #endif
10
-
11
- #include <jsi/jsi.h>
12
- #include <vector>
3
+ #include "pch.h"
13
4
 
14
5
  namespace expo {
15
6
  namespace gl_cpp {
@@ -19,10 +10,10 @@ GLuint bytesPerPixel(GLenum type, GLenum format);
19
10
  void flipPixels(GLubyte *pixels, size_t bytesPerRow, size_t rows);
20
11
 
21
12
  std::shared_ptr<uint8_t> loadImage(
22
- facebook::jsi::Runtime &runtime,
23
- const facebook::jsi::Object &jsPixels,
24
- int *fileWidth,
25
- int *fileHeight,
26
- int *fileComp);
13
+ facebook::jsi::Runtime &runtime,
14
+ const facebook::jsi::Object &jsPixels,
15
+ int *fileWidth,
16
+ int *fileHeight,
17
+ int *fileComp);
27
18
  } // namespace gl_cpp
28
19
  } // namespace expo
@@ -9,9 +9,9 @@ EXGLContextId EXGLContextCreate() {
9
9
  }
10
10
 
11
11
  void EXGLContextPrepare(
12
- void *jsiPtr,
13
- EXGLContextId exglCtxId,
14
- std::function<void(void)> flushMethod) {
12
+ void *jsiPtr,
13
+ EXGLContextId exglCtxId,
14
+ std::function<void(void)> flushMethod) {
15
15
  auto [exglCtx, lock] = ContextGet(exglCtxId);
16
16
  if (exglCtx) {
17
17
  exglCtx->prepareContext(*reinterpret_cast<jsi::Runtime *>(jsiPtr), flushMethod);
@@ -1,4 +1,7 @@
1
1
  #include "EXGLNativeContext.h"
2
+
3
+ #include <future>
4
+
2
5
  #include "EXPlatformUtils.h"
3
6
 
4
7
  namespace expo {
@@ -34,7 +37,7 @@ void EXGLContext::maybeResolveWorkletContext(jsi::Runtime &runtime) {
34
37
  return;
35
38
  }
36
39
  uintptr_t rawWorkletRuntimePointer =
37
- *reinterpret_cast<uintptr_t *>(workletRuntimeArrayBuffer.data(runtime));
40
+ *reinterpret_cast<uintptr_t *>(workletRuntimeArrayBuffer.data(runtime));
38
41
  jsi::Runtime *workletRuntime = reinterpret_cast<jsi::Runtime *>(rawWorkletRuntimePointer);
39
42
  this->maybeWorkletRuntime = workletRuntime;
40
43
  }
@@ -45,7 +48,7 @@ void EXGLContext::prepareWorkletContext() {
45
48
  }
46
49
  jsi::Runtime &runtime = *this->maybeWorkletRuntime;
47
50
  createWebGLRenderer(
48
- runtime, this, initialGlesContext, runtime.global().getPropertyAsObject(runtime, "global"));
51
+ runtime, this, initialGlesContext, runtime.global().getPropertyAsObject(runtime, "global"));
49
52
  tryRegisterOnJSRuntimeDestroy(runtime);
50
53
  }
51
54
 
@@ -76,8 +79,8 @@ void EXGLContext::addBlockingToNextBatch(Op &&op) {
76
79
  // [JS thread] Enqueue a function and return an EXGL object that will get mapped
77
80
  // to the function's return value when it is called on the GL thread.
78
81
  jsi::Value EXGLContext::addFutureToNextBatch(
79
- jsi::Runtime &runtime,
80
- std::function<unsigned int(void)> &&op) noexcept {
82
+ jsi::Runtime &runtime,
83
+ std::function<unsigned int(void)> &&op) noexcept {
81
84
  auto exglObjId = createObject();
82
85
  addToNextBatch([=] {
83
86
  assert(objects.find(exglObjId) == objects.end());
@@ -94,8 +97,8 @@ void EXGLContext::flush(void) {
94
97
  std::lock_guard<std::mutex> lock(backlogMutex);
95
98
  std::swap(backlog, copy);
96
99
  }
97
- for (const auto &batch : copy) {
98
- for (const auto &op : batch) {
100
+ for (const auto &batch: copy) {
101
+ for (const auto &op: batch) {
99
102
  op();
100
103
  }
101
104
  }
@@ -128,10 +131,10 @@ void EXGLContext::tryRegisterOnJSRuntimeDestroy(jsi::Runtime &runtime) {
128
131
  // `jsi::Runtime` is being destroyed and that will trigger destructor of
129
132
  // `InvalidateCacheOnDestroy` class which will invalidate JSI PropNameID cache.
130
133
  global.setProperty(
131
- runtime,
132
- OnJSRuntimeDestroyPropertyName,
133
- jsi::Object::createFromHostObject(
134
- runtime, std::make_shared<InvalidateCacheOnDestroy>(runtime)));
134
+ runtime,
135
+ OnJSRuntimeDestroyPropertyName,
136
+ jsi::Object::createFromHostObject(
137
+ runtime, std::make_shared<InvalidateCacheOnDestroy>(runtime)));
135
138
  }
136
139
 
137
140
  glesContext EXGLContext::prepareOpenGLESContext() {
@@ -1,28 +1,11 @@
1
1
  #pragma once
2
2
 
3
- #include "EXGLNativeApi.h"
4
-
5
- #ifdef __ANDROID__
6
- #include <GLES3/gl3.h>
7
- #include <GLES3/gl3ext.h>
8
- #endif
9
- #ifdef __APPLE__
10
- #include <OpenGLES/EAGL.h>
11
- #include <OpenGLES/ES3/gl.h>
12
- #include <OpenGLES/ES3/glext.h>
13
- #endif
3
+ #include "pch.h"
14
4
 
15
- #include "EXTypedArrayApi.h"
16
-
17
- #include <exception>
18
- #include <future>
19
5
  #include <set>
20
- #include <sstream>
21
- #include <unordered_map>
22
- #include <vector>
23
-
24
- #include <jsi/jsi.h>
25
6
 
7
+ #include "EXGLNativeApi.h"
8
+ #include "EXTypedArrayApi.h"
26
9
  #include "EXJsiUtils.h"
27
10
  #include "EXPlatformUtils.h"
28
11
  #include "EXWebGLRenderer.h"
@@ -48,10 +31,13 @@ class EXGLContext {
48
31
  using Op = std::function<void(void)>;
49
32
  using Batch = std::vector<Op>;
50
33
 
51
- public:
34
+ public:
52
35
  EXGLContext(EXGLContextId ctxId) : ctxId(ctxId) {}
36
+
53
37
  void prepareContext(jsi::Runtime &runtime, std::function<void(void)> flushMethod);
38
+
54
39
  void maybeResolveWorkletContext(jsi::Runtime &runtime);
40
+
55
41
  void prepareWorkletContext();
56
42
 
57
43
  // --- Queue handling --------------------------------------------------------
@@ -67,8 +53,10 @@ class EXGLContext {
67
53
 
68
54
  // [JS thread] Send the current 'next' batch to GL and make a new 'next' batch
69
55
  void endNextBatch() noexcept;
56
+
70
57
  // [JS thread] Add an Op to the 'next' batch
71
58
  void addToNextBatch(Op &&op) noexcept;
59
+
72
60
  // [JS thread] Add a blocking operation to the 'next' batch -- waits for the
73
61
  // queued function to run before returning
74
62
  void addBlockingToNextBatch(Op &&op);
@@ -86,8 +74,9 @@ class EXGLContext {
86
74
  // To make it work lookupObject can be called only on GL thread
87
75
  //
88
76
  jsi::Value addFutureToNextBatch(
89
- jsi::Runtime &runtime,
90
- std::function<unsigned int(void)> &&op) noexcept;
77
+ jsi::Runtime &runtime,
78
+ std::function<unsigned int(void)> &&op
79
+ ) noexcept;
91
80
 
92
81
  // [GL thread] Do all the remaining work we can do on the GL thread
93
82
  // triggered by call to flushOnGLThread
@@ -102,21 +91,26 @@ class EXGLContext {
102
91
  // mutex on the mapping.
103
92
 
104
93
  EXGLObjectId createObject(void) noexcept;
94
+
105
95
  void destroyObject(EXGLObjectId exglObjId) noexcept;
96
+
106
97
  void mapObject(EXGLObjectId exglObjId, GLuint glObj) noexcept;
98
+
107
99
  GLuint lookupObject(EXGLObjectId exglObjId) noexcept;
108
100
 
109
101
  void tryRegisterOnJSRuntimeDestroy(jsi::Runtime &runtime);
102
+
110
103
  glesContext prepareOpenGLESContext();
104
+
111
105
  void maybeReadAndCacheSupportedExtensions();
112
106
 
113
- private:
107
+ private:
114
108
  // Queue
115
109
  Batch nextBatch;
116
110
  std::vector<Batch> backlog;
117
111
  std::mutex backlogMutex;
118
112
 
119
- public:
113
+ public:
120
114
  EXGLContextId ctxId;
121
115
  // Worklet runtime is stored here only to avoid it passing through Java/Obj-C.
122
116
  // It should only be used in prepareContext and prepareWorkletContext.