expo-gl 16.0.9-canary-20251206-615dec1 → 16.0.9
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 +9 -6
- package/README.md +1 -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/{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/Canvas.js +3 -3
- package/build/Canvas.js.map +1 -1
- 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/build/GLView.web.d.ts +0 -1
- package/build/GLView.web.d.ts.map +1 -1
- package/build/GLView.web.js +0 -3
- package/build/GLView.web.js.map +1 -1
- package/common/EXGLImageUtils.cpp +0 -1
- 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.9/expo.modules.gl-16.0.9-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.module +87 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/{16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.pom → 16.0.9/expo.modules.gl-16.0.9.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9/expo.modules.gl-16.0.9.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/Canvas.tsx +3 -3
- package/src/GLView.tsx +23 -9
- package/src/GLView.web.tsx +0 -4
- package/ios/ExpoGLModule.swift +0 -76
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.module +0 -87
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.gl/16.0.9-canary-20251206-615dec1/expo.modules.gl-16.0.9-canary-20251206-615dec1.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,16 +10,19 @@
|
|
|
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.9 — 2025-12-11
|
|
15
14
|
|
|
16
|
-
###
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fix race condition bug for **web** env for `onLayout` callback. ([#41460](https://github.com/expo/expo/pull/41460) by [@psnet](https://github.com/psnet))
|
|
18
|
+
|
|
19
|
+
### 💡 Others
|
|
17
20
|
|
|
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
21
|
- 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
|
-
-
|
|
22
|
+
- **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))
|
|
23
|
+
- **Performance optimization**: remove support of **GIF** image format in image decoding in `texImage2D` expo wrapper. ([#41499](https://github.com/expo/expo/pull/41499) by [@psnet](https://github.com/psnet))
|
|
21
24
|
|
|
22
|
-
## 16.0.8
|
|
25
|
+
## 16.0.8 — 2025-12-05
|
|
23
26
|
|
|
24
27
|
_This version does not introduce any user-facing changes._
|
|
25
28
|
|
package/README.md
CHANGED
|
@@ -55,4 +55,4 @@ Run `npx pod-install` after installing the npm package.
|
|
|
55
55
|
|
|
56
56
|
# Contributing
|
|
57
57
|
|
|
58
|
-
Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo
|
|
58
|
+
Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md).
|
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.9
|
|
12
|
+
version = '16.0.9'
|
|
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.9
|
|
25
|
+
versionName "16.0.9"
|
|
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/Canvas.js
CHANGED
|
@@ -46,9 +46,9 @@ const CanvasWrapper = ({ pointerEvents, children, style, ...props }) => {
|
|
|
46
46
|
const { nativeEvent: { layout: { width, height }, }, } = event;
|
|
47
47
|
if (width !== size?.width || height !== size?.height) {
|
|
48
48
|
setSize({ width, height });
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
}
|
|
50
|
+
if (props.onLayout) {
|
|
51
|
+
props.onLayout(event);
|
|
52
52
|
}
|
|
53
53
|
}, [size?.width, size?.height, props.onLayout]);
|
|
54
54
|
React.useEffect(() => {
|
package/build/Canvas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Canvas.js","sourceRoot":"","sources":["../src/Canvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAqB,UAAU,EAAE,UAAU,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;AAC1F,OAAO,aAAa,MAAM,6CAA6C,CAAC;AAYxE,SAAS,MAAM,CAAI,OAAqB,EAAE,GAAa;IACrD,IAAI,CAAC,OAAO;QAAE,OAAO;IAErB,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;SAAM,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;QAChC,aAAa;QACb,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC;IACxB,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAiB;IAC3C,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QACzD,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACjC,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,CAAC,OAAiC,CAAC;IACtD,MAAM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,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAC5E;MAAA,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC,EAC7E;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE;QACP,aAAa,EAAE,UAAU;KAC1B;CACF,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC","sourcesContent":["import * as React from 'react';\nimport { LayoutChangeEvent, PixelRatio, StyleSheet, View, ViewProps } from 'react-native';\nimport createElement from 'react-native-web/dist/exports/createElement';\n\ninterface Size {\n width: number;\n height: number;\n}\n\ninterface GetSizeParams {\n size: Size | null;\n ref: React.RefObject<View | null>;\n}\n\nfunction setRef<T>(refProp: React.Ref<T>, ref: T | null) {\n if (!refProp) return;\n\n if (typeof refProp === 'function') {\n refProp(ref);\n } else if ('current' in refProp) {\n // @ts-ignore\n refProp.current = ref;\n }\n}\n\nfunction getSize({ size, ref }: GetSizeParams): Size {\n if (size) {\n return size;\n } else if (!ref.current || typeof window === 'undefined') {\n return { width: 0, height: 0 };\n }\n const element = ref.current as unknown as HTMLElement;\n const { offsetWidth: width = 0, offsetHeight: height = 0 } = element;\n return { width, height };\n}\n\nconst Canvas = (\n props: React.ComponentProps<typeof View> & {\n ref?: React.Ref<HTMLCanvasElement>;\n }\n) => createElement('canvas', props);\n\nconst CanvasWrapper: React.FunctionComponent<\n ViewProps & {\n canvasRef: React.Ref<HTMLCanvasElement>;\n }\n> = ({ pointerEvents, children, style, ...props }) => {\n const [size, setSize] = React.useState<Size | null>(null);\n\n const ref = React.useRef<View>(null);\n const _canvasRef = React.useRef<HTMLCanvasElement>(null);\n\n const updateCanvasSize = React.useCallback(() => {\n const canvas = _canvasRef.current;\n if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement) {\n const currentSize = getSize({\n size,\n ref,\n });\n const scale = PixelRatio.get();\n\n canvas.style.width = `${currentSize.width}px`;\n canvas.style.height = `${currentSize.height}px`;\n\n canvas.width = currentSize.width * scale;\n canvas.height = currentSize.height * scale;\n }\n }, [size?.width, size?.height]);\n\n const onLayout = React.useCallback(\n (event: LayoutChangeEvent) => {\n const {\n nativeEvent: {\n layout: { width, height },\n },\n } = event;\n\n if (width !== size?.width || height !== size?.height) {\n setSize({ width, height });\n }\n\n if (props.onLayout) {\n props.onLayout(event);\n }\n },\n [size?.width, size?.height, props.onLayout]\n );\n\n React.useEffect(() => {\n if (ref.current != null) {\n setSize(getSize({ size, ref }));\n }\n }, [ref]);\n\n React.useEffect(() => {\n updateCanvasSize();\n }, [size]);\n\n React.useEffect(() => {\n const canvas = _canvasRef.current;\n if (canvas) {\n updateCanvasSize();\n }\n setRef(props.canvasRef, canvas);\n }, [_canvasRef]);\n\n return (\n <View {...props} style={[styles.wrapper, style]} ref={ref} onLayout={onLayout}>\n <Canvas ref={_canvasRef} style={[StyleSheet.absoluteFill, { pointerEvents }]} />\n {children}\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n wrapper: {\n pointerEvents: 'box-none',\n },\n});\n\nexport default CanvasWrapper;\n"]}
|
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,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,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC;IAQnC,wBAAwB,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IAoBrF,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,10 +1,11 @@
|
|
|
1
|
-
import { UnavailabilityError, requireNativeModule, requireNativeViewManager, CodedError, } 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
|
@@ -1 +1 @@
|
|
|
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,UAAU,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAC;AACtD,MAAM,qB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EAAE,GAAG,IAAI,CAAC;QAC3B,OAAO,MAAM,MAAM,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;;AAGH,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;AAE/B,SAAS,mBAAmB,CAAC,SAAiB;IAC5C,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,qBAAqB,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,CAAC;AAChD,CAAC;AAED,6CAA6C;AAC7C,MAAM,KAAK,GAAG,CAAC,SAAiB,EAA6B,EAAE;IAC7D,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAC3B,MAAM,IAAI,UAAU,CAClB,sBAAsB,EACtB,mHAAmH,CACpH,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAEpD,gBAAgB,CAAC,EAAE,CAAC,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;AAE5D,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,SAAS,CAAC;IACV,OAAO,qBAAqB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AACrD,CAAC;AAED,cAAc;AACd;;;GAGG;AACH,MAAM,OAAO,MAAO,SAAQ,KAAK,CAAC,SAAsB;IACtD,MAAM,CAAC,UAAU,CAAM;IAEvB,MAAM,CAAC,YAAY,GAAG;QACpB,WAAW,EAAE,CAAC;QACd,gCAAgC,EAAE,KAAK;KACxC,CAAC;IAEF;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,CAAC,kBAAkB;QAC7B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,uBAAuB,CAAC,kBAAkB,EAAE,CAAC;QACzE,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAA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AAC,CAAC,CAAC;IAClD,CAAC;IACD,qBAAqB,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,CAAC;AAChD,CAAC;AAED,6CAA6C;AAC7C,MAAM,KAAK,GAAG,CAAC,SAAiB,EAA6B,EAAE;IAC7D,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAC3B,MAAM,IAAI,UAAU,CAClB,sBAAsB,EACtB,mHAAmH,CACpH,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAEpD,gBAAgB,CAAC,EAAE,CAAC,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 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"]}
|
package/build/GLView.web.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export declare class GLView extends React.Component<GLViewWebProps> {
|
|
|
23
23
|
private getGLContext;
|
|
24
24
|
private setCanvasRef;
|
|
25
25
|
takeSnapshotAsync(options?: SnapshotOptions): Promise<GLSnapshot>;
|
|
26
|
-
startARSessionAsync(): Promise<void>;
|
|
27
26
|
createCameraTextureAsync(): Promise<void>;
|
|
28
27
|
destroyObjectAsync(glObject: WebGLObject): Promise<void>;
|
|
29
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLView.web.d.ts","sourceRoot":"","sources":["../src/GLView.web.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,WAAW,EAEX,UAAU,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAiExB,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,eAAe,EAAE,CAAC,EAAE,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACrD,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACzD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAEhD,sBAAsB,CAAC,CAAC,QAAQ,EAAE,iBAAiB,GAAG,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAAC;CAC1F,CAAC;AA8BF,qBAAa,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;IACzD,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAE3B,EAAE,CAAC,EAAE,qBAAqB,CAAC;WAEd,kBAAkB,IAAI,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;WAW3D,mBAAmB,CAAC,IA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C;WAEd,kBAAkB,IAAI,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;WAW3D,mBAAmB,CAAC,IAAI,CAAC,EAAE,qBAAqB,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAK5E,iBAAiB,CAC5B,EAAE,EAAE,qBAAqB,EACzB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,UAAU,CAAC;IAetB,oBAAoB;IAcpB,MAAM;IAgBN,kBAAkB,CAAC,SAAS,EAAE,cAAc;IAQ5C,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,aAAa,CASnB;IAEF,OAAO,CAAC,iBAAiB,CAKvB;IAEF,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,YAAY,CAalB;IAEW,iBAAiB,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,UAAU,CAAC;IASrE,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzC,kBAAkB,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtE"}
|
package/build/GLView.web.js
CHANGED
|
@@ -175,9 +175,6 @@ export class GLView extends React.Component {
|
|
|
175
175
|
const gl = this.getGLContextOrReject();
|
|
176
176
|
return await GLView.takeSnapshotAsync(gl, options);
|
|
177
177
|
}
|
|
178
|
-
async startARSessionAsync() {
|
|
179
|
-
throw new UnavailabilityError('GLView', 'startARSessionAsync');
|
|
180
|
-
}
|
|
181
178
|
async createCameraTextureAsync() {
|
|
182
179
|
throw new UnavailabilityError('GLView', 'createCameraTextureAsync');
|
|
183
180
|
}
|
package/build/GLView.web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLView.web.js","sourceRoot":"","sources":["../src/GLView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,SAAS,MAAM,WAAW,CAAC;A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C;IAEM,KAAK,CAAC,wBAAwB;QACnC,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,QAAqB;QACnD,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["import { CodedError, Platform, UnavailabilityError } from 'expo-modules-core';\nimport invariant from 'invariant';\nimport * as React from 'react';\nimport { Dimensions } from 'react-native';\n\nimport Canvas from './Canvas';\nimport { WebGLObject } from './GLView';\nimport {\n GLViewProps,\n ExpoWebGLRenderingContext,\n GLSnapshot,\n SnapshotOptions,\n ComponentOrHandle,\n} from './GLView.types';\n\nfunction getImageForAsset(asset: {\n downloadAsync?: () => Promise<any>;\n uri?: string;\n localUri?: string;\n}): HTMLImageElement | any {\n if (asset != null && typeof asset === 'object' && asset.downloadAsync) {\n const dataURI = asset.localUri || asset.uri || '';\n const image = new Image();\n image.src = dataURI;\n return image;\n }\n return asset;\n}\n\nfunction isOffscreenCanvas(element: any): element is OffscreenCanvas {\n return element && typeof element.convertToBlob === 'function';\n}\n\nfunction asExpoContext(gl: ExpoWebGLRenderingContext): WebGLRenderingContext {\n gl.endFrameEXP = function glEndFrameEXP(): void {};\n\n if (!gl['_expo_texImage2D']) {\n gl['_expo_texImage2D'] = gl.texImage2D;\n gl.texImage2D = (...props: any[]): any => {\n const nextProps = [...props];\n nextProps.push(getImageForAsset(nextProps.pop()));\n return gl['_expo_texImage2D']!(...nextProps);\n };\n }\n\n if (!gl['_expo_texSubImage2D']) {\n gl['_expo_texSubImage2D'] = gl.texSubImage2D;\n gl.texSubImage2D = (...props: any[]): any => {\n const nextProps = [...props];\n nextProps.push(getImageForAsset(nextProps.pop()));\n return gl['_expo_texSubImage2D']!(...nextProps);\n };\n }\n\n return gl;\n}\n\nfunction ensureContext(\n canvas?: HTMLCanvasElement,\n contextAttributes?: WebGLContextAttributes\n): WebGLRenderingContext {\n if (!canvas) {\n throw new CodedError(\n 'ERR_GL_INVALID',\n 'Attempting to use the GL context before it has been created.'\n );\n }\n\n const context =\n canvas.getContext('webgl2', contextAttributes) ||\n canvas.getContext('webgl', contextAttributes) ||\n canvas.getContext('webgl-experimental', contextAttributes) ||\n canvas.getContext('experimental-webgl', contextAttributes);\n invariant(context, 'Browser does not support WebGL');\n return asExpoContext(context as ExpoWebGLRenderingContext);\n}\n\n// @needsAudit @docsMissing\nexport type GLViewWebProps = GLViewProps & {\n onContextCreate: (gl: WebGLRenderingContext) => void;\n onContextRestored?: (gl?: WebGLRenderingContext) => void;\n onContextLost?: () => void;\n webglContextAttributes?: WebGLContextAttributes;\n // type overwrite\n nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | HTMLCanvasElement | null): unknown;\n};\n\nasync function getBlobFromWebGLRenderingContext(\n gl: WebGLRenderingContext,\n options: SnapshotOptions = {}\n): Promise<{ width: number; height: number; blob: Blob | null }> {\n invariant(gl, 'getBlobFromWebGLRenderingContext(): WebGL Rendering Context is not defined');\n\n const { canvas } = gl;\n\n let blob: Blob | null = null;\n\n if (typeof (canvas as any).msToBlob === 'function') {\n // @ts-ignore: polyfill: https://stackoverflow.com/a/29815058/4047926\n blob = await canvas.msToBlob();\n } else if (isOffscreenCanvas(canvas)) {\n blob = await canvas.convertToBlob({ quality: options.compress, type: options.format });\n } else {\n blob = await new Promise((resolve) => {\n canvas.toBlob((blob: Blob | null) => resolve(blob), options.format, options.compress);\n });\n }\n\n return {\n blob,\n width: canvas.width,\n height: canvas.height,\n };\n}\n\nexport class GLView extends React.Component<GLViewWebProps> {\n canvas?: HTMLCanvasElement;\n\n gl?: WebGLRenderingContext;\n\n static async createContextAsync(): Promise<WebGLRenderingContext | null> {\n if (!Platform.isDOMAvailable) {\n return null;\n }\n const canvas = document.createElement('canvas');\n const { width, height, scale } = Dimensions.get('window');\n canvas.width = width * scale;\n canvas.height = height * scale;\n return ensureContext(canvas);\n }\n\n static async destroyContextAsync(exgl?: WebGLRenderingContext | number): Promise<boolean> {\n // Do nothing\n return true;\n }\n\n static async takeSnapshotAsync(\n gl: WebGLRenderingContext,\n options: SnapshotOptions = {}\n ): Promise<GLSnapshot> {\n const { blob, width, height } = await getBlobFromWebGLRenderingContext(gl, options);\n\n if (!blob) {\n throw new CodedError('ERR_GL_SNAPSHOT', 'Failed to save the GL context');\n }\n\n return {\n uri: blob,\n localUri: '',\n width,\n height,\n };\n }\n\n componentWillUnmount() {\n if (this.gl) {\n const loseContextExt = this.gl.getExtension('WEBGL_lose_context');\n if (loseContextExt) {\n loseContextExt.loseContext();\n }\n this.gl = undefined;\n }\n if (this.canvas) {\n this.canvas.removeEventListener('webglcontextlost', this.onContextLost);\n this.canvas.removeEventListener('webglcontextrestored', this.onContextRestored);\n }\n }\n\n render() {\n const {\n onContextCreate,\n onContextRestored,\n onContextLost,\n webglContextAttributes,\n msaaSamples,\n nativeRef_EXPERIMENTAL,\n // @ts-ignore: ref does not exist\n ref,\n ...domProps\n } = this.props;\n\n return <Canvas {...domProps} canvasRef={this.setCanvasRef} />;\n }\n\n componentDidUpdate(prevProps: GLViewWebProps) {\n const { webglContextAttributes } = this.props;\n if (this.canvas && webglContextAttributes !== prevProps.webglContextAttributes) {\n this.onContextLost(null);\n this.onContextRestored();\n }\n }\n\n private getGLContextOrReject(): WebGLRenderingContext {\n const gl = this.getGLContext();\n if (!gl) {\n throw new CodedError(\n 'ERR_GL_INVALID',\n 'Attempting to use the GL context before it has been created.'\n );\n }\n return gl;\n }\n\n private onContextLost = (event: Event | null): void => {\n if (event && event.preventDefault) {\n event.preventDefault();\n }\n this.gl = undefined;\n\n if (typeof this.props.onContextLost === 'function') {\n this.props.onContextLost();\n }\n };\n\n private onContextRestored = (): void => {\n this.gl = undefined;\n if (this.getGLContext() == null) {\n throw new CodedError('ERR_GL_INVALID', 'Failed to restore GL context.');\n }\n };\n\n private getGLContext(): WebGLRenderingContext | null {\n if (this.gl) return this.gl;\n\n if (this.canvas) {\n this.gl = ensureContext(this.canvas, this.props.webglContextAttributes);\n if (typeof this.props.onContextCreate === 'function') {\n this.props.onContextCreate(this.gl);\n }\n return this.gl;\n }\n return null;\n }\n\n private setCanvasRef = (canvas: HTMLCanvasElement): void => {\n this.canvas = canvas;\n\n if (typeof this.props.nativeRef_EXPERIMENTAL === 'function') {\n this.props.nativeRef_EXPERIMENTAL(canvas);\n }\n\n if (this.canvas) {\n this.canvas.addEventListener('webglcontextlost', this.onContextLost);\n this.canvas.addEventListener('webglcontextrestored', this.onContextRestored);\n\n this.getGLContext();\n }\n };\n\n public async takeSnapshotAsync(options: SnapshotOptions = {}): Promise<GLSnapshot> {\n if (!GLView.takeSnapshotAsync) {\n throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');\n }\n\n const gl = this.getGLContextOrReject();\n return await GLView.takeSnapshotAsync(gl, options);\n }\n\n public async startARSessionAsync(): Promise<void> {\n throw new UnavailabilityError('GLView', 'startARSessionAsync');\n }\n\n public async createCameraTextureAsync(): Promise<void> {\n throw new UnavailabilityError('GLView', 'createCameraTextureAsync');\n }\n\n public async destroyObjectAsync(glObject: WebGLObject): Promise<void> {\n throw new UnavailabilityError('GLView', 'destroyObjectAsync');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GLView.web.js","sourceRoot":"","sources":["../src/GLView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,MAAM,MAAM,UAAU,CAAC;AAU9B,SAAS,gBAAgB,CAAC,KAIzB;IACC,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;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AO,IAAI,CAAC;IACd,CAAC;IAEO,YAAY,GAAG,CAAC,MAAyB,EAAQ,EAAE;QACzD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB,KAAK,UAAU,EAAE,CAAC;YAC5D,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YACrE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,sBAAsB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAE7E,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IAEK,KAAK,CAAC,iBAAiB,CAAC,UAA2B,EAAE;QAC1D,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;YAC9B,MAAM,IAAI,mBAAmB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,EAAE,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACvC,OAAO,MAAM,MAAM,CAAC,iBAAiB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,wBAAwB;QACnC,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,QAAqB;QACnD,MAAM,IAAI,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["import { CodedError, Platform, UnavailabilityError } from 'expo-modules-core';\nimport invariant from 'invariant';\nimport * as React from 'react';\nimport { Dimensions } from 'react-native';\n\nimport Canvas from './Canvas';\nimport { WebGLObject } from './GLView';\nimport {\n GLViewProps,\n ExpoWebGLRenderingContext,\n GLSnapshot,\n SnapshotOptions,\n ComponentOrHandle,\n} from './GLView.types';\n\nfunction getImageForAsset(asset: {\n downloadAsync?: () => Promise<any>;\n uri?: string;\n localUri?: string;\n}): HTMLImageElement | any {\n if (asset != null && typeof asset === 'object' && asset.downloadAsync) {\n const dataURI = asset.localUri || asset.uri || '';\n const image = new Image();\n image.src = dataURI;\n return image;\n }\n return asset;\n}\n\nfunction isOffscreenCanvas(element: any): element is OffscreenCanvas {\n return element && typeof element.convertToBlob === 'function';\n}\n\nfunction asExpoContext(gl: ExpoWebGLRenderingContext): WebGLRenderingContext {\n gl.endFrameEXP = function glEndFrameEXP(): void {};\n\n if (!gl['_expo_texImage2D']) {\n gl['_expo_texImage2D'] = gl.texImage2D;\n gl.texImage2D = (...props: any[]): any => {\n const nextProps = [...props];\n nextProps.push(getImageForAsset(nextProps.pop()));\n return gl['_expo_texImage2D']!(...nextProps);\n };\n }\n\n if (!gl['_expo_texSubImage2D']) {\n gl['_expo_texSubImage2D'] = gl.texSubImage2D;\n gl.texSubImage2D = (...props: any[]): any => {\n const nextProps = [...props];\n nextProps.push(getImageForAsset(nextProps.pop()));\n return gl['_expo_texSubImage2D']!(...nextProps);\n };\n }\n\n return gl;\n}\n\nfunction ensureContext(\n canvas?: HTMLCanvasElement,\n contextAttributes?: WebGLContextAttributes\n): WebGLRenderingContext {\n if (!canvas) {\n throw new CodedError(\n 'ERR_GL_INVALID',\n 'Attempting to use the GL context before it has been created.'\n );\n }\n\n const context =\n canvas.getContext('webgl2', contextAttributes) ||\n canvas.getContext('webgl', contextAttributes) ||\n canvas.getContext('webgl-experimental', contextAttributes) ||\n canvas.getContext('experimental-webgl', contextAttributes);\n invariant(context, 'Browser does not support WebGL');\n return asExpoContext(context as ExpoWebGLRenderingContext);\n}\n\n// @needsAudit @docsMissing\nexport type GLViewWebProps = GLViewProps & {\n onContextCreate: (gl: WebGLRenderingContext) => void;\n onContextRestored?: (gl?: WebGLRenderingContext) => void;\n onContextLost?: () => void;\n webglContextAttributes?: WebGLContextAttributes;\n // type overwrite\n nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | HTMLCanvasElement | null): unknown;\n};\n\nasync function getBlobFromWebGLRenderingContext(\n gl: WebGLRenderingContext,\n options: SnapshotOptions = {}\n): Promise<{ width: number; height: number; blob: Blob | null }> {\n invariant(gl, 'getBlobFromWebGLRenderingContext(): WebGL Rendering Context is not defined');\n\n const { canvas } = gl;\n\n let blob: Blob | null = null;\n\n if (typeof (canvas as any).msToBlob === 'function') {\n // @ts-ignore: polyfill: https://stackoverflow.com/a/29815058/4047926\n blob = await canvas.msToBlob();\n } else if (isOffscreenCanvas(canvas)) {\n blob = await canvas.convertToBlob({ quality: options.compress, type: options.format });\n } else {\n blob = await new Promise((resolve) => {\n canvas.toBlob((blob: Blob | null) => resolve(blob), options.format, options.compress);\n });\n }\n\n return {\n blob,\n width: canvas.width,\n height: canvas.height,\n };\n}\n\nexport class GLView extends React.Component<GLViewWebProps> {\n canvas?: HTMLCanvasElement;\n\n gl?: WebGLRenderingContext;\n\n static async createContextAsync(): Promise<WebGLRenderingContext | null> {\n if (!Platform.isDOMAvailable) {\n return null;\n }\n const canvas = document.createElement('canvas');\n const { width, height, scale } = Dimensions.get('window');\n canvas.width = width * scale;\n canvas.height = height * scale;\n return ensureContext(canvas);\n }\n\n static async destroyContextAsync(exgl?: WebGLRenderingContext | number): Promise<boolean> {\n // Do nothing\n return true;\n }\n\n static async takeSnapshotAsync(\n gl: WebGLRenderingContext,\n options: SnapshotOptions = {}\n ): Promise<GLSnapshot> {\n const { blob, width, height } = await getBlobFromWebGLRenderingContext(gl, options);\n\n if (!blob) {\n throw new CodedError('ERR_GL_SNAPSHOT', 'Failed to save the GL context');\n }\n\n return {\n uri: blob,\n localUri: '',\n width,\n height,\n };\n }\n\n componentWillUnmount() {\n if (this.gl) {\n const loseContextExt = this.gl.getExtension('WEBGL_lose_context');\n if (loseContextExt) {\n loseContextExt.loseContext();\n }\n this.gl = undefined;\n }\n if (this.canvas) {\n this.canvas.removeEventListener('webglcontextlost', this.onContextLost);\n this.canvas.removeEventListener('webglcontextrestored', this.onContextRestored);\n }\n }\n\n render() {\n const {\n onContextCreate,\n onContextRestored,\n onContextLost,\n webglContextAttributes,\n msaaSamples,\n nativeRef_EXPERIMENTAL,\n // @ts-ignore: ref does not exist\n ref,\n ...domProps\n } = this.props;\n\n return <Canvas {...domProps} canvasRef={this.setCanvasRef} />;\n }\n\n componentDidUpdate(prevProps: GLViewWebProps) {\n const { webglContextAttributes } = this.props;\n if (this.canvas && webglContextAttributes !== prevProps.webglContextAttributes) {\n this.onContextLost(null);\n this.onContextRestored();\n }\n }\n\n private getGLContextOrReject(): WebGLRenderingContext {\n const gl = this.getGLContext();\n if (!gl) {\n throw new CodedError(\n 'ERR_GL_INVALID',\n 'Attempting to use the GL context before it has been created.'\n );\n }\n return gl;\n }\n\n private onContextLost = (event: Event | null): void => {\n if (event && event.preventDefault) {\n event.preventDefault();\n }\n this.gl = undefined;\n\n if (typeof this.props.onContextLost === 'function') {\n this.props.onContextLost();\n }\n };\n\n private onContextRestored = (): void => {\n this.gl = undefined;\n if (this.getGLContext() == null) {\n throw new CodedError('ERR_GL_INVALID', 'Failed to restore GL context.');\n }\n };\n\n private getGLContext(): WebGLRenderingContext | null {\n if (this.gl) return this.gl;\n\n if (this.canvas) {\n this.gl = ensureContext(this.canvas, this.props.webglContextAttributes);\n if (typeof this.props.onContextCreate === 'function') {\n this.props.onContextCreate(this.gl);\n }\n return this.gl;\n }\n return null;\n }\n\n private setCanvasRef = (canvas: HTMLCanvasElement): void => {\n this.canvas = canvas;\n\n if (typeof this.props.nativeRef_EXPERIMENTAL === 'function') {\n this.props.nativeRef_EXPERIMENTAL(canvas);\n }\n\n if (this.canvas) {\n this.canvas.addEventListener('webglcontextlost', this.onContextLost);\n this.canvas.addEventListener('webglcontextrestored', this.onContextRestored);\n\n this.getGLContext();\n }\n };\n\n public async takeSnapshotAsync(options: SnapshotOptions = {}): Promise<GLSnapshot> {\n if (!GLView.takeSnapshotAsync) {\n throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');\n }\n\n const gl = this.getGLContextOrReject();\n return await GLView.takeSnapshotAsync(gl, options);\n }\n\n public async createCameraTextureAsync(): Promise<void> {\n throw new UnavailabilityError('GLView', 'createCameraTextureAsync');\n }\n\n public async destroyObjectAsync(glObject: WebGLObject): Promise<void> {\n throw new UnavailabilityError('GLView', 'destroyObjectAsync');\n }\n}\n"]}
|
package/expo-module.config.json
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"platforms": ["apple", "android"],
|
|
3
3
|
"apple": {
|
|
4
4
|
"podspecPath": "./ExpoGL.podspec",
|
|
5
|
-
"modules": ["
|
|
5
|
+
"modules": ["GLViewModule"]
|
|
6
6
|
},
|
|
7
7
|
"android": {
|
|
8
|
-
"modules": ["expo.modules.gl.
|
|
8
|
+
"modules": ["expo.modules.gl.GLViewModule", "expo.modules.gl.GLObjectManagerModule"],
|
|
9
9
|
"publication": {
|
|
10
10
|
"groupId": "host.exp.exponent",
|
|
11
11
|
"artifactId": "expo.modules.gl",
|
|
12
|
-
"version": "16.0.9
|
|
12
|
+
"version": "16.0.9",
|
|
13
13
|
"repository": "local-maven-repo"
|
|
14
14
|
}
|
|
15
15
|
}
|
package/ios/EXGLContext.mm
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
@property (nonatomic, strong) dispatch_queue_t glQueue;
|
|
19
19
|
@property (nonatomic, weak) EXModuleRegistry *moduleRegistry;
|
|
20
|
+
@property (nonatomic, weak) EXGLObjectManager *objectManager;
|
|
20
21
|
@property (nonatomic, assign) BOOL isContextReady;
|
|
21
22
|
@property (nonatomic, assign) BOOL wasPrepareCalled;
|
|
22
23
|
@property (nonatomic) BOOL appIsBackgrounded;
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
self.delegate = delegate;
|
|
33
34
|
|
|
34
35
|
_moduleRegistry = moduleRegistry;
|
|
36
|
+
_objectManager = (EXGLObjectManager *)[_moduleRegistry getExportedModuleOfClass:[EXGLObjectManager class]];
|
|
35
37
|
_glQueue = dispatch_queue_create("host.exp.gl", DISPATCH_QUEUE_SERIAL);
|
|
36
38
|
_eaglCtx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3] ?: [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
|
37
39
|
_isContextReady = NO;
|
|
@@ -73,7 +75,7 @@
|
|
|
73
75
|
- (void)initialize
|
|
74
76
|
{
|
|
75
77
|
self->_contextId = EXGLContextCreate();
|
|
76
|
-
[
|
|
78
|
+
[self->_objectManager saveContext:self];
|
|
77
79
|
|
|
78
80
|
// listen for foreground/background transitions
|
|
79
81
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
@@ -180,7 +182,7 @@
|
|
|
180
182
|
EXGLContextDestroy(self->_contextId);
|
|
181
183
|
|
|
182
184
|
// Remove from dictionary of contexts
|
|
183
|
-
[
|
|
185
|
+
[self->_objectManager deleteContextWithId:@(self->_contextId)];
|
|
184
186
|
}];
|
|
185
187
|
}];
|
|
186
188
|
}
|
package/ios/EXGLObjectManager.h
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
// Copyright 2016-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
|
-
#import <ExpoModulesCore/
|
|
3
|
+
#import <ExpoModulesCore/EXExportedModule.h>
|
|
4
|
+
#import <ExpoModulesCore/EXModuleRegistryConsumer.h>
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
#import <ExpoModulesCore/EXUIManager.h>
|
|
7
|
+
#import <ExpoModulesCore/EXFileSystemInterface.h>
|
|
6
8
|
|
|
7
|
-
@
|
|
9
|
+
@interface EXGLObjectManager : EXExportedModule <EXModuleRegistryConsumer>
|
|
10
|
+
|
|
11
|
+
@property (nonatomic, weak, nullable) id<EXUIManager> uiManager;
|
|
12
|
+
@property (nonatomic, weak, nullable) id<EXFileSystemInterface> fileSystem;
|
|
8
13
|
|
|
9
14
|
- (void)saveContext:(nonnull id)glContext;
|
|
10
15
|
- (void)deleteContextWithId:(nonnull NSNumber *)contextId;
|
|
11
16
|
|
|
12
|
-
- (void)takeSnapshotWithContextId:(nonnull NSNumber *)exglCtxId
|
|
13
|
-
andOptions:(nonnull NSDictionary *)options
|
|
14
|
-
resolver:(nonnull EXPromiseResolveBlock)resolve
|
|
15
|
-
rejecter:(nonnull EXPromiseRejectBlock)reject;
|
|
16
|
-
|
|
17
|
-
- (void)destroyContextWithId:(nonnull NSNumber *)exglCtxId
|
|
18
|
-
resolve:(nonnull EXPromiseResolveBlock)resolve
|
|
19
|
-
reject:(nonnull EXPromiseRejectBlock)reject;
|
|
20
|
-
|
|
21
|
-
- (void)destroyObjectAsync:(nonnull NSNumber *)exglObjId
|
|
22
|
-
resolve:(nonnull EXPromiseResolveBlock)resolve
|
|
23
|
-
reject:(nonnull EXPromiseRejectBlock)reject;
|
|
24
|
-
|
|
25
|
-
- (void)createTextureForContextWithId:(nonnull NSNumber *)exglCtxId
|
|
26
|
-
cameraView:(nonnull id<EXCameraInterface>)cameraView
|
|
27
|
-
resolver:(nonnull EXPromiseResolveBlock)resolve
|
|
28
|
-
rejecter:(nonnull EXPromiseRejectBlock)reject;
|
|
29
|
-
|
|
30
17
|
@end
|