expo-gl 11.4.0 → 12.0.0
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/.clang-format +87 -0
- package/CHANGELOG.md +20 -0
- package/{ios/EXGL.podspec → EXGL.podspec} +10 -5
- package/README.md +0 -4
- package/android/CMakeLists.txt +59 -0
- package/android/build.gradle +118 -5
- package/android/src/main/cpp/EXGLJniApi.cpp +91 -0
- package/android/src/main/java/expo/modules/gl/cpp/EXGL.java +23 -0
- package/build/GLView.d.ts +29 -19
- package/build/GLView.d.ts.map +1 -1
- package/build/GLView.js +30 -1
- package/build/GLView.js.map +1 -1
- package/build/GLView.types.d.ts +50 -13
- package/build/GLView.types.d.ts.map +1 -1
- package/build/GLView.types.js +1 -0
- package/build/GLView.types.js.map +1 -1
- package/build/GLView.web.d.ts +5 -12
- package/build/GLView.web.d.ts.map +1 -1
- package/build/GLView.web.js.map +1 -1
- package/build/types.d.ts +3 -0
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/common/EXGLContextManager.cpp +60 -0
- package/common/EXGLContextManager.h +16 -0
- package/common/EXGLImageUtils.cpp +139 -0
- package/common/EXGLImageUtils.h +28 -0
- package/common/EXGLNativeApi.cpp +79 -0
- package/common/EXGLNativeApi.h +70 -0
- package/common/EXGLNativeContext.cpp +202 -0
- package/common/EXGLNativeContext.h +138 -0
- package/common/EXJsiArgsTransform.h +281 -0
- package/common/EXJsiUtils.h +82 -0
- package/common/EXPlatformUtils.h +36 -0
- package/common/EXTypedArrayApi.cpp +308 -0
- package/common/EXTypedArrayApi.h +170 -0
- package/common/EXWebGLConstants.def +568 -0
- package/common/EXWebGLMethods.cpp +1964 -0
- package/common/EXWebGLMethods.def +278 -0
- package/common/EXWebGLMethods.h +18 -0
- package/common/EXWebGLMethodsHelpers.h +147 -0
- package/common/EXWebGLRenderer.cpp +274 -0
- package/common/EXWebGLRenderer.h +48 -0
- package/common/stb_image.h +7293 -0
- package/ios/EXGL/EXGLCameraObject.mm +2 -2
- package/ios/EXGL/EXGLContext.h +3 -3
- package/ios/EXGL/EXGLContext.mm +7 -7
- package/ios/EXGL/EXGLObject.h +3 -3
- package/ios/EXGL/EXGLObject.mm +2 -2
- package/ios/EXGL/EXGLView.h +2 -2
- package/ios/EXGL/EXGLView.mm +7 -7
- package/ios/EXGL/EXPlatformUtils.mm +25 -0
- package/ios/EXGL.xcframework/ios-arm64/EXGL.framework/EXGL +0 -0
- package/ios/EXGL.xcframework/ios-arm64/EXGL.framework/Info.plist +0 -0
- package/ios/EXGL.xcframework/ios-arm64_x86_64-simulator/EXGL.framework/EXGL +0 -0
- package/ios/EXGL.xcframework/ios-arm64_x86_64-simulator/EXGL.framework/Info.plist +0 -0
- package/package.json +4 -5
- package/react-native.config.js +9 -0
- package/scripts/format.sh +14 -0
- package/src/GLView.tsx +34 -22
- package/src/GLView.types.ts +57 -19
- package/src/GLView.web.tsx +8 -14
- package/src/types.ts +3 -0
- package/unimodule.json +4 -1
package/.clang-format
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
AccessModifierOffset: -1
|
|
3
|
+
AlignAfterOpenBracket: AlwaysBreak
|
|
4
|
+
AlignConsecutiveAssignments: false
|
|
5
|
+
AlignConsecutiveDeclarations: false
|
|
6
|
+
AlignEscapedNewlinesLeft: true
|
|
7
|
+
AlignOperands: false
|
|
8
|
+
AlignTrailingComments: false
|
|
9
|
+
AllowAllParametersOfDeclarationOnNextLine: false
|
|
10
|
+
AllowShortBlocksOnASingleLine: false
|
|
11
|
+
AllowShortCaseLabelsOnASingleLine: false
|
|
12
|
+
AllowShortFunctionsOnASingleLine: Empty
|
|
13
|
+
AllowShortIfStatementsOnASingleLine: false
|
|
14
|
+
AllowShortLoopsOnASingleLine: false
|
|
15
|
+
AlwaysBreakAfterReturnType: None
|
|
16
|
+
AlwaysBreakBeforeMultilineStrings: true
|
|
17
|
+
AlwaysBreakTemplateDeclarations: true
|
|
18
|
+
BinPackArguments: false
|
|
19
|
+
BinPackParameters: false
|
|
20
|
+
BraceWrapping:
|
|
21
|
+
AfterClass: false
|
|
22
|
+
AfterControlStatement: false
|
|
23
|
+
AfterEnum: false
|
|
24
|
+
AfterFunction: false
|
|
25
|
+
AfterNamespace: false
|
|
26
|
+
AfterObjCDeclaration: false
|
|
27
|
+
AfterStruct: false
|
|
28
|
+
AfterUnion: false
|
|
29
|
+
BeforeCatch: false
|
|
30
|
+
BeforeElse: false
|
|
31
|
+
IndentBraces: false
|
|
32
|
+
BreakBeforeBinaryOperators: None
|
|
33
|
+
BreakBeforeBraces: Attach
|
|
34
|
+
BreakBeforeTernaryOperators: true
|
|
35
|
+
BreakConstructorInitializersBeforeComma: false
|
|
36
|
+
BreakAfterJavaFieldAnnotations: false
|
|
37
|
+
BreakStringLiterals: false
|
|
38
|
+
ColumnLimit: 100
|
|
39
|
+
CommentPragmas: '^ IWYU pragma:'
|
|
40
|
+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
|
41
|
+
ConstructorInitializerIndentWidth: 4
|
|
42
|
+
ContinuationIndentWidth: 4
|
|
43
|
+
Cpp11BracedListStyle: true
|
|
44
|
+
DerivePointerAlignment: false
|
|
45
|
+
DisableFormat: false
|
|
46
|
+
ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ]
|
|
47
|
+
IncludeCategories:
|
|
48
|
+
- Regex: '^<.*\.h(pp)?>'
|
|
49
|
+
Priority: 1
|
|
50
|
+
- Regex: '^<.*'
|
|
51
|
+
Priority: 2
|
|
52
|
+
- Regex: '.*'
|
|
53
|
+
Priority: 3
|
|
54
|
+
IndentCaseLabels: true
|
|
55
|
+
IndentWidth: 2
|
|
56
|
+
IndentWrappedFunctionNames: false
|
|
57
|
+
KeepEmptyLinesAtTheStartOfBlocks: false
|
|
58
|
+
MacroBlockBegin: ''
|
|
59
|
+
MacroBlockEnd: ''
|
|
60
|
+
MaxEmptyLinesToKeep: 1
|
|
61
|
+
NamespaceIndentation: None
|
|
62
|
+
ObjCBlockIndentWidth: 2
|
|
63
|
+
ObjCSpaceAfterProperty: false
|
|
64
|
+
ObjCSpaceBeforeProtocolList: false
|
|
65
|
+
PenaltyBreakBeforeFirstCallParameter: 1
|
|
66
|
+
PenaltyBreakComment: 300
|
|
67
|
+
PenaltyBreakFirstLessLess: 120
|
|
68
|
+
PenaltyBreakString: 1000
|
|
69
|
+
PenaltyExcessCharacter: 1000000
|
|
70
|
+
PenaltyReturnTypeOnItsOwnLine: 200
|
|
71
|
+
PointerAlignment: Right
|
|
72
|
+
ReflowComments: true
|
|
73
|
+
SortIncludes: true
|
|
74
|
+
SpaceAfterCStyleCast: false
|
|
75
|
+
SpaceBeforeAssignmentOperators: true
|
|
76
|
+
SpaceBeforeParens: ControlStatements
|
|
77
|
+
SpaceInEmptyParentheses: false
|
|
78
|
+
SpacesBeforeTrailingComments: 1
|
|
79
|
+
SpacesInAngles: false
|
|
80
|
+
SpacesInContainerLiterals: true
|
|
81
|
+
SpacesInCStyleCastParentheses: false
|
|
82
|
+
SpacesInParentheses: false
|
|
83
|
+
SpacesInSquareBrackets: false
|
|
84
|
+
Standard: Cpp11
|
|
85
|
+
TabWidth: 8
|
|
86
|
+
UseTab: Never
|
|
87
|
+
...
|
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,26 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 12.0.0 — 2022-10-25
|
|
14
|
+
|
|
15
|
+
### 🛠 Breaking changes
|
|
16
|
+
|
|
17
|
+
- Bumped iOS deployment target to 13.0 and deprecated support for iOS 12. ([#18873](https://github.com/expo/expo/pull/18873) by [@tsapeta](https://github.com/tsapeta))
|
|
18
|
+
|
|
19
|
+
### 🐛 Bug fixes
|
|
20
|
+
|
|
21
|
+
- Use shared C++ runtime to reduce library size on Android. ([#19372](https://github.com/expo/expo/pull/19372) by [@kudo](https://github.com/kudo))
|
|
22
|
+
|
|
23
|
+
### 💡 Others
|
|
24
|
+
|
|
25
|
+
- Merge `GLViewProps` and `BaseGLViewProps` into one type - `GLViewProps`. ([#18322](https://github.com/expo/expo/pull/18322) by [@Simek](https://github.com/Simek))
|
|
26
|
+
- Rename Web-specific prop types from `GLViewProps` to `GLViewWebProps`. ([#18322](https://github.com/expo/expo/pull/18322) by [@Simek](https://github.com/Simek))
|
|
27
|
+
- Merge `expo-gl-cpp` package into `expo-gl`. ([#18875](https://github.com/expo/expo/pull/18875) by [@wkozyra95](https://github.com/wkozyra95))
|
|
28
|
+
|
|
29
|
+
### ⚠️ Notices
|
|
30
|
+
|
|
31
|
+
- Added support for React Native 0.70.x. ([#19261](https://github.com/expo/expo/pull/19261) by [@kudo](https://github.com/kudo))
|
|
32
|
+
|
|
13
33
|
## 11.4.0 — 2022-07-07
|
|
14
34
|
|
|
15
35
|
### 🐛 Bug fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'json'
|
|
2
2
|
|
|
3
|
-
package = JSON.parse(File.read(File.join(__dir__, '
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
6
|
s.name = 'EXGL'
|
|
@@ -10,17 +10,22 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.license = package['license']
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.homepage = package['homepage']
|
|
13
|
-
s.platform = :ios, '
|
|
13
|
+
s.platform = :ios, '13.0'
|
|
14
14
|
s.source = { git: 'https://github.com/expo/expo-gl.git' }
|
|
15
15
|
s.static_framework = true
|
|
16
16
|
|
|
17
17
|
s.dependency 'ExpoModulesCore'
|
|
18
|
-
s.dependency '
|
|
18
|
+
s.dependency 'React-jsi'
|
|
19
|
+
|
|
20
|
+
s.compiler_flags = '-x objective-c++ -std=c++1z'
|
|
21
|
+
s.pod_target_xcconfig = {
|
|
22
|
+
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GLES_SILENCE_DEPRECATION=1'
|
|
23
|
+
}
|
|
19
24
|
|
|
20
25
|
if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
|
|
21
|
-
s.source_files = "
|
|
26
|
+
s.source_files = "ios/**/*.h"
|
|
22
27
|
s.vendored_frameworks = "#{s.name}.xcframework"
|
|
23
28
|
else
|
|
24
|
-
s.source_files = "
|
|
29
|
+
s.source_files = "ios/**/*.{h,m,mm}", "common/**/*.{h,cpp,def}"
|
|
25
30
|
end
|
|
26
31
|
end
|
package/README.md
CHANGED
|
@@ -15,10 +15,6 @@ For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare
|
|
|
15
15
|
|
|
16
16
|
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
17
17
|
|
|
18
|
-
### Install expo-gl-cpp
|
|
19
|
-
|
|
20
|
-
expo-gl requires that you also install and configure [expo-gl-cpp](https://github.com/expo/expo/tree/main/packages/expo-gl-cpp).
|
|
21
|
-
|
|
22
18
|
### Add the package to your npm dependencies
|
|
23
19
|
|
|
24
20
|
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.4.1)
|
|
2
|
+
|
|
3
|
+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
4
|
+
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
5
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
6
|
+
|
|
7
|
+
set(PACKAGE_NAME "expo-gl")
|
|
8
|
+
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
|
|
9
|
+
set(COMMON_DIR ${CMAKE_SOURCE_DIR}/../common)
|
|
10
|
+
|
|
11
|
+
add_library(
|
|
12
|
+
${PACKAGE_NAME} SHARED
|
|
13
|
+
${COMMON_DIR}/EXGLNativeApi.cpp
|
|
14
|
+
${COMMON_DIR}/EXGLNativeApi.h
|
|
15
|
+
${COMMON_DIR}/EXGLImageUtils.cpp
|
|
16
|
+
${COMMON_DIR}/EXGLImageUtils.h
|
|
17
|
+
${COMMON_DIR}/EXGLNativeContext.cpp
|
|
18
|
+
${COMMON_DIR}/EXGLNativeContext.h
|
|
19
|
+
${COMMON_DIR}/EXGLContextManager.cpp
|
|
20
|
+
${COMMON_DIR}/EXGLContextManager.h
|
|
21
|
+
${COMMON_DIR}/EXWebGLMethods.cpp
|
|
22
|
+
${COMMON_DIR}/EXWebGLMethods.h
|
|
23
|
+
${COMMON_DIR}/EXWebGLRenderer.cpp
|
|
24
|
+
${COMMON_DIR}/EXWebGLRenderer.h
|
|
25
|
+
${COMMON_DIR}/EXTypedArrayApi.cpp
|
|
26
|
+
${COMMON_DIR}/EXTypedArrayApi.h
|
|
27
|
+
./src/main/cpp/EXGLJniApi.cpp)
|
|
28
|
+
|
|
29
|
+
# Extracted AAR: ${BUILD_DIR}/react-native-0*/jni/${ANDROID_ABI}
|
|
30
|
+
file(GLOB LIBRN_DIR "${RN_SO_DIR}/${ANDROID_ABI}")
|
|
31
|
+
if(NOT LIBRN_DIR)
|
|
32
|
+
# If /${ANDROID_ABI} dir not found, then ${RN_SO_DIR} is probably:
|
|
33
|
+
# ReactAndroid/build/react-ndk/exported
|
|
34
|
+
file(GLOB LIBRN_DIR "${RN_SO_DIR}")
|
|
35
|
+
endif()
|
|
36
|
+
|
|
37
|
+
target_include_directories(
|
|
38
|
+
${PACKAGE_NAME} PRIVATE "${REACT_NATIVE_DIR}/ReactCommon/jsi"
|
|
39
|
+
"${COMMON_DIR}")
|
|
40
|
+
|
|
41
|
+
find_library(
|
|
42
|
+
JSI_LIB jsi
|
|
43
|
+
PATHS ${LIBRN_DIR}
|
|
44
|
+
NO_CMAKE_FIND_ROOT_PATH)
|
|
45
|
+
|
|
46
|
+
find_library(LOG_LIB log)
|
|
47
|
+
find_library(GLES_LIB GLESv3)
|
|
48
|
+
|
|
49
|
+
target_compile_options(
|
|
50
|
+
${PACKAGE_NAME}
|
|
51
|
+
PRIVATE -O2
|
|
52
|
+
-fexceptions
|
|
53
|
+
-frtti
|
|
54
|
+
-Wall
|
|
55
|
+
-Wextra
|
|
56
|
+
-Wno-unused-parameter
|
|
57
|
+
-Wshorten-64-to-32
|
|
58
|
+
-Wstrict-prototypes)
|
|
59
|
+
target_link_libraries(${PACKAGE_NAME} ${JSI_LIB} ${LOG_LIB} ${GLES_LIB} android)
|
package/android/build.gradle
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
import java.nio.file.Paths
|
|
2
|
+
|
|
1
3
|
apply plugin: 'com.android.library'
|
|
2
4
|
apply plugin: 'kotlin-android'
|
|
3
5
|
apply plugin: 'maven-publish'
|
|
4
6
|
|
|
5
7
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '
|
|
8
|
+
version = '12.0.0'
|
|
9
|
+
|
|
10
|
+
def REACT_NATIVE_DIR = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).parent
|
|
11
|
+
def RN_BUILD_FROM_SOURCE = findProject(":ReactAndroid") != null
|
|
12
|
+
def RN_SO_DIR = RN_BUILD_FROM_SOURCE
|
|
13
|
+
? Paths.get(findProject(":ReactAndroid").getProjectDir().toString(), "build", "intermediates", "library_*", "*", "jni")
|
|
14
|
+
: "${buildDir}/react-native-0*/jni"
|
|
15
|
+
def RN_AAR_DIR = "${REACT_NATIVE_DIR}/android"
|
|
16
|
+
def reactNativeArchitectures() {
|
|
17
|
+
def value = project.getProperties().get("reactNativeArchitectures")
|
|
18
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
19
|
+
}
|
|
7
20
|
|
|
8
21
|
buildscript {
|
|
9
22
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -61,6 +74,13 @@ afterEvaluate {
|
|
|
61
74
|
android {
|
|
62
75
|
compileSdkVersion safeExtGet("compileSdkVersion", 31)
|
|
63
76
|
|
|
77
|
+
if (rootProject.hasProperty("ndkPath")) {
|
|
78
|
+
ndkPath rootProject.ext.ndkPath
|
|
79
|
+
}
|
|
80
|
+
if (rootProject.hasProperty("ndkVersion")) {
|
|
81
|
+
ndkVersion rootProject.ext.ndkVersion
|
|
82
|
+
}
|
|
83
|
+
|
|
64
84
|
compileOptions {
|
|
65
85
|
sourceCompatibility JavaVersion.VERSION_11
|
|
66
86
|
targetCompatibility JavaVersion.VERSION_11
|
|
@@ -74,11 +94,35 @@ android {
|
|
|
74
94
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
95
|
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
76
96
|
versionCode 31
|
|
77
|
-
versionName "
|
|
97
|
+
versionName "12.0.0"
|
|
98
|
+
|
|
99
|
+
externalNativeBuild {
|
|
100
|
+
cmake {
|
|
101
|
+
abiFilters (*reactNativeArchitectures())
|
|
102
|
+
arguments "-DANDROID_STL=c++_shared",
|
|
103
|
+
"-DREACT_NATIVE_DIR=${REACT_NATIVE_DIR}",
|
|
104
|
+
"-DRN_SO_DIR=${RN_SO_DIR}"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
externalNativeBuild {
|
|
110
|
+
cmake {
|
|
111
|
+
path "./CMakeLists.txt"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
packagingOptions {
|
|
116
|
+
// Gradle will add cmake target dependencies into packaging.
|
|
117
|
+
excludes = [
|
|
118
|
+
"**/libc++_shared.so",
|
|
119
|
+
"**/libjsi.so",
|
|
120
|
+
]
|
|
78
121
|
}
|
|
79
122
|
|
|
80
|
-
|
|
81
|
-
|
|
123
|
+
configurations {
|
|
124
|
+
extractHeaders
|
|
125
|
+
extractJNI
|
|
82
126
|
}
|
|
83
127
|
|
|
84
128
|
lintOptions {
|
|
@@ -86,9 +130,78 @@ android {
|
|
|
86
130
|
}
|
|
87
131
|
}
|
|
88
132
|
|
|
133
|
+
repositories {
|
|
134
|
+
mavenCentral()
|
|
135
|
+
}
|
|
136
|
+
|
|
89
137
|
dependencies {
|
|
90
|
-
|
|
138
|
+
compileOnly 'com.facebook.soloader:soloader:0.8.2'
|
|
91
139
|
implementation project(':expo-modules-core')
|
|
92
140
|
|
|
93
141
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
94
142
|
}
|
|
143
|
+
|
|
144
|
+
def extractReactNativeAAR = { buildType ->
|
|
145
|
+
def suffix = buildType == 'Debug' ? '-debug' : '-release'
|
|
146
|
+
def rnAARs = fileTree(RN_AAR_DIR).matching { include "**/react-native/**/*${suffix}.aar" }
|
|
147
|
+
if (rnAARs.isEmpty()) {
|
|
148
|
+
rnAARs = fileTree(RN_AAR_DIR).matching { include "**/react-native/**/*.aar" }
|
|
149
|
+
}
|
|
150
|
+
if (rnAARs.any()) {
|
|
151
|
+
// node_modules/react-native has a .aar, extract headers
|
|
152
|
+
if (rnAARs.size() > 1) {
|
|
153
|
+
logger.error("More than one React Native AAR file has been found:")
|
|
154
|
+
rnAARs.each {println(it) }
|
|
155
|
+
throw new GradleException("Multiple React Native AARs found:\n${rnAARs.join("\n")}" +
|
|
156
|
+
"\nRemove the old ones and try again")
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
def rnAAR = rnAARs.singleFile
|
|
160
|
+
def file = rnAAR.absoluteFile
|
|
161
|
+
def packageName = file.name.tokenize('-')[0]
|
|
162
|
+
copy {
|
|
163
|
+
from zipTree(file)
|
|
164
|
+
into "$buildDir/$file.name"
|
|
165
|
+
include "jni/**/*"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
task extractReactNativeAARRelease {
|
|
170
|
+
doLast {
|
|
171
|
+
extractReactNativeAAR('Release')
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
task extractReactNativeAARDebug {
|
|
176
|
+
doLast {
|
|
177
|
+
extractReactNativeAAR('Debug')
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
task extractJNIFiles {
|
|
182
|
+
doLast {
|
|
183
|
+
configurations.extractJNI.files.each {
|
|
184
|
+
def file = it.absoluteFile
|
|
185
|
+
copy {
|
|
186
|
+
from zipTree(file)
|
|
187
|
+
into "$buildDir/$file.name"
|
|
188
|
+
include "jni/**/*"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
tasks.whenTaskAdded { task ->
|
|
195
|
+
if (!task.name.contains("Clean") && (task.name.contains('externalNativeBuild') || task.name.startsWith('configureCMake'))) {
|
|
196
|
+
def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release'
|
|
197
|
+
task.dependsOn(extractJNIFiles)
|
|
198
|
+
if (RN_BUILD_FROM_SOURCE) {
|
|
199
|
+
task.dependsOn(":ReactAndroid:copy${buildType}JniLibsProjectOnly")
|
|
200
|
+
} else {
|
|
201
|
+
task.dependsOn("extractReactNativeAAR${buildType}")
|
|
202
|
+
}
|
|
203
|
+
} else if (task.name.startsWith('generateJsonModel') && RN_BUILD_FROM_SOURCE) {
|
|
204
|
+
def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release'
|
|
205
|
+
task.dependsOn(":ReactAndroid:copy${buildType}JniLibsProjectOnly")
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#include <stdint.h>
|
|
2
|
+
|
|
3
|
+
#include <jni.h>
|
|
4
|
+
#include <thread>
|
|
5
|
+
#include <android/log.h>
|
|
6
|
+
|
|
7
|
+
#include <jsi/jsi.h>
|
|
8
|
+
#include "EXGLNativeApi.h"
|
|
9
|
+
#include "EXPlatformUtils.h"
|
|
10
|
+
|
|
11
|
+
extern "C" {
|
|
12
|
+
|
|
13
|
+
// JNIEnv is valid only inside the same thread that it was passed from
|
|
14
|
+
// to support worklet we need register it from UI thread
|
|
15
|
+
thread_local JNIEnv* threadLocalEnv;
|
|
16
|
+
|
|
17
|
+
JNIEXPORT jint JNICALL
|
|
18
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLContextCreate
|
|
19
|
+
(JNIEnv *env, jclass clazz) {
|
|
20
|
+
return EXGLContextCreate();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
JNIEXPORT void JNICALL
|
|
24
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLContextPrepare
|
|
25
|
+
(JNIEnv *env, jclass clazz, jlong jsiPtr, jint exglCtxId, jobject glContext) {
|
|
26
|
+
threadLocalEnv = env;
|
|
27
|
+
jclass GLContextClass = env->GetObjectClass(glContext);
|
|
28
|
+
jobject glContextRef = env->NewGlobalRef(glContext);
|
|
29
|
+
jmethodID flushMethodRef = env->GetMethodID(GLContextClass, "flush", "()V");
|
|
30
|
+
|
|
31
|
+
std::function<void(void)> flushMethod = [glContextRef, flushMethodRef] {
|
|
32
|
+
threadLocalEnv->CallVoidMethod(glContextRef, flushMethodRef);
|
|
33
|
+
};
|
|
34
|
+
EXGLContextPrepare((void*) jsiPtr, exglCtxId, flushMethod);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
JNIEXPORT void JNICALL
|
|
38
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLContextDestroy
|
|
39
|
+
(JNIEnv *env, jclass clazz, jint exglCtxId) {
|
|
40
|
+
EXGLContextDestroy(exglCtxId);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
JNIEXPORT void JNICALL
|
|
44
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLContextFlush
|
|
45
|
+
(JNIEnv *env, jclass clazz, jint exglCtxId) {
|
|
46
|
+
EXGLContextFlush(exglCtxId);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
JNIEXPORT jint JNICALL
|
|
50
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLContextCreateObject
|
|
51
|
+
(JNIEnv *env, jclass clazz, jint exglCtxId) {
|
|
52
|
+
return EXGLContextCreateObject(exglCtxId);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
JNIEXPORT void JNICALL
|
|
56
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLContextDestroyObject
|
|
57
|
+
(JNIEnv *env, jclass clazz, jint exglCtxId, jint exglObjId) {
|
|
58
|
+
EXGLContextDestroyObject(exglCtxId, exglObjId);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
JNIEXPORT void JNICALL
|
|
62
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLContextMapObject
|
|
63
|
+
(JNIEnv *env, jclass clazz, jint exglCtxId, jint exglObjId, jint glObj) {
|
|
64
|
+
EXGLContextMapObject(exglCtxId, exglObjId, glObj);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
JNIEXPORT jint JNICALL
|
|
68
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLContextGetObject
|
|
69
|
+
(JNIEnv *env, jclass clazz, jint exglCtxId, jint exglObjId) {
|
|
70
|
+
return EXGLContextGetObject(exglCtxId, exglObjId);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
JNIEXPORT void JNICALL
|
|
74
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLRegisterThread
|
|
75
|
+
(JNIEnv *env, jclass clazz) {
|
|
76
|
+
threadLocalEnv = env;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
JNIEXPORT bool JNICALL
|
|
80
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLContextNeedsRedraw
|
|
81
|
+
(JNIEnv *env, jclass clazz, jint exglCtxId) {
|
|
82
|
+
return EXGLContextNeedsRedraw(exglCtxId);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
JNIEXPORT void JNICALL
|
|
86
|
+
Java_expo_modules_gl_cpp_EXGL_EXGLContextDrawEnded
|
|
87
|
+
(JNIEnv *env, jclass clazz, jint exglCtxId) {
|
|
88
|
+
EXGLContextDrawEnded(exglCtxId);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package expo.modules.gl.cpp;
|
|
2
|
+
|
|
3
|
+
import com.facebook.soloader.SoLoader;
|
|
4
|
+
|
|
5
|
+
// Java bindings for EXGLNativeApi.h interface
|
|
6
|
+
public class EXGL {
|
|
7
|
+
static {
|
|
8
|
+
SoLoader.loadLibrary("expo-gl");
|
|
9
|
+
}
|
|
10
|
+
public static native int EXGLContextCreate();
|
|
11
|
+
public static native void EXGLContextPrepare(long jsCtxPtr, int exglCtxId, Object glContext);
|
|
12
|
+
|
|
13
|
+
public static native void EXGLContextDestroy(int exglCtxId);
|
|
14
|
+
public static native void EXGLContextFlush(int exglCtxId);
|
|
15
|
+
|
|
16
|
+
public static native int EXGLContextCreateObject(int exglCtxId);
|
|
17
|
+
public static native void EXGLContextDestroyObject(int exglCtxId, int exglObjId);
|
|
18
|
+
public static native void EXGLContextMapObject(int exglCtxId, int exglObjId, int glObj);
|
|
19
|
+
public static native int EXGLContextGetObject(int exglCtxId, int exglObjId);
|
|
20
|
+
public static native void EXGLRegisterThread();
|
|
21
|
+
public static native boolean EXGLContextNeedsRedraw(int exglCtxId);
|
|
22
|
+
public static native void EXGLContextDrawEnded(int exglCtxId);
|
|
23
|
+
}
|
package/build/GLView.d.ts
CHANGED
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ComponentOrHandle, SurfaceCreateEvent, GLSnapshot, ExpoWebGLRenderingContext, SnapshotOptions,
|
|
3
|
-
export
|
|
2
|
+
import { ComponentOrHandle, SurfaceCreateEvent, GLSnapshot, ExpoWebGLRenderingContext, SnapshotOptions, GLViewProps } from './GLView.types';
|
|
3
|
+
export declare type WebGLObject = {
|
|
4
4
|
id: number;
|
|
5
|
-
}
|
|
6
|
-
export declare type GLViewProps = {
|
|
7
|
-
/**
|
|
8
|
-
* Called when the OpenGL context is created, with the context object as a parameter. The context
|
|
9
|
-
* object has an API mirroring WebGL's WebGLRenderingContext.
|
|
10
|
-
*/
|
|
11
|
-
onContextCreate(gl: ExpoWebGLRenderingContext): void;
|
|
12
|
-
/**
|
|
13
|
-
* [iOS only] Number of samples for Apple's built-in multisampling.
|
|
14
|
-
*/
|
|
15
|
-
msaaSamples: number;
|
|
16
|
-
/**
|
|
17
|
-
* A ref callback for the native GLView
|
|
18
|
-
*/
|
|
19
|
-
nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | null): any;
|
|
20
|
-
} & BaseGLViewProps;
|
|
5
|
+
};
|
|
21
6
|
/**
|
|
22
|
-
* A
|
|
7
|
+
* A View that acts as an OpenGL ES render target. On mounting, an OpenGL ES context is created.
|
|
8
|
+
* Its drawing buffer is presented as the contents of the View every frame.
|
|
23
9
|
*/
|
|
24
10
|
export declare class GLView extends React.Component<GLViewProps> {
|
|
25
11
|
static NativeView: any;
|
|
26
12
|
static defaultProps: {
|
|
27
13
|
msaaSamples: number;
|
|
28
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Imperative API that creates headless context which is devoid of underlying view.
|
|
17
|
+
* It's useful for headless rendering or in case you want to keep just one context per application and share it between multiple components.
|
|
18
|
+
* It is slightly faster than usual context as it doesn't swap framebuffers and doesn't present them on the canvas,
|
|
19
|
+
* however it may require you to take a snapshot in order to present its results.
|
|
20
|
+
* 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.
|
|
21
|
+
* @return A promise that resolves to WebGL context object. See [WebGL API](#webgl-api) for more details.
|
|
22
|
+
*/
|
|
29
23
|
static createContextAsync(): Promise<ExpoWebGLRenderingContext>;
|
|
24
|
+
/**
|
|
25
|
+
* Destroys given context.
|
|
26
|
+
* @param exgl WebGL context to destroy.
|
|
27
|
+
* @return A promise that resolves to boolean value that is `true` if given context existed and has been destroyed successfully.
|
|
28
|
+
*/
|
|
30
29
|
static destroyContextAsync(exgl?: ExpoWebGLRenderingContext | number): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Takes a snapshot of the framebuffer and saves it as a file to app's cache directory.
|
|
32
|
+
* @param exgl WebGL context to take a snapshot from.
|
|
33
|
+
* @param options
|
|
34
|
+
* @return A promise that resolves to `GLSnapshot` object.
|
|
35
|
+
*/
|
|
31
36
|
static takeSnapshotAsync(exgl?: ExpoWebGLRenderingContext | number, options?: SnapshotOptions): Promise<GLSnapshot>;
|
|
32
37
|
static getWorkletContext: (contextId: number) => ExpoWebGLRenderingContext | undefined;
|
|
33
38
|
nativeRef: ComponentOrHandle;
|
|
@@ -38,6 +43,11 @@ export declare class GLView extends React.Component<GLViewProps> {
|
|
|
38
43
|
startARSessionAsync(): Promise<any>;
|
|
39
44
|
createCameraTextureAsync(cameraRefOrHandle: ComponentOrHandle): Promise<WebGLTexture>;
|
|
40
45
|
destroyObjectAsync(glObject: WebGLObject): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Same as static [`takeSnapshotAsync()`](#glviewtakesnapshotasyncgl-options),
|
|
48
|
+
* but uses WebGL context that is associated with the view on which the method is called.
|
|
49
|
+
* @param options
|
|
50
|
+
*/
|
|
41
51
|
takeSnapshotAsync(options?: SnapshotOptions): Promise<GLSnapshot>;
|
|
42
52
|
}
|
|
43
53
|
//# sourceMappingURL=GLView.d.ts.map
|
package/build/GLView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLView.d.ts","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,yBAAyB,EACzB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"GLView.d.ts","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,yBAAyB,EACzB,eAAe,EACf,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAIxB,oBAAY,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AASF;;;GAGG;AACH,qBAAa,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;IACtD,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC;IAEvB,MAAM,CAAC,YAAY;;MAEjB;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;IAK7F;;;;;OAKG;WACU,iBAAiB,CAC5B,IAAI,CAAC,EAAE,yBAAyB,GAAG,MAAM,EACzC,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,UAAU,CAAC;IAKtB,MAAM,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,yBAAyB,GAAG,SAAS,CACrD;IAEjC,SAAS,EAAE,iBAAiB,CAAQ;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,MAAM;IA0BN,aAAa,cAAe,iBAAiB,KAAG,IAAI,CAKlD;IAEF,gBAAgB,mCAAoC,kBAAkB,KAAG,IAAI,CAQ3E;IAGI,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
|
@@ -5,22 +5,43 @@ import { configureLogging } from './GLUtils';
|
|
|
5
5
|
import { createWorkletContextProvider } from './GLWorkletContextProvider';
|
|
6
6
|
const { ExponentGLObjectManager, ExponentGLViewManager } = NativeModulesProxy;
|
|
7
7
|
const NativeView = requireNativeViewManager('ExponentGLView');
|
|
8
|
+
// @needsAudit
|
|
8
9
|
/**
|
|
9
|
-
* A
|
|
10
|
+
* A View that acts as an OpenGL ES render target. On mounting, an OpenGL ES context is created.
|
|
11
|
+
* Its drawing buffer is presented as the contents of the View every frame.
|
|
10
12
|
*/
|
|
11
13
|
export class GLView extends React.Component {
|
|
12
14
|
static NativeView;
|
|
13
15
|
static defaultProps = {
|
|
14
16
|
msaaSamples: 4,
|
|
15
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Imperative API that creates headless context which is devoid of underlying view.
|
|
20
|
+
* It's useful for headless rendering or in case you want to keep just one context per application and share it between multiple components.
|
|
21
|
+
* It is slightly faster than usual context as it doesn't swap framebuffers and doesn't present them on the canvas,
|
|
22
|
+
* however it may require you to take a snapshot in order to present its results.
|
|
23
|
+
* 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.
|
|
24
|
+
* @return A promise that resolves to WebGL context object. See [WebGL API](#webgl-api) for more details.
|
|
25
|
+
*/
|
|
16
26
|
static async createContextAsync() {
|
|
17
27
|
const { exglCtxId } = await ExponentGLObjectManager.createContextAsync();
|
|
18
28
|
return getGl(exglCtxId);
|
|
19
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Destroys given context.
|
|
32
|
+
* @param exgl WebGL context to destroy.
|
|
33
|
+
* @return A promise that resolves to boolean value that is `true` if given context existed and has been destroyed successfully.
|
|
34
|
+
*/
|
|
20
35
|
static async destroyContextAsync(exgl) {
|
|
21
36
|
const exglCtxId = getContextId(exgl);
|
|
22
37
|
return ExponentGLObjectManager.destroyContextAsync(exglCtxId);
|
|
23
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Takes a snapshot of the framebuffer and saves it as a file to app's cache directory.
|
|
41
|
+
* @param exgl WebGL context to take a snapshot from.
|
|
42
|
+
* @param options
|
|
43
|
+
* @return A promise that resolves to `GLSnapshot` object.
|
|
44
|
+
*/
|
|
24
45
|
static async takeSnapshotAsync(exgl, options = {}) {
|
|
25
46
|
const exglCtxId = getContextId(exgl);
|
|
26
47
|
return ExponentGLObjectManager.takeSnapshotAsync(exglCtxId, options);
|
|
@@ -54,12 +75,14 @@ export class GLView extends React.Component {
|
|
|
54
75
|
this.props.onContextCreate(gl);
|
|
55
76
|
}
|
|
56
77
|
};
|
|
78
|
+
// @docsMissing
|
|
57
79
|
async startARSessionAsync() {
|
|
58
80
|
if (!ExponentGLViewManager.startARSessionAsync) {
|
|
59
81
|
throw new UnavailabilityError('expo-gl', 'startARSessionAsync');
|
|
60
82
|
}
|
|
61
83
|
return await ExponentGLViewManager.startARSessionAsync(findNodeHandle(this.nativeRef));
|
|
62
84
|
}
|
|
85
|
+
// @docsMissing
|
|
63
86
|
async createCameraTextureAsync(cameraRefOrHandle) {
|
|
64
87
|
if (!ExponentGLObjectManager.createCameraTextureAsync) {
|
|
65
88
|
throw new UnavailabilityError('expo-gl', 'createCameraTextureAsync');
|
|
@@ -72,12 +95,18 @@ export class GLView extends React.Component {
|
|
|
72
95
|
const { exglObjId } = await ExponentGLObjectManager.createCameraTextureAsync(exglCtxId, cameraTag);
|
|
73
96
|
return { id: exglObjId };
|
|
74
97
|
}
|
|
98
|
+
// @docsMissing
|
|
75
99
|
async destroyObjectAsync(glObject) {
|
|
76
100
|
if (!ExponentGLObjectManager.destroyObjectAsync) {
|
|
77
101
|
throw new UnavailabilityError('expo-gl', 'destroyObjectAsync');
|
|
78
102
|
}
|
|
79
103
|
return await ExponentGLObjectManager.destroyObjectAsync(glObject.id);
|
|
80
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Same as static [`takeSnapshotAsync()`](#glviewtakesnapshotasyncgl-options),
|
|
107
|
+
* but uses WebGL context that is associated with the view on which the method is called.
|
|
108
|
+
* @param options
|
|
109
|
+
*/
|
|
81
110
|
async takeSnapshotAsync(options = {}) {
|
|
82
111
|
if (!GLView.takeSnapshotAsync) {
|
|
83
112
|
throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');
|