expo-gl 16.0.8-canary-20251127-587bc53 → 16.0.8
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 +2 -8
- 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/{GLModule.kt → GLObjectManagerModule.kt} +3 -10
- package/android/src/main/java/expo/modules/gl/GLView.kt +1 -1
- package/android/src/main/java/expo/modules/gl/GLViewModule.kt +17 -0
- package/build/GLView.d.ts +1 -0
- package/build/GLView.d.ts.map +1 -1
- package/build/GLView.js +18 -10
- package/build/GLView.js.map +1 -1
- package/common/EXGLImageUtils.cpp +0 -3
- package/common/stb_image.h +5981 -6674
- package/expo-module.config.json +3 -3
- package/ios/EXGLContext.mm +4 -2
- package/ios/EXGLObjectManager.h +8 -21
- package/ios/EXGLObjectManager.mm +76 -32
- package/ios/GLViewModule.swift +20 -0
- 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 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8-sources.jar.sha512 +1 -0
- 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 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.module +87 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/{16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.pom → 16.0.8/expo.modules.gl-16.0.8.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8/expo.modules.gl-16.0.8.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 +6 -5
- package/src/GLView.tsx +23 -9
- package/ios/ExpoGLModule.swift +0 -76
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.module +0 -87
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.8-canary-20251127-587bc53/expo.modules.gl-16.0.8-canary-20251127-587bc53.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,15 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
- [android] rename module to align with iOS ([#41193](https://github.com/expo/expo/pull/41193) by [@Ubax](https://github.com/Ubax))
|
|
13
|
+
## 16.0.8 — 2025-12-05
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
### ⚠️ Notices
|
|
18
|
-
|
|
19
|
-
- **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))
|
|
20
|
-
- 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))
|
|
21
|
-
- Added support for React Native 0.82.x. ([#39678](https://github.com/expo/expo/pull/39678) by [@gabrieldonadel](https://github.com/gabrieldonadel))
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
22
16
|
|
|
23
17
|
## 16.0.7 — 2025-09-11
|
|
24
18
|
|
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.8
|
|
12
|
+
version = '16.0.8'
|
|
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.8
|
|
25
|
+
versionName "16.0.8"
|
|
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 GLObjectManagerModule 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(GLObjectManagerModule 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 GLObjectManagerModule : 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("ExponentGLObjectManager")
|
|
26
26
|
|
|
27
27
|
AsyncFunction("destroyObjectAsync") { exglObjId: Int ->
|
|
28
28
|
val glObject = mGLObjects[exglObjId]
|
|
@@ -61,7 +61,7 @@ class GLModule : Module() {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
AsyncFunction("createContextAsync") { promise: Promise ->
|
|
64
|
-
val glContext = GLContext(this@
|
|
64
|
+
val glContext = GLContext(this@GLObjectManagerModule)
|
|
65
65
|
glContext.initialize(null, false) {
|
|
66
66
|
val results = Bundle()
|
|
67
67
|
results.putInt("exglCtxId", glContext.contextId)
|
|
@@ -76,13 +76,6 @@ class GLModule : 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
|
-
}
|
|
86
79
|
}
|
|
87
80
|
|
|
88
81
|
private fun getContextWithId(exglCtxId: Int): GLContext? {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package expo.modules.gl
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
|
|
6
|
+
class GLViewModule : Module() {
|
|
7
|
+
override fun definition() = ModuleDefinition {
|
|
8
|
+
Name("ExponentGLView")
|
|
9
|
+
|
|
10
|
+
View(GLView::class) {
|
|
11
|
+
Events("onSurfaceCreate")
|
|
12
|
+
Prop("enableExperimentalWorkletSupport") { view: GLView, enableExperimentalWorkletSupport: Boolean? ->
|
|
13
|
+
view.enableExperimentalWorkletSupport = enableExperimentalWorkletSupport ?: false
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
package/build/GLView.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ 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>;
|
|
51
52
|
createCameraTextureAsync(cameraRefOrHandle: ComponentOrHandle): Promise<WebGLTexture>;
|
|
52
53
|
destroyObjectAsync(glObject: WebGLObject): Promise<boolean>;
|
|
53
54
|
/**
|
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":"AAOA,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;AAUF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,yBAAyB,G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odedError, } from 'expo-modules-core';
|
|
1
|
+
import { NativeModulesProxy, 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
|
|
6
|
+
const ExponentGLObjectManager = requireNativeModule('ExponentGLObjectManager');
|
|
7
|
+
const { ExponentGLViewManager } = NativeModulesProxy;
|
|
8
|
+
const NativeView = requireNativeViewManager('ExponentGLView');
|
|
8
9
|
const workletContextManager = createWorkletContextManager();
|
|
9
10
|
export function getWorkletContext(contextId) {
|
|
10
11
|
'worklet';
|
|
@@ -30,7 +31,7 @@ export class GLView extends React.Component {
|
|
|
30
31
|
* @return A promise that resolves to WebGL context object. See [WebGL API](#webgl-api) for more details.
|
|
31
32
|
*/
|
|
32
33
|
static async createContextAsync() {
|
|
33
|
-
const { exglCtxId } = await
|
|
34
|
+
const { exglCtxId } = await ExponentGLObjectManager.createContextAsync();
|
|
34
35
|
return getGl(exglCtxId);
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
@@ -41,7 +42,7 @@ export class GLView extends React.Component {
|
|
|
41
42
|
static async destroyContextAsync(exgl) {
|
|
42
43
|
const exglCtxId = getContextId(exgl);
|
|
43
44
|
unregisterGLContext(exglCtxId);
|
|
44
|
-
return
|
|
45
|
+
return ExponentGLObjectManager.destroyContextAsync(exglCtxId);
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* Takes a snapshot of the framebuffer and saves it as a file to app's cache directory.
|
|
@@ -51,7 +52,7 @@ export class GLView extends React.Component {
|
|
|
51
52
|
*/
|
|
52
53
|
static async takeSnapshotAsync(exgl, options = {}) {
|
|
53
54
|
const exglCtxId = getContextId(exgl);
|
|
54
|
-
return
|
|
55
|
+
return ExponentGLObjectManager.takeSnapshotAsync(exglCtxId, options);
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
58
|
* This method doesn't work inside of the worklets with new reanimated versions.
|
|
@@ -97,8 +98,15 @@ export class GLView extends React.Component {
|
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
// @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
|
|
100
108
|
async createCameraTextureAsync(cameraRefOrHandle) {
|
|
101
|
-
if (!
|
|
109
|
+
if (!ExponentGLObjectManager.createCameraTextureAsync) {
|
|
102
110
|
throw new UnavailabilityError('expo-gl', 'createCameraTextureAsync');
|
|
103
111
|
}
|
|
104
112
|
const { exglCtxId } = this;
|
|
@@ -106,15 +114,15 @@ export class GLView extends React.Component {
|
|
|
106
114
|
throw new Error("GLView's surface is not created yet!");
|
|
107
115
|
}
|
|
108
116
|
const cameraTag = findNodeHandle(cameraRefOrHandle);
|
|
109
|
-
const { exglObjId } = await
|
|
117
|
+
const { exglObjId } = await ExponentGLObjectManager.createCameraTextureAsync(exglCtxId, cameraTag);
|
|
110
118
|
return { id: exglObjId };
|
|
111
119
|
}
|
|
112
120
|
// @docsMissing
|
|
113
121
|
async destroyObjectAsync(glObject) {
|
|
114
|
-
if (!
|
|
122
|
+
if (!ExponentGLObjectManager.destroyObjectAsync) {
|
|
115
123
|
throw new UnavailabilityError('expo-gl', 'destroyObjectAsync');
|
|
116
124
|
}
|
|
117
|
-
return await
|
|
125
|
+
return await ExponentGLObjectManager.destroyObjectAsync(glObject.id);
|
|
118
126
|
}
|
|
119
127
|
/**
|
|
120
128
|
* Same as static [`takeSnapshotAsync()`](#takesnapshotasyncoptions),
|
package/build/GLView.js.map
CHANGED
|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C,CAAC;IAErB,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,IAAyC,EAAU,EAAE;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 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 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"]}
|
|
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,mBAAmB,CAAC,yBAAyB,CAAC,CAAC;AAC/E,MAAM,EAAE,qBAAqB,EAAE,GAAG,kBAAkB,CAAC;AAErD,MAAM,UAAU,GAAG,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;AAC9D,MAAM,qBAAqB,GAAG,2BAA2B,EAAE,CAAC;AAE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AAC;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"]}
|