expo-gl 16.0.8 → 16.0.9-canary-20251205-a1dedc6
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.
- package/CHANGELOG.md +10 -1
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/gl/GLContext.java +2 -2
- package/android/src/main/java/expo/modules/gl/{GLObjectManagerModule.kt → GLModule.kt} +10 -3
- package/android/src/main/java/expo/modules/gl/GLView.kt +1 -1
- package/build/GLView.d.ts +0 -1
- package/build/GLView.d.ts.map +1 -1
- package/build/GLView.js +10 -18
- package/build/GLView.js.map +1 -1
- package/common/EXGLImageUtils.cpp +3 -0
- package/common/stb_image.h +6674 -5981
- package/expo-module.config.json +3 -3
- package/ios/EXGLContext.mm +2 -4
- package/ios/EXGLObjectManager.h +21 -8
- package/ios/EXGLObjectManager.mm +32 -76
- package/ios/ExpoGLModule.swift +76 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.module +87 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/{16.0.8/expo.modules.gl-16.0.8.pom → 16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251205-a1dedc6/expo.modules.gl-16.0.9-canary-20251205-a1dedc6.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/maven-metadata.xml.sha512 +1 -1
- package/package.json +5 -6
- package/src/GLView.tsx +9 -23
- package/android/src/main/java/expo/modules/gl/GLViewModule.kt +0 -17
- package/ios/GLViewModule.swift +0 -20
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.module +0 -87
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,7 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
- Methods of the legacy `EXGLObjectManager` module are now exported from the existing native module in Swift. ([#41171](https://github.com/expo/expo/pull/41171) by [@tsapeta](https://github.com/tsapeta))
|
|
14
|
+
- [android] rename module to align with iOS ([#41193](https://github.com/expo/expo/pull/41193) by [@Ubax](https://github.com/Ubax))
|
|
15
|
+
|
|
16
|
+
### ⚠️ Notices
|
|
17
|
+
|
|
18
|
+
- **Performance optimization**: reduce supported old image formats in lib `stb_image.h` used for image decoding in `texImage2D` expo wrapper to support only **JPEG, PNG, GIF** image formats. Formats **BMP, PSD, TGA, HDR, PIC, PNM** are no longer supported. ([#41001](https://github.com/expo/expo/pull/41001) by [@psnet](https://github.com/psnet))
|
|
19
|
+
- Updated library `stb_image.h` used for image decoding in `texImage2D` expo wraper method. A lot of fixes and performance improvements, see related PR. ([#41000](https://github.com/expo/expo/pull/41000) by [@psnet](https://github.com/psnet))
|
|
20
|
+
- Added support for React Native 0.82.x. ([#39678](https://github.com/expo/expo/pull/39678) by [@gabrieldonadel](https://github.com/gabrieldonadel))
|
|
21
|
+
|
|
22
|
+
## 16.0.8 - 2025-12-05
|
|
14
23
|
|
|
15
24
|
_This version does not introduce any user-facing changes._
|
|
16
25
|
|
package/android/build.gradle
CHANGED
|
@@ -9,7 +9,7 @@ def reactNativeArchitectures() {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
group = 'host.exp.exponent'
|
|
12
|
-
version = '16.0.
|
|
12
|
+
version = '16.0.9-canary-20251205-a1dedc6'
|
|
13
13
|
|
|
14
14
|
android {
|
|
15
15
|
if (rootProject.hasProperty("ndkPath")) {
|
|
@@ -22,7 +22,7 @@ android {
|
|
|
22
22
|
namespace "expo.modules.gl"
|
|
23
23
|
defaultConfig {
|
|
24
24
|
versionCode 31
|
|
25
|
-
versionName "16.0.
|
|
25
|
+
versionName "16.0.9-canary-20251205-a1dedc6"
|
|
26
26
|
|
|
27
27
|
externalNativeBuild {
|
|
28
28
|
cmake {
|
|
@@ -39,7 +39,7 @@ import static expo.modules.gl.cpp.EXGL.*;
|
|
|
39
39
|
public class GLContext {
|
|
40
40
|
private int mEXGLCtxId = -1;
|
|
41
41
|
|
|
42
|
-
private final
|
|
42
|
+
private final GLModule mManager;
|
|
43
43
|
private GLThread mGLThread;
|
|
44
44
|
private EGLDisplay mEGLDisplay;
|
|
45
45
|
private EGLSurface mEGLSurface;
|
|
@@ -49,7 +49,7 @@ public class GLContext {
|
|
|
49
49
|
|
|
50
50
|
private BlockingQueue<Runnable> mEventQueue = new LinkedBlockingQueue<>();
|
|
51
51
|
|
|
52
|
-
public GLContext(
|
|
52
|
+
public GLContext(GLModule manager) {
|
|
53
53
|
super();
|
|
54
54
|
mManager = manager;
|
|
55
55
|
}
|
|
@@ -18,11 +18,11 @@ private class InvalidCameraViewException :
|
|
|
18
18
|
private class InvalidGLContextException :
|
|
19
19
|
CodedException("GLContext not found for given context id")
|
|
20
20
|
|
|
21
|
-
class
|
|
21
|
+
class GLModule : Module() {
|
|
22
22
|
private val mGLObjects = SparseArray<GLObject>()
|
|
23
23
|
private val mGLContextMap = SparseArray<GLContext>()
|
|
24
24
|
override fun definition() = ModuleDefinition {
|
|
25
|
-
Name("
|
|
25
|
+
Name("ExpoGL")
|
|
26
26
|
|
|
27
27
|
AsyncFunction("destroyObjectAsync") { exglObjId: Int ->
|
|
28
28
|
val glObject = mGLObjects[exglObjId]
|
|
@@ -61,7 +61,7 @@ class GLObjectManagerModule : Module() {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
AsyncFunction("createContextAsync") { promise: Promise ->
|
|
64
|
-
val glContext = GLContext(this@
|
|
64
|
+
val glContext = GLContext(this@GLModule)
|
|
65
65
|
glContext.initialize(null, false) {
|
|
66
66
|
val results = Bundle()
|
|
67
67
|
results.putInt("exglCtxId", glContext.contextId)
|
|
@@ -76,6 +76,13 @@ class GLObjectManagerModule : Module() {
|
|
|
76
76
|
glContext.destroy()
|
|
77
77
|
true
|
|
78
78
|
}
|
|
79
|
+
|
|
80
|
+
View(GLView::class) {
|
|
81
|
+
Events("onSurfaceCreate")
|
|
82
|
+
Prop("enableExperimentalWorkletSupport") { view: GLView, enableExperimentalWorkletSupport: Boolean? ->
|
|
83
|
+
view.enableExperimentalWorkletSupport = enableExperimentalWorkletSupport ?: false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
private fun getContextWithId(exglCtxId: Int): GLContext? {
|
package/build/GLView.d.ts
CHANGED
|
@@ -48,7 +48,6 @@ export declare class GLView extends React.Component<GLViewProps> {
|
|
|
48
48
|
_onSurfaceCreate: ({ nativeEvent: { exglCtxId } }: SurfaceCreateEvent) => void;
|
|
49
49
|
componentWillUnmount(): void;
|
|
50
50
|
componentDidUpdate(prevProps: GLViewProps): void;
|
|
51
|
-
startARSessionAsync(): Promise<any>;
|
|
52
51
|
createCameraTextureAsync(cameraRefOrHandle: ComponentOrHandle): Promise<WebGLTexture>;
|
|
53
52
|
destroyObjectAsync(glObject: WebGLObject): Promise<boolean>;
|
|
54
53
|
/**
|
package/build/GLView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLView.d.ts","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GLView.d.ts","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,yBAAyB,EACzB,eAAe,EACf,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAIxB,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAQF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,yBAAyB,GAAG,SAAS,CAG1F;AAGD;;;GAGG;AACH,qBAAa,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;IACtD,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC;IAEvB,MAAM,CAAC,YAAY;;;MAGjB;IAEF;;;;;;;OAOG;WACU,kBAAkB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IAKrE;;;;OAIG;WACU,mBAAmB,CAAC,IAAI,CAAC,EAAE,yBAAyB,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM7F;;;;;OAKG;WACU,iBAAiB,CAC5B,IAAI,CAAC,EAAE,yBAAyB,GAAG,MAAM,EACzC,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,UAAU,CAAC;IAKtB;;;OAGG;IACH,MAAM,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,yBAAyB,GAAG,SAAS,CACnD;IAEnC,SAAS,EAAE,iBAAiB,CAAQ;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,MAAM;IAwBN,aAAa,GAAI,WAAW,iBAAiB,KAAG,IAAI,CAKlD;IAEF,gBAAgB,GAAI,gCAAgC,kBAAkB,KAAG,IAAI,CAQ3E;IAEF,oBAAoB,IAAI,IAAI;IAM5B,kBAAkB,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI;IAS1C,wBAAwB,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IAiBrF,kBAAkB,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAOjE;;;;OAIG;IACG,iBAAiB,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,UAAU,CAAC;CAO5E"}
|
package/build/GLView.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnavailabilityError, requireNativeModule, requireNativeViewManager, CodedError, } from 'expo-modules-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { Platform, View, findNodeHandle } from 'react-native';
|
|
4
4
|
import { configureLogging } from './GLUtils';
|
|
5
5
|
import { createWorkletContextManager } from './GLWorkletContextManager';
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const NativeView = requireNativeViewManager('ExponentGLView');
|
|
6
|
+
const GLNativeModule = requireNativeModule('ExpoGL');
|
|
7
|
+
const NativeView = requireNativeViewManager('ExpoGL');
|
|
9
8
|
const workletContextManager = createWorkletContextManager();
|
|
10
9
|
export function getWorkletContext(contextId) {
|
|
11
10
|
'worklet';
|
|
@@ -31,7 +30,7 @@ export class GLView extends React.Component {
|
|
|
31
30
|
* @return A promise that resolves to WebGL context object. See [WebGL API](#webgl-api) for more details.
|
|
32
31
|
*/
|
|
33
32
|
static async createContextAsync() {
|
|
34
|
-
const { exglCtxId } = await
|
|
33
|
+
const { exglCtxId } = await GLNativeModule.createContextAsync();
|
|
35
34
|
return getGl(exglCtxId);
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
@@ -42,7 +41,7 @@ export class GLView extends React.Component {
|
|
|
42
41
|
static async destroyContextAsync(exgl) {
|
|
43
42
|
const exglCtxId = getContextId(exgl);
|
|
44
43
|
unregisterGLContext(exglCtxId);
|
|
45
|
-
return
|
|
44
|
+
return GLNativeModule.destroyContextAsync(exglCtxId);
|
|
46
45
|
}
|
|
47
46
|
/**
|
|
48
47
|
* Takes a snapshot of the framebuffer and saves it as a file to app's cache directory.
|
|
@@ -52,7 +51,7 @@ export class GLView extends React.Component {
|
|
|
52
51
|
*/
|
|
53
52
|
static async takeSnapshotAsync(exgl, options = {}) {
|
|
54
53
|
const exglCtxId = getContextId(exgl);
|
|
55
|
-
return
|
|
54
|
+
return GLNativeModule.takeSnapshotAsync(exglCtxId, options);
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
57
|
* This method doesn't work inside of the worklets with new reanimated versions.
|
|
@@ -98,15 +97,8 @@ export class GLView extends React.Component {
|
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
// @docsMissing
|
|
101
|
-
async startARSessionAsync() {
|
|
102
|
-
if (!ExponentGLViewManager.startARSessionAsync) {
|
|
103
|
-
throw new UnavailabilityError('expo-gl', 'startARSessionAsync');
|
|
104
|
-
}
|
|
105
|
-
return await ExponentGLViewManager.startARSessionAsync(findNodeHandle(this.nativeRef));
|
|
106
|
-
}
|
|
107
|
-
// @docsMissing
|
|
108
100
|
async createCameraTextureAsync(cameraRefOrHandle) {
|
|
109
|
-
if (!
|
|
101
|
+
if (!GLNativeModule.createCameraTextureAsync) {
|
|
110
102
|
throw new UnavailabilityError('expo-gl', 'createCameraTextureAsync');
|
|
111
103
|
}
|
|
112
104
|
const { exglCtxId } = this;
|
|
@@ -114,15 +106,15 @@ export class GLView extends React.Component {
|
|
|
114
106
|
throw new Error("GLView's surface is not created yet!");
|
|
115
107
|
}
|
|
116
108
|
const cameraTag = findNodeHandle(cameraRefOrHandle);
|
|
117
|
-
const { exglObjId } = await
|
|
109
|
+
const { exglObjId } = await GLNativeModule.createCameraTextureAsync(exglCtxId, cameraTag);
|
|
118
110
|
return { id: exglObjId };
|
|
119
111
|
}
|
|
120
112
|
// @docsMissing
|
|
121
113
|
async destroyObjectAsync(glObject) {
|
|
122
|
-
if (!
|
|
114
|
+
if (!GLNativeModule.destroyObjectAsync) {
|
|
123
115
|
throw new UnavailabilityError('expo-gl', 'destroyObjectAsync');
|
|
124
116
|
}
|
|
125
|
-
return await
|
|
117
|
+
return await GLNativeModule.destroyObjectAsync(glObject.id);
|
|
126
118
|
}
|
|
127
119
|
/**
|
|
128
120
|
* Same as static [`takeSnapshotAsync()`](#takesnapshotasyncoptions),
|
package/build/GLView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLView.js","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAS7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AASxE,MAAM,uBAAuB,GAAG,mBAA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AE;IACzE,MAAM,SAAS,GAAG,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3E,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import {\n NativeModulesProxy,\n UnavailabilityError,\n requireNativeModule,\n requireNativeViewManager,\n CodedError,\n} from 'expo-modules-core';\nimport * as React from 'react';\nimport { Platform, View, findNodeHandle } from 'react-native';\n\nimport { configureLogging } from './GLUtils';\nimport {\n ComponentOrHandle,\n SurfaceCreateEvent,\n GLSnapshot,\n ExpoWebGLRenderingContext,\n SnapshotOptions,\n GLViewProps,\n} from './GLView.types';\nimport { createWorkletContextManager } from './GLWorkletContextManager';\n\n// @docsMissing\nexport type WebGLObject = {\n id: number;\n};\n\ndeclare let global: any;\n\nconst ExponentGLObjectManager = requireNativeModule('ExponentGLObjectManager');\nconst { ExponentGLViewManager } = NativeModulesProxy;\n\nconst NativeView = requireNativeViewManager('ExponentGLView');\nconst workletContextManager = createWorkletContextManager();\n\nexport function getWorkletContext(contextId: number): ExpoWebGLRenderingContext | undefined {\n 'worklet';\n return workletContextManager.getContext(contextId);\n}\n\n// @needsAudit\n/**\n * A View that acts as an OpenGL ES render target. On mounting, an OpenGL ES context is created.\n * Its drawing buffer is presented as the contents of the View every frame.\n */\nexport class GLView extends React.Component<GLViewProps> {\n static NativeView: any;\n\n static defaultProps = {\n msaaSamples: 4,\n enableExperimentalWorkletSupport: false,\n };\n\n /**\n * Imperative API that creates headless context which is devoid of underlying view.\n * It's useful for headless rendering or in case you want to keep just one context per application and share it between multiple components.\n * It is slightly faster than usual context as it doesn't swap framebuffers and doesn't present them on the canvas,\n * however it may require you to take a snapshot in order to present its results.\n * Also, keep in mind that you need to set up a viewport and create your own framebuffer and texture that you will be drawing to, before you take a snapshot.\n * @return A promise that resolves to WebGL context object. See [WebGL API](#webgl-api) for more details.\n */\n static async createContextAsync(): Promise<ExpoWebGLRenderingContext> {\n const { exglCtxId } = await ExponentGLObjectManager.createContextAsync();\n return getGl(exglCtxId);\n }\n\n /**\n * Destroys given context.\n * @param exgl WebGL context to destroy.\n * @return A promise that resolves to boolean value that is `true` if given context existed and has been destroyed successfully.\n */\n static async destroyContextAsync(exgl?: ExpoWebGLRenderingContext | number): Promise<boolean> {\n const exglCtxId = getContextId(exgl);\n unregisterGLContext(exglCtxId);\n return ExponentGLObjectManager.destroyContextAsync(exglCtxId);\n }\n\n /**\n * Takes a snapshot of the framebuffer and saves it as a file to app's cache directory.\n * @param exgl WebGL context to take a snapshot from.\n * @param options\n * @return A promise that resolves to `GLSnapshot` object.\n */\n static async takeSnapshotAsync(\n exgl?: ExpoWebGLRenderingContext | number,\n options: SnapshotOptions = {}\n ): Promise<GLSnapshot> {\n const exglCtxId = getContextId(exgl);\n return ExponentGLObjectManager.takeSnapshotAsync(exglCtxId, options);\n }\n\n /**\n * This method doesn't work inside of the worklets with new reanimated versions.\n * @deprecated Use `getWorkletContext` from the global scope instead.\n */\n static getWorkletContext: (contextId: number) => ExpoWebGLRenderingContext | undefined =\n workletContextManager.getContext;\n\n nativeRef: ComponentOrHandle = null;\n exglCtxId?: number;\n\n render() {\n const { onContextCreate, msaaSamples, enableExperimentalWorkletSupport, ...viewProps } =\n this.props;\n\n return (\n <View {...viewProps}>\n <NativeView\n ref={this._setNativeRef}\n style={{\n flex: 1,\n ...(Platform.OS === 'ios'\n ? {\n backgroundColor: 'transparent',\n }\n : {}),\n }}\n onSurfaceCreate={this._onSurfaceCreate}\n enableExperimentalWorkletSupport={enableExperimentalWorkletSupport}\n msaaSamples={Platform.OS === 'ios' ? msaaSamples : undefined}\n />\n </View>\n );\n }\n\n _setNativeRef = (nativeRef: ComponentOrHandle): void => {\n if (this.props.nativeRef_EXPERIMENTAL) {\n this.props.nativeRef_EXPERIMENTAL(nativeRef);\n }\n this.nativeRef = nativeRef;\n };\n\n _onSurfaceCreate = ({ nativeEvent: { exglCtxId } }: SurfaceCreateEvent): void => {\n const gl = getGl(exglCtxId);\n\n this.exglCtxId = exglCtxId;\n\n if (this.props.onContextCreate) {\n this.props.onContextCreate(gl);\n }\n };\n\n componentWillUnmount(): void {\n if (this.exglCtxId) {\n unregisterGLContext(this.exglCtxId);\n }\n }\n\n componentDidUpdate(prevProps: GLViewProps): void {\n if (\n this.props.enableExperimentalWorkletSupport !== prevProps.enableExperimentalWorkletSupport\n ) {\n console.warn('Updating prop enableExperimentalWorkletSupport is not supported');\n }\n }\n\n // @docsMissing\n async startARSessionAsync(): Promise<any> {\n if (!ExponentGLViewManager.startARSessionAsync) {\n throw new UnavailabilityError('expo-gl', 'startARSessionAsync');\n }\n return await ExponentGLViewManager.startARSessionAsync(findNodeHandle(this.nativeRef));\n }\n\n // @docsMissing\n async createCameraTextureAsync(cameraRefOrHandle: ComponentOrHandle): Promise<WebGLTexture> {\n if (!ExponentGLObjectManager.createCameraTextureAsync) {\n throw new UnavailabilityError('expo-gl', 'createCameraTextureAsync');\n }\n\n const { exglCtxId } = this;\n\n if (!exglCtxId) {\n throw new Error(\"GLView's surface is not created yet!\");\n }\n\n const cameraTag = findNodeHandle(cameraRefOrHandle);\n const { exglObjId } = await ExponentGLObjectManager.createCameraTextureAsync(\n exglCtxId,\n cameraTag\n );\n return { id: exglObjId } as WebGLTexture;\n }\n\n // @docsMissing\n async destroyObjectAsync(glObject: WebGLObject): Promise<boolean> {\n if (!ExponentGLObjectManager.destroyObjectAsync) {\n throw new UnavailabilityError('expo-gl', 'destroyObjectAsync');\n }\n return await ExponentGLObjectManager.destroyObjectAsync(glObject.id);\n }\n\n /**\n * Same as static [`takeSnapshotAsync()`](#takesnapshotasyncoptions),\n * but uses WebGL context that is associated with the view on which the method is called.\n * @param options\n */\n async takeSnapshotAsync(options: SnapshotOptions = {}): Promise<GLSnapshot> {\n if (!GLView.takeSnapshotAsync) {\n throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');\n }\n const { exglCtxId } = this;\n return await GLView.takeSnapshotAsync(exglCtxId, options);\n }\n}\n\nGLView.NativeView = NativeView;\n\nfunction unregisterGLContext(exglCtxId: number) {\n if (global.__EXGLContexts) {\n delete global.__EXGLContexts[String(exglCtxId)];\n }\n workletContextManager.unregister?.(exglCtxId);\n}\n\n// Get the GL interface from an EXGLContextId\nconst getGl = (exglCtxId: number): ExpoWebGLRenderingContext => {\n if (!global.__EXGLContexts) {\n throw new CodedError(\n 'ERR_GL_NOT_AVAILABLE',\n 'GL is currently not available. (Have you enabled remote debugging? GL is not available while debugging remotely.)'\n );\n }\n const gl = global.__EXGLContexts[String(exglCtxId)];\n\n configureLogging(gl);\n\n return gl;\n};\n\nconst getContextId = (exgl?: ExpoWebGLRenderingContext | number): number => {\n const exglCtxId = exgl && typeof exgl === 'object' ? exgl.contextId : exgl;\n\n if (!exglCtxId || typeof exglCtxId !== 'number') {\n throw new Error(`Invalid EXGLContext id: ${String(exglCtxId)}`);\n }\n return exglCtxId;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"GLView.js","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAS7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AASxE,MAAM,cAAc,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACrD,MAAM,UAA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\n CodedError,\n} from 'expo-modules-core';\nimport * as React from 'react';\nimport { Platform, View, findNodeHandle } from 'react-native';\n\nimport { configureLogging } from './GLUtils';\nimport {\n ComponentOrHandle,\n SurfaceCreateEvent,\n GLSnapshot,\n ExpoWebGLRenderingContext,\n SnapshotOptions,\n GLViewProps,\n} from './GLView.types';\nimport { createWorkletContextManager } from './GLWorkletContextManager';\n\n// @docsMissing\nexport type WebGLObject = {\n id: number;\n};\n\ndeclare let global: any;\n\nconst GLNativeModule = requireNativeModule('ExpoGL');\nconst NativeView = requireNativeViewManager('ExpoGL');\nconst workletContextManager = createWorkletContextManager();\n\nexport function getWorkletContext(contextId: number): ExpoWebGLRenderingContext | undefined {\n 'worklet';\n return workletContextManager.getContext(contextId);\n}\n\n// @needsAudit\n/**\n * A View that acts as an OpenGL ES render target. On mounting, an OpenGL ES context is created.\n * Its drawing buffer is presented as the contents of the View every frame.\n */\nexport class GLView extends React.Component<GLViewProps> {\n static NativeView: any;\n\n static defaultProps = {\n msaaSamples: 4,\n enableExperimentalWorkletSupport: false,\n };\n\n /**\n * Imperative API that creates headless context which is devoid of underlying view.\n * It's useful for headless rendering or in case you want to keep just one context per application and share it between multiple components.\n * It is slightly faster than usual context as it doesn't swap framebuffers and doesn't present them on the canvas,\n * however it may require you to take a snapshot in order to present its results.\n * Also, keep in mind that you need to set up a viewport and create your own framebuffer and texture that you will be drawing to, before you take a snapshot.\n * @return A promise that resolves to WebGL context object. See [WebGL API](#webgl-api) for more details.\n */\n static async createContextAsync(): Promise<ExpoWebGLRenderingContext> {\n const { exglCtxId } = await GLNativeModule.createContextAsync();\n return getGl(exglCtxId);\n }\n\n /**\n * Destroys given context.\n * @param exgl WebGL context to destroy.\n * @return A promise that resolves to boolean value that is `true` if given context existed and has been destroyed successfully.\n */\n static async destroyContextAsync(exgl?: ExpoWebGLRenderingContext | number): Promise<boolean> {\n const exglCtxId = getContextId(exgl);\n unregisterGLContext(exglCtxId);\n return GLNativeModule.destroyContextAsync(exglCtxId);\n }\n\n /**\n * Takes a snapshot of the framebuffer and saves it as a file to app's cache directory.\n * @param exgl WebGL context to take a snapshot from.\n * @param options\n * @return A promise that resolves to `GLSnapshot` object.\n */\n static async takeSnapshotAsync(\n exgl?: ExpoWebGLRenderingContext | number,\n options: SnapshotOptions = {}\n ): Promise<GLSnapshot> {\n const exglCtxId = getContextId(exgl);\n return GLNativeModule.takeSnapshotAsync(exglCtxId, options);\n }\n\n /**\n * This method doesn't work inside of the worklets with new reanimated versions.\n * @deprecated Use `getWorkletContext` from the global scope instead.\n */\n static getWorkletContext: (contextId: number) => ExpoWebGLRenderingContext | undefined =\n workletContextManager.getContext;\n\n nativeRef: ComponentOrHandle = null;\n exglCtxId?: number;\n\n render() {\n const { onContextCreate, msaaSamples, enableExperimentalWorkletSupport, ...viewProps } =\n this.props;\n\n return (\n <View {...viewProps}>\n <NativeView\n ref={this._setNativeRef}\n style={{\n flex: 1,\n ...(Platform.OS === 'ios'\n ? {\n backgroundColor: 'transparent',\n }\n : {}),\n }}\n onSurfaceCreate={this._onSurfaceCreate}\n enableExperimentalWorkletSupport={enableExperimentalWorkletSupport}\n msaaSamples={Platform.OS === 'ios' ? msaaSamples : undefined}\n />\n </View>\n );\n }\n\n _setNativeRef = (nativeRef: ComponentOrHandle): void => {\n if (this.props.nativeRef_EXPERIMENTAL) {\n this.props.nativeRef_EXPERIMENTAL(nativeRef);\n }\n this.nativeRef = nativeRef;\n };\n\n _onSurfaceCreate = ({ nativeEvent: { exglCtxId } }: SurfaceCreateEvent): void => {\n const gl = getGl(exglCtxId);\n\n this.exglCtxId = exglCtxId;\n\n if (this.props.onContextCreate) {\n this.props.onContextCreate(gl);\n }\n };\n\n componentWillUnmount(): void {\n if (this.exglCtxId) {\n unregisterGLContext(this.exglCtxId);\n }\n }\n\n componentDidUpdate(prevProps: GLViewProps): void {\n if (\n this.props.enableExperimentalWorkletSupport !== prevProps.enableExperimentalWorkletSupport\n ) {\n console.warn('Updating prop enableExperimentalWorkletSupport is not supported');\n }\n }\n\n // @docsMissing\n async createCameraTextureAsync(cameraRefOrHandle: ComponentOrHandle): Promise<WebGLTexture> {\n if (!GLNativeModule.createCameraTextureAsync) {\n throw new UnavailabilityError('expo-gl', 'createCameraTextureAsync');\n }\n\n const { exglCtxId } = this;\n\n if (!exglCtxId) {\n throw new Error(\"GLView's surface is not created yet!\");\n }\n\n const cameraTag = findNodeHandle(cameraRefOrHandle);\n const { exglObjId } = await GLNativeModule.createCameraTextureAsync(exglCtxId, cameraTag);\n return { id: exglObjId } as WebGLTexture;\n }\n\n // @docsMissing\n async destroyObjectAsync(glObject: WebGLObject): Promise<boolean> {\n if (!GLNativeModule.destroyObjectAsync) {\n throw new UnavailabilityError('expo-gl', 'destroyObjectAsync');\n }\n return await GLNativeModule.destroyObjectAsync(glObject.id);\n }\n\n /**\n * Same as static [`takeSnapshotAsync()`](#takesnapshotasyncoptions),\n * but uses WebGL context that is associated with the view on which the method is called.\n * @param options\n */\n async takeSnapshotAsync(options: SnapshotOptions = {}): Promise<GLSnapshot> {\n if (!GLView.takeSnapshotAsync) {\n throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');\n }\n const { exglCtxId } = this;\n return await GLView.takeSnapshotAsync(exglCtxId, options);\n }\n}\n\nGLView.NativeView = NativeView;\n\nfunction unregisterGLContext(exglCtxId: number) {\n if (global.__EXGLContexts) {\n delete global.__EXGLContexts[String(exglCtxId)];\n }\n workletContextManager.unregister?.(exglCtxId);\n}\n\n// Get the GL interface from an EXGLContextId\nconst getGl = (exglCtxId: number): ExpoWebGLRenderingContext => {\n if (!global.__EXGLContexts) {\n throw new CodedError(\n 'ERR_GL_NOT_AVAILABLE',\n 'GL is currently not available. (Have you enabled remote debugging? GL is not available while debugging remotely.)'\n );\n }\n const gl = global.__EXGLContexts[String(exglCtxId)];\n\n configureLogging(gl);\n\n return gl;\n};\n\nconst getContextId = (exgl?: ExpoWebGLRenderingContext | number): number => {\n const exglCtxId = exgl && typeof exgl === 'object' ? exgl.contextId : exgl;\n\n if (!exglCtxId || typeof exglCtxId !== 'number') {\n throw new Error(`Invalid EXGLContext id: ${String(exglCtxId)}`);\n }\n return exglCtxId;\n};\n"]}
|