expo-gl 12.2.0 → 12.3.1
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 +14 -0
- package/README.md +8 -1
- package/android/build.gradle +5 -5
- package/android/src/main/java/expo/modules/gl/GLPackage.java +0 -6
- package/android/src/main/java/expo/modules/gl/GLView.kt +85 -0
- package/android/src/main/java/expo/modules/gl/GLViewModule.kt +14 -0
- package/expo-module.config.json +3 -0
- package/package.json +3 -3
- package/android/src/main/java/expo/modules/gl/GLView.java +0 -117
- package/android/src/main/java/expo/modules/gl/GLViewManager.java +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 12.3.1 — 2023-02-09
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 12.3.0 — 2023-02-03
|
|
18
|
+
|
|
19
|
+
### 🎉 New features
|
|
20
|
+
|
|
21
|
+
- Migrated the view manager to the new Expo modules API and thus added support for Fabric on Android. ([#20749](https://github.com/expo/expo/pull/20749) by [@lukmccall](https://github.com/lukmccall))
|
|
22
|
+
|
|
23
|
+
### 💡 Others
|
|
24
|
+
|
|
25
|
+
- On Android bump `compileSdkVersion` and `targetSdkVersion` to `33`. ([#20721](https://github.com/expo/expo/pull/20721) by [@lukmccall](https://github.com/lukmccall))
|
|
26
|
+
|
|
13
27
|
## 12.2.0 — 2022-12-30
|
|
14
28
|
|
|
15
29
|
### 🐛 Bug fixes
|
package/README.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
<p>
|
|
2
|
+
<a href="https://docs.expo.dev/versions/latest/sdk/gl-view/">
|
|
3
|
+
<img
|
|
4
|
+
src="../../.github/resources/expo-gl.svg"
|
|
5
|
+
alt="expo-gl"
|
|
6
|
+
height="64" />
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
2
9
|
|
|
3
10
|
Provides GLView that acts as OpenGL ES render target and gives GL context object implementing WebGL 2.0 specification.
|
|
4
11
|
|
package/android/build.gradle
CHANGED
|
@@ -6,7 +6,7 @@ apply plugin: 'maven-publish'
|
|
|
6
6
|
apply plugin: "de.undercouch.download"
|
|
7
7
|
|
|
8
8
|
group = 'host.exp.exponent'
|
|
9
|
-
version = '12.
|
|
9
|
+
version = '12.3.1'
|
|
10
10
|
|
|
11
11
|
def REACT_NATIVE_BUILD_FROM_SOURCE = findProject(":ReactAndroid") != null
|
|
12
12
|
def REACT_NATIVE_DIR = REACT_NATIVE_BUILD_FROM_SOURCE
|
|
@@ -43,7 +43,7 @@ buildscript {
|
|
|
43
43
|
if (ext.has("kotlinVersion")) {
|
|
44
44
|
ext.kotlinVersion()
|
|
45
45
|
} else {
|
|
46
|
-
ext.safeExtGet("kotlinVersion", "1.
|
|
46
|
+
ext.safeExtGet("kotlinVersion", "1.8.10")
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -81,7 +81,7 @@ afterEvaluate {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
android {
|
|
84
|
-
compileSdkVersion safeExtGet("compileSdkVersion",
|
|
84
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 33)
|
|
85
85
|
|
|
86
86
|
if (rootProject.hasProperty("ndkPath")) {
|
|
87
87
|
ndkPath rootProject.ext.ndkPath
|
|
@@ -101,9 +101,9 @@ android {
|
|
|
101
101
|
|
|
102
102
|
defaultConfig {
|
|
103
103
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
104
|
-
targetSdkVersion safeExtGet("targetSdkVersion",
|
|
104
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
105
105
|
versionCode 31
|
|
106
|
-
versionName "12.
|
|
106
|
+
versionName "12.3.1"
|
|
107
107
|
|
|
108
108
|
externalNativeBuild {
|
|
109
109
|
cmake {
|
|
@@ -7,16 +7,10 @@ import java.util.List;
|
|
|
7
7
|
|
|
8
8
|
import expo.modules.core.ExportedModule;
|
|
9
9
|
import expo.modules.core.BasePackage;
|
|
10
|
-
import expo.modules.core.ViewManager;
|
|
11
10
|
|
|
12
11
|
public class GLPackage extends BasePackage {
|
|
13
12
|
@Override
|
|
14
13
|
public List<ExportedModule> createExportedModules(Context context) {
|
|
15
14
|
return Collections.singletonList((ExportedModule) new GLObjectManagerModule(context));
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
@Override
|
|
19
|
-
public List<ViewManager> createViewManagers(Context context) {
|
|
20
|
-
return Collections.singletonList((ViewManager) new GLViewManager());
|
|
21
|
-
}
|
|
22
16
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
package expo.modules.gl
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.graphics.SurfaceTexture
|
|
6
|
+
import android.view.TextureView
|
|
7
|
+
import android.view.TextureView.SurfaceTextureListener
|
|
8
|
+
import expo.modules.kotlin.AppContext
|
|
9
|
+
import expo.modules.kotlin.records.Field
|
|
10
|
+
import expo.modules.kotlin.records.Record
|
|
11
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
12
|
+
|
|
13
|
+
data class OnSurfaceCreateRecord(
|
|
14
|
+
@Field val exglCtxId: Int
|
|
15
|
+
) : Record
|
|
16
|
+
|
|
17
|
+
@SuppressLint("ViewConstructor")
|
|
18
|
+
class GLView(context: Context, appContext: AppContext) : TextureView(context), SurfaceTextureListener {
|
|
19
|
+
private var onSurfaceCreateWasCalled = false
|
|
20
|
+
private var onSurfaceTextureWasCalledWithZeroSize = false
|
|
21
|
+
private var glContext = GLContext(
|
|
22
|
+
appContext
|
|
23
|
+
.legacyModuleRegistry
|
|
24
|
+
.getExportedModuleOfClass(GLObjectManagerModule::class.java) as GLObjectManagerModule
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
private val exglContextId: Int
|
|
28
|
+
get() = glContext.contextId
|
|
29
|
+
|
|
30
|
+
val onSurfaceCreate by EventDispatcher<OnSurfaceCreateRecord>()
|
|
31
|
+
|
|
32
|
+
init {
|
|
33
|
+
surfaceTextureListener = this
|
|
34
|
+
isOpaque = false
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Public interface to allow running events on GL thread
|
|
38
|
+
fun runOnGLThread(r: Runnable?) {
|
|
39
|
+
glContext.runAsync(r)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// `TextureView.SurfaceTextureListener` events
|
|
43
|
+
@Synchronized
|
|
44
|
+
override fun onSurfaceTextureAvailable(surfaceTexture: SurfaceTexture, width: Int, height: Int) {
|
|
45
|
+
if (!onSurfaceCreateWasCalled) {
|
|
46
|
+
// onSurfaceTextureAvailable is sometimes called with 0 size texture
|
|
47
|
+
// and immediately followed by onSurfaceTextureSizeChanged with actual size
|
|
48
|
+
if (width == 0 || height == 0) {
|
|
49
|
+
onSurfaceTextureWasCalledWithZeroSize = true
|
|
50
|
+
}
|
|
51
|
+
if (!onSurfaceTextureWasCalledWithZeroSize) {
|
|
52
|
+
initializeSurfaceInGLContext(surfaceTexture)
|
|
53
|
+
}
|
|
54
|
+
onSurfaceCreateWasCalled = true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override fun onSurfaceTextureDestroyed(surface: SurfaceTexture): Boolean {
|
|
59
|
+
glContext.destroy()
|
|
60
|
+
|
|
61
|
+
// reset flag, so the context will be recreated when the new surface is available
|
|
62
|
+
onSurfaceCreateWasCalled = false
|
|
63
|
+
return true
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Synchronized
|
|
67
|
+
override fun onSurfaceTextureSizeChanged(surfaceTexture: SurfaceTexture, width: Int, height: Int) {
|
|
68
|
+
if (onSurfaceTextureWasCalledWithZeroSize && (width != 0 || height != 0)) {
|
|
69
|
+
initializeSurfaceInGLContext(surfaceTexture)
|
|
70
|
+
onSurfaceTextureWasCalledWithZeroSize = false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
override fun onSurfaceTextureUpdated(surface: SurfaceTexture) = Unit
|
|
75
|
+
|
|
76
|
+
fun flush() {
|
|
77
|
+
glContext.flush()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private fun initializeSurfaceInGLContext(surfaceTexture: SurfaceTexture) {
|
|
81
|
+
glContext.initialize(surfaceTexture) {
|
|
82
|
+
onSurfaceCreate(OnSurfaceCreateRecord(exglContextId))
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
package/expo-module.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-gl",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.1",
|
|
4
4
|
"description": "Provides GLView that acts as OpenGL ES render target and gives GL context object implementing WebGL 2.0 specification.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@types/offscreencanvas": "2019.6.4",
|
|
45
45
|
"@types/webgl2": "^0.0.6",
|
|
46
46
|
"expo-module-scripts": "^3.0.0",
|
|
47
|
-
"react-test-renderer": "
|
|
47
|
+
"react-test-renderer": "18.2.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"expo": "*"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "1f8a6a09570fd451378565ca34933018ce48454e"
|
|
53
53
|
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
package expo.modules.gl;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.graphics.SurfaceTexture;
|
|
5
|
-
import android.os.Bundle;
|
|
6
|
-
import android.view.TextureView;
|
|
7
|
-
|
|
8
|
-
import expo.modules.core.ModuleRegistry;
|
|
9
|
-
import expo.modules.core.interfaces.services.EventEmitter;
|
|
10
|
-
|
|
11
|
-
public class GLView extends TextureView implements TextureView.SurfaceTextureListener {
|
|
12
|
-
private boolean mOnSurfaceCreateCalled = false;
|
|
13
|
-
private boolean mOnSurfaceTextureCreatedWithZeroSize = false;
|
|
14
|
-
|
|
15
|
-
private GLContext mGLContext;
|
|
16
|
-
private ModuleRegistry mModuleRegistry;
|
|
17
|
-
|
|
18
|
-
// Suppresses ViewConstructor warnings
|
|
19
|
-
public GLView(Context context) {
|
|
20
|
-
super(context);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public GLView(Context context, ModuleRegistry moduleRegistry) {
|
|
24
|
-
super(context);
|
|
25
|
-
setSurfaceTextureListener(this);
|
|
26
|
-
setOpaque(false);
|
|
27
|
-
|
|
28
|
-
GLObjectManagerModule objectManager = (GLObjectManagerModule)moduleRegistry.getExportedModuleOfClass(GLObjectManagerModule.class);
|
|
29
|
-
mGLContext = new GLContext(objectManager);
|
|
30
|
-
mModuleRegistry = moduleRegistry;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Public interface to allow running events on GL thread
|
|
34
|
-
|
|
35
|
-
public void runOnGLThread(Runnable r) {
|
|
36
|
-
mGLContext.runAsync(r);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public GLContext getGLContext() {
|
|
40
|
-
return mGLContext;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// `TextureView.SurfaceTextureListener` events
|
|
45
|
-
|
|
46
|
-
@Override
|
|
47
|
-
synchronized public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
|
|
48
|
-
if (!mOnSurfaceCreateCalled) {
|
|
49
|
-
// onSurfaceTextureAvailable is sometimes called with 0 size texture
|
|
50
|
-
// and immediately followed by onSurfaceTextureSizeChanged with actual size
|
|
51
|
-
if (width == 0 || height == 0) {
|
|
52
|
-
mOnSurfaceTextureCreatedWithZeroSize = true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!mOnSurfaceTextureCreatedWithZeroSize) {
|
|
56
|
-
initializeSurfaceInGLContext(surfaceTexture);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
mOnSurfaceCreateCalled = true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
@Override
|
|
64
|
-
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
|
|
65
|
-
mGLContext.destroy();
|
|
66
|
-
|
|
67
|
-
// reset flag, so the context will be recreated when the new surface is available
|
|
68
|
-
mOnSurfaceCreateCalled = false;
|
|
69
|
-
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@Override
|
|
74
|
-
synchronized public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) {
|
|
75
|
-
if (mOnSurfaceTextureCreatedWithZeroSize && (width != 0 || height != 0)) {
|
|
76
|
-
initializeSurfaceInGLContext(surfaceTexture);
|
|
77
|
-
mOnSurfaceTextureCreatedWithZeroSize = false;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@Override
|
|
82
|
-
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public void flush() {
|
|
86
|
-
mGLContext.flush();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public int getEXGLCtxId() {
|
|
90
|
-
return mGLContext.getContextId();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private void initializeSurfaceInGLContext(SurfaceTexture surfaceTexture) {
|
|
94
|
-
mGLContext.initialize(surfaceTexture, new Runnable() {
|
|
95
|
-
@Override
|
|
96
|
-
public void run() {
|
|
97
|
-
final Bundle event = new Bundle();
|
|
98
|
-
final EventEmitter eventEmitter = mModuleRegistry.getModule(EventEmitter.class);
|
|
99
|
-
|
|
100
|
-
event.putInt("exglCtxId", mGLContext.getContextId());
|
|
101
|
-
|
|
102
|
-
eventEmitter.emit(getId(), new EventEmitter.BaseEvent() {
|
|
103
|
-
@Override
|
|
104
|
-
public String getEventName() {
|
|
105
|
-
return "onSurfaceCreate";
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
@Override
|
|
109
|
-
public Bundle getEventBody() {
|
|
110
|
-
return event;
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
package expo.modules.gl;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
|
|
5
|
-
import java.util.Arrays;
|
|
6
|
-
import java.util.List;
|
|
7
|
-
|
|
8
|
-
import expo.modules.core.ModuleRegistry;
|
|
9
|
-
import expo.modules.core.ViewManager;
|
|
10
|
-
|
|
11
|
-
public class GLViewManager extends ViewManager<GLView> {
|
|
12
|
-
private ModuleRegistry mModuleRegistry;
|
|
13
|
-
|
|
14
|
-
@Override
|
|
15
|
-
public String getName() {
|
|
16
|
-
return "ExponentGLView";
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@Override
|
|
20
|
-
public GLView createViewInstance(Context context) {
|
|
21
|
-
return new GLView(context, mModuleRegistry);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@Override
|
|
25
|
-
public ViewManagerType getViewManagerType() {
|
|
26
|
-
return ViewManagerType.SIMPLE;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@Override
|
|
30
|
-
public List<String> getExportedEventNames() {
|
|
31
|
-
return Arrays.asList("onSurfaceCreate");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@Override
|
|
35
|
-
public void onCreate(ModuleRegistry moduleRegistry) {
|
|
36
|
-
mModuleRegistry = moduleRegistry;
|
|
37
|
-
}
|
|
38
|
-
}
|