react-native-skia 3.0.0 → 3.0.2
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/Package.swift +14 -13
- package/android/CMakeLists.txt +13 -42
- package/android/build.gradle +55 -47
- package/android/cpp/jni/JniLoad.cpp +2 -4
- package/android/cpp/jni/include/JniSkiaView.h +123 -0
- package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.cpp → RNSkAndroidCanvasProvider.cpp} +45 -100
- package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.h → RNSkAndroidCanvasProvider.h} +24 -22
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -83
- package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +0 -8
- package/android/src/main/java/com/reactnative/skia/RNSkiaPackage.java +1 -2
- package/android/src/main/java/com/reactnative/skia/SkiaSurfaceView.java +1 -3
- package/android/src/main/java/com/reactnative/skia/SkiaTextureView.java +1 -17
- package/android/src/main/java/com/reactnative/skia/{SkiaBaseView.java → SkiaView.java} +78 -16
- package/android/src/main/java/com/reactnative/skia/SkiaViewManager.java +85 -0
- package/apple/MetalLayerColorSpace.mm +0 -4
- package/apple/RNSkApplePlatformContext.h +0 -14
- package/apple/RNSkApplePlatformContext.mm +2 -112
- package/apple/RNSkMetalCanvasProvider.h +14 -19
- package/apple/RNSkMetalCanvasProvider.mm +35 -68
- package/apple/SkiaView.h +20 -0
- package/apple/SkiaView.mm +210 -0
- package/cpp/api/JsiSkApi.h +2 -13
- package/cpp/api/JsiSkCanvas.h +4 -18
- package/cpp/api/JsiSkGraphiteContext.h +1 -5
- package/cpp/api/JsiSkGraphiteRecording.h +1 -5
- package/cpp/api/JsiSkImage.h +7 -41
- package/cpp/api/JsiSkImageFactory.h +0 -14
- package/cpp/api/JsiSkSurface.h +2 -16
- package/cpp/api/JsiSkSurfaceFactory.h +0 -8
- package/cpp/rnskia/RNDawnContext.h +6 -0
- package/cpp/rnskia/RNDawnInterop.cpp +0 -4
- package/cpp/rnskia/RNDawnUtils.h +0 -1
- package/cpp/rnskia/RNDawnWindowContext.cpp +10 -0
- package/cpp/rnskia/RNDawnWindowContext.h +4 -0
- package/cpp/rnskia/RNSkCanvasProvider.h +221 -0
- package/cpp/rnskia/RNSkGraphiteProducer.cpp +36 -14
- package/cpp/rnskia/RNSkGraphiteProducer.h +23 -8
- package/cpp/rnskia/RNSkGraphiteTarget.h +383 -0
- package/cpp/rnskia/RNSkJsiViewApi.h +9 -18
- package/cpp/rnskia/RNSkPlatformContext.h +9 -15
- package/cpp/rnskia/RNSkView.h +340 -245
- package/jestSetup.js +1 -3
- package/lib/commonjs/Platform/Platform.web.js +1 -1
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/index.d.ts +1 -3
- package/lib/commonjs/index.js +3 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mock/index.js +0 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +15 -12
- package/lib/commonjs/renderer/Canvas.js +24 -20
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Graphite.d.ts +3 -3
- package/lib/commonjs/skia/types/Graphite.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +1 -2
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/commonjs/specs/NativeSkiaModule.web.js +5 -9
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/{typescript/src/specs/SkiaPictureViewNativeComponent.d.ts → commonjs/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/commonjs/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
- package/lib/commonjs/specs/SkiaViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.js +27 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/commonjs/views/SkiaGraphiteView.js +23 -12
- package/lib/commonjs/views/SkiaGraphiteView.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.d.ts +4 -1
- package/lib/commonjs/views/SkiaPictureView.js +12 -10
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaView.web.d.ts +12 -0
- package/lib/commonjs/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +82 -38
- package/lib/commonjs/views/SkiaView.web.js.map +1 -0
- package/lib/commonjs/views/SkiaWebRenderer.js +1 -1
- package/lib/commonjs/views/SkiaWebRenderer.js.map +1 -1
- package/lib/commonjs/views/android.d.ts +6 -0
- package/lib/commonjs/views/android.js +17 -0
- package/lib/commonjs/views/android.js.map +1 -0
- package/lib/commonjs/views/types.d.ts +3 -12
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/Platform/Platform.web.js +1 -1
- package/lib/module/Platform/Platform.web.js.map +1 -1
- package/lib/module/index.d.ts +1 -3
- package/lib/module/index.js +1 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/mock/index.js +0 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +15 -12
- package/lib/module/renderer/Canvas.js +24 -19
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/types/Graphite.d.ts +3 -3
- package/lib/module/skia/types/Graphite.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +1 -2
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/module/specs/NativeSkiaModule.web.js +5 -9
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/{commonjs/specs/SkiaPictureViewNativeComponent.d.ts → module/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/module/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
- package/lib/module/specs/SkiaViewNativeComponent.js.map +1 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.js +21 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.js.map +1 -0
- package/lib/module/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/module/views/SkiaGraphiteView.js +23 -12
- package/lib/module/views/SkiaGraphiteView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.d.ts +4 -1
- package/lib/module/views/SkiaPictureView.js +12 -10
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaView.web.d.ts +12 -0
- package/lib/module/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +80 -36
- package/lib/module/views/SkiaView.web.js.map +1 -0
- package/lib/module/views/SkiaWebRenderer.js +1 -1
- package/lib/module/views/SkiaWebRenderer.js.map +1 -1
- package/lib/module/views/android.d.ts +6 -0
- package/lib/module/views/android.js +10 -0
- package/lib/module/views/android.js.map +1 -0
- package/lib/module/views/types.d.ts +3 -12
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -3
- package/lib/typescript/src/renderer/Canvas.d.ts +15 -12
- package/lib/typescript/src/skia/types/Graphite.d.ts +3 -3
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/typescript/src/skia/types/Skia.d.ts +1 -2
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/{module/specs/SkiaPictureViewNativeComponent.d.ts → typescript/src/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/typescript/src/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/typescript/src/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/typescript/src/views/SkiaPictureView.d.ts +4 -1
- package/lib/typescript/src/views/SkiaView.web.d.ts +12 -0
- package/lib/typescript/src/views/android.d.ts +6 -0
- package/lib/typescript/src/views/types.d.ts +3 -12
- package/package.json +8 -16
- package/react-native-skia.podspec +50 -57
- package/src/Platform/Platform.web.tsx +1 -1
- package/src/index.ts +1 -3
- package/src/mock/index.ts +0 -1
- package/src/renderer/Canvas.tsx +23 -27
- package/src/skia/types/Graphite.ts +3 -3
- package/src/skia/types/Image/ImageFactory.ts +2 -2
- package/src/skia/types/Skia.ts +1 -2
- package/src/skia/types/Surface/SurfaceFactory.ts +1 -1
- package/src/specs/NativeSkiaModule.web.ts +9 -21
- package/src/specs/{SkiaPictureViewNativeComponent.ts → SkiaViewNativeComponent.ts} +1 -4
- package/src/specs/{SkiaPictureViewNativeComponent.web.ts → SkiaViewNativeComponent.web.ts} +8 -10
- package/src/views/SkiaGraphiteView.tsx +27 -16
- package/src/views/SkiaPictureView.tsx +11 -10
- package/src/views/{SkiaGraphiteView.web.tsx → SkiaView.web.tsx} +100 -53
- package/src/views/SkiaWebRenderer.ts +1 -1
- package/src/views/android.ts +16 -0
- package/src/views/types.ts +3 -14
- package/android/cpp/jni/include/JniSkiaBaseView.h +0 -92
- package/android/cpp/jni/include/JniSkiaGraphiteView.h +0 -176
- package/android/cpp/jni/include/JniSkiaPictureView.h +0 -172
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +0 -245
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.h +0 -33
- package/android/cpp/rnskia-android/OpenGLContext.h +0 -248
- package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +0 -67
- package/android/cpp/rnskia-android/OpenGLWindowContext.h +0 -75
- package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -67
- package/android/cpp/rnskia-android/gl/Context.h +0 -80
- package/android/cpp/rnskia-android/gl/Display.h +0 -123
- package/android/cpp/rnskia-android/gl/Error.cpp +0 -45
- package/android/cpp/rnskia-android/gl/Error.h +0 -8
- package/android/cpp/rnskia-android/gl/Surface.h +0 -43
- package/android/src/main/java/com/reactnative/skia/SkiaBaseViewManager.java +0 -65
- package/android/src/main/java/com/reactnative/skia/SkiaGraphiteView.java +0 -78
- package/android/src/main/java/com/reactnative/skia/SkiaGraphiteViewManager.java +0 -32
- package/android/src/main/java/com/reactnative/skia/SkiaPictureView.java +0 -105
- package/android/src/main/java/com/reactnative/skia/SkiaPictureViewManager.java +0 -44
- package/apple/MetalContext.h +0 -116
- package/apple/MetalContext.mm +0 -38
- package/apple/MetalWindowContext.h +0 -42
- package/apple/MetalWindowContext.mm +0 -95
- package/apple/RNSkAppleView.h +0 -49
- package/apple/RNSkAppleView.mm +0 -35
- package/apple/SkiaCVPixelBufferUtils.h +0 -122
- package/apple/SkiaCVPixelBufferUtils.mm +0 -535
- package/apple/SkiaGraphiteView.h +0 -26
- package/apple/SkiaGraphiteView.mm +0 -180
- package/apple/SkiaPictureView.h +0 -7
- package/apple/SkiaPictureView.mm +0 -70
- package/apple/SkiaUIView.h +0 -31
- package/apple/SkiaUIView.mm +0 -164
- package/cpp/rnskia/RNSkGraphiteView.h +0 -708
- package/cpp/rnskia/RNSkPictureView.cpp +0 -69
- package/cpp/rnskia/RNSkPictureView.h +0 -211
- package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +0 -1162
- package/lib/commonjs/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/commonjs/renderer/DefaultCanvas.js +0 -42
- package/lib/commonjs/renderer/DefaultCanvas.js.map +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/commonjs/renderer/GraphiteCanvas.js +0 -64
- package/lib/commonjs/renderer/GraphiteCanvas.js.map +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.web.js +0 -13
- package/lib/commonjs/renderer/GraphiteCanvas.web.js.map +0 -1
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js +0 -12
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js +0 -28
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +0 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js +0 -29
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/commonjs/views/SkiaGraphiteView.web.js.map +0 -1
- package/lib/commonjs/views/SkiaPictureView.web.d.ts +0 -11
- package/lib/commonjs/views/SkiaPictureView.web.js +0 -165
- package/lib/commonjs/views/SkiaPictureView.web.js.map +0 -1
- package/lib/module/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/module/renderer/DefaultCanvas.js +0 -34
- package/lib/module/renderer/DefaultCanvas.js.map +0 -1
- package/lib/module/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/module/renderer/GraphiteCanvas.js +0 -57
- package/lib/module/renderer/GraphiteCanvas.js.map +0 -1
- package/lib/module/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/module/renderer/GraphiteCanvas.web.js +0 -4
- package/lib/module/renderer/GraphiteCanvas.web.js.map +0 -1
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.js +0 -8
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js +0 -22
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +0 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.js +0 -23
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
- package/lib/module/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/module/views/SkiaGraphiteView.web.js.map +0 -1
- package/lib/module/views/SkiaPictureView.web.d.ts +0 -11
- package/lib/module/views/SkiaPictureView.web.js +0 -156
- package/lib/module/views/SkiaPictureView.web.js.map +0 -1
- package/lib/typescript/src/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/typescript/src/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/typescript/src/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/typescript/src/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/typescript/src/views/SkiaPictureView.web.d.ts +0 -11
- package/libs/.graphite +0 -1
- package/src/renderer/DefaultCanvas.tsx +0 -41
- package/src/renderer/GraphiteCanvas.tsx +0 -61
- package/src/renderer/GraphiteCanvas.web.tsx +0 -3
- package/src/specs/SkiaGraphiteViewNativeComponent.ts +0 -17
- package/src/specs/SkiaGraphiteViewNativeComponent.web.ts +0 -31
- package/src/views/SkiaPictureView.web.tsx +0 -224
package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.cpp → RNSkAndroidCanvasProvider.cpp}
RENAMED
|
@@ -1,55 +1,40 @@
|
|
|
1
|
-
#include "
|
|
1
|
+
#include "RNSkAndroidCanvasProvider.h"
|
|
2
2
|
|
|
3
3
|
#include <android/native_window_jni.h>
|
|
4
4
|
#include <fbjni/fbjni.h>
|
|
5
5
|
#include <jni.h>
|
|
6
6
|
#include <memory>
|
|
7
7
|
|
|
8
|
-
#include "RNSkLog.h"
|
|
9
|
-
|
|
10
|
-
#if defined(SK_GRAPHITE)
|
|
11
8
|
#include "RNDawnContext.h"
|
|
12
|
-
#
|
|
13
|
-
#include "OpenGLContext.h"
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
#pragma clang diagnostic push
|
|
17
|
-
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
18
|
-
|
|
19
|
-
#include "include/core/SkCanvas.h"
|
|
20
|
-
#include "include/core/SkSurface.h"
|
|
21
|
-
|
|
22
|
-
#pragma clang diagnostic pop
|
|
9
|
+
#include "RNSkLog.h"
|
|
23
10
|
|
|
24
11
|
namespace RNSkia {
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
std::
|
|
28
|
-
std::
|
|
29
|
-
: RNSkCanvasProvider(std::move(requestRedraw)),
|
|
30
|
-
_platformContext(std::move(platformContext)) {}
|
|
13
|
+
RNSkAndroidCanvasProvider::RNSkAndroidCanvasProvider(
|
|
14
|
+
std::shared_ptr<RNSkPlatformContext> platformContext)
|
|
15
|
+
: _platformContext(std::move(platformContext)) {}
|
|
31
16
|
|
|
32
|
-
|
|
17
|
+
RNSkAndroidCanvasProvider::~RNSkAndroidCanvasProvider() {
|
|
33
18
|
_surfaceHolder = nullptr;
|
|
34
19
|
releaseWindow();
|
|
35
20
|
}
|
|
36
21
|
|
|
37
|
-
int
|
|
22
|
+
int RNSkAndroidCanvasProvider::getWidth() {
|
|
38
23
|
if (_surfaceHolder) {
|
|
39
24
|
return _surfaceHolder->getWidth();
|
|
40
25
|
}
|
|
41
26
|
return 0;
|
|
42
27
|
}
|
|
43
28
|
|
|
44
|
-
int
|
|
29
|
+
int RNSkAndroidCanvasProvider::getHeight() {
|
|
45
30
|
if (_surfaceHolder) {
|
|
46
31
|
return _surfaceHolder->getHeight();
|
|
47
32
|
}
|
|
48
33
|
return 0;
|
|
49
34
|
}
|
|
50
35
|
|
|
51
|
-
ANativeWindow *
|
|
52
|
-
|
|
36
|
+
ANativeWindow *RNSkAndroidCanvasProvider::acquireWindow(jobject surface,
|
|
37
|
+
bool isSurface) {
|
|
53
38
|
JNIEnv *env = facebook::jni::Environment::current();
|
|
54
39
|
jobject jSurface = surface;
|
|
55
40
|
if (!isSurface) {
|
|
@@ -65,20 +50,13 @@ ANativeWindow *RNSkOpenGLCanvasProvider::acquireWindow(jobject surface,
|
|
|
65
50
|
env->DeleteLocalRef(localSurface);
|
|
66
51
|
env->DeleteLocalRef(surfaceClass);
|
|
67
52
|
jSurface = _jSurface;
|
|
68
|
-
#if !defined(SK_GRAPHITE)
|
|
69
|
-
_jSurfaceTexture = env->NewGlobalRef(surface);
|
|
70
|
-
jclass surfaceTextureClass = env->GetObjectClass(surface);
|
|
71
|
-
_updateTexImageMethod =
|
|
72
|
-
env->GetMethodID(surfaceTextureClass, "updateTexImage", "()V");
|
|
73
|
-
env->DeleteLocalRef(surfaceTextureClass);
|
|
74
|
-
#endif
|
|
75
53
|
}
|
|
76
54
|
// Acquires a reference on the window, given back by releaseWindow().
|
|
77
55
|
_window = ANativeWindow_fromSurface(env, jSurface);
|
|
78
56
|
return _window;
|
|
79
57
|
}
|
|
80
58
|
|
|
81
|
-
void
|
|
59
|
+
void RNSkAndroidCanvasProvider::releaseWindow() {
|
|
82
60
|
if (_window == nullptr && _jSurface == nullptr) {
|
|
83
61
|
return;
|
|
84
62
|
}
|
|
@@ -97,33 +75,9 @@ void RNSkOpenGLCanvasProvider::releaseWindow() {
|
|
|
97
75
|
env->DeleteGlobalRef(_jSurface);
|
|
98
76
|
_jSurface = nullptr;
|
|
99
77
|
}
|
|
100
|
-
#if !defined(SK_GRAPHITE)
|
|
101
|
-
if (_jSurfaceTexture != nullptr) {
|
|
102
|
-
env->DeleteGlobalRef(_jSurfaceTexture);
|
|
103
|
-
_jSurfaceTexture = nullptr;
|
|
104
|
-
_updateTexImageMethod = nullptr;
|
|
105
|
-
}
|
|
106
|
-
#endif
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
#if !defined(SK_GRAPHITE)
|
|
110
|
-
void RNSkOpenGLCanvasProvider::updateTexImage() {
|
|
111
|
-
if (_jSurfaceTexture) {
|
|
112
|
-
JNIEnv *env = facebook::jni::Environment::current();
|
|
113
|
-
env->CallVoidMethod(_jSurfaceTexture, _updateTexImageMethod);
|
|
114
|
-
|
|
115
|
-
// Check for exceptions
|
|
116
|
-
if (env->ExceptionCheck()) {
|
|
117
|
-
RNSkLogger::logToConsole("updateAndRelease() failed. The exception above "
|
|
118
|
-
"can safely be ignored");
|
|
119
|
-
env->ExceptionClear();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
78
|
}
|
|
123
|
-
#endif
|
|
124
79
|
|
|
125
|
-
|
|
126
|
-
void RNSkOpenGLCanvasProvider::updateTargetInfo() {
|
|
80
|
+
void RNSkAndroidCanvasProvider::updateTargetInfo() {
|
|
127
81
|
std::lock_guard<std::mutex> lock(_targetInfoMutex);
|
|
128
82
|
if (_surfaceHolder == nullptr) {
|
|
129
83
|
_hasTargetInfo = false;
|
|
@@ -137,8 +91,7 @@ void RNSkOpenGLCanvasProvider::updateTargetInfo() {
|
|
|
137
91
|
_hasTargetInfo = true;
|
|
138
92
|
}
|
|
139
93
|
|
|
140
|
-
bool
|
|
141
|
-
RNSkGraphiteTargetInfo *info) {
|
|
94
|
+
bool RNSkAndroidCanvasProvider::getTargetInfo(RNSkGraphiteTargetInfo *info) {
|
|
142
95
|
std::lock_guard<std::mutex> lock(_targetInfoMutex);
|
|
143
96
|
if (!_hasTargetInfo) {
|
|
144
97
|
return false;
|
|
@@ -147,7 +100,23 @@ bool RNSkOpenGLCanvasProvider::getGraphiteTargetInfo(
|
|
|
147
100
|
return true;
|
|
148
101
|
}
|
|
149
102
|
|
|
150
|
-
|
|
103
|
+
void RNSkAndroidCanvasProvider::setLayoutSize(int width, int height) {
|
|
104
|
+
std::lock_guard<std::mutex> lock(_targetInfoMutex);
|
|
105
|
+
_layoutWidth = width;
|
|
106
|
+
_layoutHeight = height;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
bool RNSkAndroidCanvasProvider::getLayoutSize(int *width, int *height) {
|
|
110
|
+
std::lock_guard<std::mutex> lock(_targetInfoMutex);
|
|
111
|
+
if (_layoutWidth <= 0 || _layoutHeight <= 0) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
*width = _layoutWidth;
|
|
115
|
+
*height = _layoutHeight;
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
bool RNSkAndroidCanvasProvider::presentRecordings(
|
|
151
120
|
const std::vector<skgpu::graphite::Recording *> &recordings) {
|
|
152
121
|
if (_surfaceHolder == nullptr) {
|
|
153
122
|
return false;
|
|
@@ -155,33 +124,18 @@ bool RNSkOpenGLCanvasProvider::presentRecordings(
|
|
|
155
124
|
return static_cast<DawnWindowContext *>(_surfaceHolder.get())
|
|
156
125
|
->presentRecordings(recordings);
|
|
157
126
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (_surfaceHolder != nullptr && cb != nullptr) {
|
|
163
|
-
// Get the surface
|
|
164
|
-
auto surface = _surfaceHolder->getSurface();
|
|
165
|
-
#if !defined(SK_GRAPHITE)
|
|
166
|
-
updateTexImage();
|
|
167
|
-
#endif
|
|
168
|
-
if (surface) {
|
|
169
|
-
// Draw into canvas using callback
|
|
170
|
-
cb(surface->getCanvas());
|
|
171
|
-
// Swap buffers and show on screen
|
|
172
|
-
_surfaceHolder->present();
|
|
173
|
-
return true;
|
|
174
|
-
} else {
|
|
175
|
-
// the render context did not provide a surface
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
127
|
+
|
|
128
|
+
bool RNSkAndroidCanvasProvider::presentImage(const sk_sp<SkImage> &image) {
|
|
129
|
+
if (_surfaceHolder == nullptr) {
|
|
130
|
+
return false;
|
|
178
131
|
}
|
|
179
|
-
return
|
|
132
|
+
return static_cast<DawnWindowContext *>(_surfaceHolder.get())
|
|
133
|
+
->presentImage(image);
|
|
180
134
|
}
|
|
181
135
|
|
|
182
|
-
void
|
|
183
|
-
|
|
184
|
-
|
|
136
|
+
void RNSkAndroidCanvasProvider::surfaceAvailable(jobject surface, int width,
|
|
137
|
+
int height, bool isSurface,
|
|
138
|
+
bool highBitDepth) {
|
|
185
139
|
// Release the old surface and its window
|
|
186
140
|
_surfaceHolder = nullptr;
|
|
187
141
|
releaseWindow();
|
|
@@ -192,32 +146,25 @@ void RNSkOpenGLCanvasProvider::surfaceAvailable(jobject surface, int width,
|
|
|
192
146
|
releaseWindow();
|
|
193
147
|
return;
|
|
194
148
|
}
|
|
195
|
-
#if defined(SK_GRAPHITE)
|
|
196
149
|
_surfaceHolder = DawnContext::getInstance().MakeWindow(window, width, height,
|
|
197
150
|
highBitDepth);
|
|
198
151
|
updateTargetInfo();
|
|
199
|
-
#else
|
|
200
|
-
_surfaceHolder =
|
|
201
|
-
OpenGLContext::getInstance().MakeWindow(window, highBitDepth);
|
|
202
|
-
#endif
|
|
203
152
|
|
|
204
153
|
// Post redraw request to ensure we paint in the next draw cycle.
|
|
205
|
-
|
|
154
|
+
requestRedraw();
|
|
206
155
|
}
|
|
207
156
|
|
|
208
|
-
void
|
|
157
|
+
void RNSkAndroidCanvasProvider::surfaceDestroyed() {
|
|
209
158
|
// destroy the renderer (a unique pointer so the dtor will be called
|
|
210
159
|
// immediately.)
|
|
211
160
|
_surfaceHolder = nullptr;
|
|
212
|
-
#if defined(SK_GRAPHITE)
|
|
213
161
|
updateTargetInfo();
|
|
214
|
-
#endif
|
|
215
162
|
releaseWindow();
|
|
216
163
|
}
|
|
217
164
|
|
|
218
|
-
void
|
|
219
|
-
|
|
220
|
-
|
|
165
|
+
void RNSkAndroidCanvasProvider::surfaceSizeChanged(jobject jSurface, int width,
|
|
166
|
+
int height, bool isSurface,
|
|
167
|
+
bool highBitDepth) {
|
|
221
168
|
if (width == 0 && height == 0) {
|
|
222
169
|
// Setting width/height to zero is nothing we need to care about when
|
|
223
170
|
// it comes to invalidating the surface.
|
|
@@ -228,12 +175,10 @@ void RNSkOpenGLCanvasProvider::surfaceSizeChanged(jobject jSurface, int width,
|
|
|
228
175
|
surfaceAvailable(jSurface, width, height, isSurface, highBitDepth);
|
|
229
176
|
} else {
|
|
230
177
|
_surfaceHolder->resize(width, height);
|
|
231
|
-
#if defined(SK_GRAPHITE)
|
|
232
178
|
updateTargetInfo();
|
|
233
|
-
#endif
|
|
234
179
|
}
|
|
235
180
|
|
|
236
181
|
// Redraw after size change
|
|
237
|
-
|
|
182
|
+
requestRedraw();
|
|
238
183
|
}
|
|
239
184
|
} // namespace RNSkia
|
package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.h → RNSkAndroidCanvasProvider.h}
RENAMED
|
@@ -6,35 +6,45 @@
|
|
|
6
6
|
#include <mutex>
|
|
7
7
|
#include <vector>
|
|
8
8
|
|
|
9
|
-
#include "
|
|
9
|
+
#include "RNSkCanvasProvider.h"
|
|
10
|
+
#include "RNSkPlatformContext.h"
|
|
10
11
|
#include "RNWindowContext.h"
|
|
11
12
|
|
|
12
13
|
#include <android/native_window.h>
|
|
13
14
|
|
|
14
15
|
namespace RNSkia {
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The ANativeWindow a SkiaView presents into: the Surface of a SurfaceView or
|
|
19
|
+
* a Surface created over the SurfaceTexture of a TextureView, configured as a
|
|
20
|
+
* Dawn surface (see DawnWindowContext).
|
|
21
|
+
*/
|
|
22
|
+
class RNSkAndroidCanvasProvider : public RNSkCanvasProvider {
|
|
19
23
|
public:
|
|
20
|
-
|
|
21
|
-
std::
|
|
22
|
-
std::shared_ptr<RNSkia::RNSkPlatformContext> platformContext);
|
|
24
|
+
explicit RNSkAndroidCanvasProvider(
|
|
25
|
+
std::shared_ptr<RNSkPlatformContext> platformContext);
|
|
23
26
|
|
|
24
|
-
virtual ~
|
|
27
|
+
virtual ~RNSkAndroidCanvasProvider();
|
|
25
28
|
|
|
26
29
|
int getWidth() override;
|
|
27
30
|
|
|
28
31
|
int getHeight() override;
|
|
29
32
|
|
|
30
|
-
bool
|
|
33
|
+
bool getTargetInfo(RNSkGraphiteTargetInfo *info) override;
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
bool getGraphiteTargetInfo(RNSkGraphiteTargetInfo *info) override;
|
|
35
|
+
bool getLayoutSize(int *width, int *height) override;
|
|
34
36
|
|
|
35
37
|
bool presentRecordings(
|
|
36
38
|
const std::vector<skgpu::graphite::Recording *> &recordings) override;
|
|
37
|
-
|
|
39
|
+
|
|
40
|
+
bool presentImage(const sk_sp<SkImage> &image) override;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
The pixel size the backing view was laid out with. The surface it gets
|
|
44
|
+
(SurfaceView or TextureView) has exactly this size, so a frame recorded
|
|
45
|
+
before the surface exists already matches it. Main thread.
|
|
46
|
+
*/
|
|
47
|
+
void setLayoutSize(int width, int height);
|
|
38
48
|
|
|
39
49
|
void surfaceAvailable(jobject surface, int width, int height, bool isSurface,
|
|
40
50
|
bool highBitDepth);
|
|
@@ -52,13 +62,8 @@ private:
|
|
|
52
62
|
// Gives back what acquireWindow() took. Call after the window context that
|
|
53
63
|
// draws into the window is gone.
|
|
54
64
|
void releaseWindow();
|
|
55
|
-
#if !defined(SK_GRAPHITE)
|
|
56
|
-
// Lets the SurfaceTexture of a TextureView consume the previous frame.
|
|
57
|
-
void updateTexImage();
|
|
58
|
-
#else
|
|
59
65
|
// Copies the window's target description where any thread can read it.
|
|
60
66
|
void updateTargetInfo();
|
|
61
|
-
#endif
|
|
62
67
|
|
|
63
68
|
std::unique_ptr<WindowContext> _surfaceHolder = nullptr;
|
|
64
69
|
std::shared_ptr<RNSkPlatformContext> _platformContext;
|
|
@@ -67,13 +72,10 @@ private:
|
|
|
67
72
|
// as the window and is released with it (a SurfaceView's Surface is owned by
|
|
68
73
|
// the view).
|
|
69
74
|
jobject _jSurface = nullptr;
|
|
70
|
-
#if !defined(SK_GRAPHITE)
|
|
71
|
-
jobject _jSurfaceTexture = nullptr;
|
|
72
|
-
jmethodID _updateTexImageMethod = nullptr;
|
|
73
|
-
#else
|
|
74
75
|
std::mutex _targetInfoMutex;
|
|
75
76
|
RNSkGraphiteTargetInfo _targetInfo;
|
|
76
77
|
bool _hasTargetInfo = false;
|
|
77
|
-
|
|
78
|
+
int _layoutWidth = 0;
|
|
79
|
+
int _layoutHeight = 0;
|
|
78
80
|
};
|
|
79
81
|
} // namespace RNSkia
|
|
@@ -10,11 +10,7 @@
|
|
|
10
10
|
#include <memory>
|
|
11
11
|
#include <string>
|
|
12
12
|
|
|
13
|
-
#if defined(SK_GRAPHITE)
|
|
14
13
|
#include "RNDawnContext.h"
|
|
15
|
-
#else
|
|
16
|
-
#include "OpenGLContext.h"
|
|
17
|
-
#endif
|
|
18
14
|
|
|
19
15
|
#include "AHardwareBufferUtils.h"
|
|
20
16
|
#include "JniPlatformContext.h"
|
|
@@ -54,49 +50,13 @@ public:
|
|
|
54
50
|
|
|
55
51
|
sk_sp<SkSurface> makeOffscreenSurface(int width, int height,
|
|
56
52
|
bool useP3ColorSpace = false) override {
|
|
57
|
-
#if defined(SK_GRAPHITE)
|
|
58
53
|
return DawnContext::getInstance().MakeOffscreen(width, height,
|
|
59
54
|
useP3ColorSpace);
|
|
60
|
-
#else
|
|
61
|
-
return OpenGLContext::getInstance().MakeOffscreen(width, height,
|
|
62
|
-
useP3ColorSpace);
|
|
63
|
-
#endif
|
|
64
55
|
}
|
|
65
56
|
|
|
66
57
|
sk_sp<SkImage> makeImageFromNativeBuffer(void *buffer) override {
|
|
67
|
-
#if defined(SK_GRAPHITE)
|
|
68
58
|
return DawnContext::getInstance().MakeImageFromBuffer(buffer);
|
|
69
|
-
#else
|
|
70
|
-
return OpenGLContext::getInstance().MakeImageFromBuffer(buffer);
|
|
71
|
-
#endif
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
#if !defined(SK_GRAPHITE)
|
|
75
|
-
sk_sp<SkImage> makeImageFromNativeTexture(const TextureInfo &texInfo,
|
|
76
|
-
int width, int height,
|
|
77
|
-
bool mipMapped) override {
|
|
78
|
-
GrGLTextureInfo textureInfo;
|
|
79
|
-
textureInfo.fTarget = (GrGLenum)texInfo.glTarget;
|
|
80
|
-
textureInfo.fID = (GrGLuint)texInfo.glID;
|
|
81
|
-
textureInfo.fFormat = (GrGLenum)texInfo.glFormat;
|
|
82
|
-
textureInfo.fProtected =
|
|
83
|
-
texInfo.glProtected ? skgpu::Protected::kYes : skgpu::Protected::kNo;
|
|
84
|
-
|
|
85
|
-
OpenGLContext::getInstance().makeCurrent();
|
|
86
|
-
if (glIsTexture(textureInfo.fID) == GL_FALSE) {
|
|
87
|
-
throw std::runtime_error("Invalid textureInfo");
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
GrBackendTexture backendTexture = GrBackendTextures::MakeGL(
|
|
91
|
-
width, height,
|
|
92
|
-
mipMapped ? skgpu::Mipmapped::kYes : skgpu::Mipmapped::kNo,
|
|
93
|
-
textureInfo);
|
|
94
|
-
return SkImages::BorrowTextureFrom(
|
|
95
|
-
OpenGLContext::getInstance().getDirectContext(), backendTexture,
|
|
96
|
-
kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType,
|
|
97
|
-
nullptr);
|
|
98
59
|
}
|
|
99
|
-
#endif
|
|
100
60
|
|
|
101
61
|
std::shared_ptr<RNSkVideo> createVideo(const std::string &url) override {
|
|
102
62
|
auto jniVideo = _jniPlatformContext->createVideo(url);
|
|
@@ -112,13 +72,11 @@ public:
|
|
|
112
72
|
|
|
113
73
|
uint64_t makeNativeBuffer(sk_sp<SkImage> image) override {
|
|
114
74
|
#if __ANDROID_API__ >= 26
|
|
115
|
-
#if defined(SK_GRAPHITE)
|
|
116
75
|
// A Graphite GPU texture can't be read with readPixels(nullptr); read it
|
|
117
76
|
// back to a raster image first or the buffer ends up uninitialized/black.
|
|
118
77
|
if (image && image->isTextureBacked()) {
|
|
119
78
|
image = DawnContext::getInstance().MakeRasterImage(image);
|
|
120
79
|
}
|
|
121
|
-
#endif
|
|
122
80
|
auto bytesPerPixel = image->imageInfo().bytesPerPixel();
|
|
123
81
|
int bytesPerRow = image->width() * bytesPerPixel;
|
|
124
82
|
auto buf = SkData::MakeUninitialized(image->width() * image->height() *
|
|
@@ -229,47 +187,6 @@ public:
|
|
|
229
187
|
#endif
|
|
230
188
|
}
|
|
231
189
|
|
|
232
|
-
#if !defined(SK_GRAPHITE)
|
|
233
|
-
GrDirectContext *getDirectContext() override {
|
|
234
|
-
return OpenGLContext::getInstance().getDirectContext();
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const TextureInfo getTexture(sk_sp<SkImage> image) override {
|
|
238
|
-
GrBackendTexture texture;
|
|
239
|
-
if (!SkImages::GetBackendTextureFromImage(image, &texture, true)) {
|
|
240
|
-
throw std::runtime_error("Couldn't get backend texture from image.");
|
|
241
|
-
}
|
|
242
|
-
return getTextureInfo(texture);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const TextureInfo getTexture(sk_sp<SkSurface> surface) override {
|
|
246
|
-
GrBackendTexture texture = SkSurfaces::GetBackendTexture(
|
|
247
|
-
surface.get(), SkSurface::BackendHandleAccess::kFlushRead);
|
|
248
|
-
return getTextureInfo(texture);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
static TextureInfo getTextureInfo(const GrBackendTexture &texture) {
|
|
252
|
-
|
|
253
|
-
if (!texture.isValid()) {
|
|
254
|
-
throw std::runtime_error("invalid backend texture");
|
|
255
|
-
}
|
|
256
|
-
GrGLTextureInfo textureInfo;
|
|
257
|
-
if (!GrBackendTextures::GetGLTextureInfo(texture, &textureInfo)) {
|
|
258
|
-
throw std::runtime_error("couldn't get OpenGL texture");
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
OpenGLContext::getInstance().makeCurrent();
|
|
262
|
-
glFlush();
|
|
263
|
-
|
|
264
|
-
TextureInfo texInfo;
|
|
265
|
-
texInfo.glProtected = textureInfo.isProtected();
|
|
266
|
-
texInfo.glID = textureInfo.fID;
|
|
267
|
-
texInfo.glFormat = textureInfo.fFormat;
|
|
268
|
-
texInfo.glTarget = textureInfo.fTarget;
|
|
269
|
-
return texInfo;
|
|
270
|
-
}
|
|
271
|
-
#endif
|
|
272
|
-
|
|
273
190
|
sk_sp<SkFontMgr> createFontMgr() override {
|
|
274
191
|
return SkFontMgr_New_Android(nullptr, SkFontScanner_Make_FreeType());
|
|
275
192
|
}
|
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#include "RNSkLog.h"
|
|
9
9
|
|
|
10
|
-
#if defined(SK_GRAPHITE)
|
|
11
10
|
#include "RNDawnContext.h"
|
|
12
|
-
#else
|
|
13
|
-
#include "OpenGLContext.h"
|
|
14
|
-
#endif
|
|
15
11
|
|
|
16
12
|
#pragma clang diagnostic push
|
|
17
13
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
@@ -59,11 +55,7 @@ sk_sp<SkImage> RNSkAndroidVideo::nextImage(double *timeStamp) {
|
|
|
59
55
|
// Convert jobject to AHardwareBuffer
|
|
60
56
|
AHardwareBuffer *buffer =
|
|
61
57
|
AHardwareBuffer_fromHardwareBuffer(env, jHardwareBuffer);
|
|
62
|
-
#if defined(SK_GRAPHITE)
|
|
63
58
|
return DawnContext::getInstance().MakeImageFromBuffer(buffer);
|
|
64
|
-
#else
|
|
65
|
-
return OpenGLContext::getInstance().MakeImageFromBuffer(buffer);
|
|
66
|
-
#endif
|
|
67
59
|
#else
|
|
68
60
|
return nullptr;
|
|
69
61
|
#endif
|
|
@@ -33,8 +33,7 @@ public class RNSkiaPackage extends BaseReactPackage implements ReactPackage {
|
|
|
33
33
|
@Override
|
|
34
34
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
35
35
|
return Arrays.<ViewManager>asList(
|
|
36
|
-
new
|
|
37
|
-
new SkiaGraphiteViewManager()
|
|
36
|
+
new SkiaViewManager()
|
|
38
37
|
);
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -11,12 +11,10 @@ import androidx.annotation.NonNull;
|
|
|
11
11
|
public class SkiaSurfaceView extends SurfaceView implements SurfaceHolder.Callback {
|
|
12
12
|
|
|
13
13
|
SkiaViewAPI mApi;
|
|
14
|
-
boolean mDebug;
|
|
15
14
|
|
|
16
|
-
public SkiaSurfaceView(Context context, SkiaViewAPI api, boolean
|
|
15
|
+
public SkiaSurfaceView(Context context, SkiaViewAPI api, boolean zOrderOnTop, boolean opaque) {
|
|
17
16
|
super(context);
|
|
18
17
|
mApi = api;
|
|
19
|
-
mDebug = debug;
|
|
20
18
|
// Must be set before the surface is created.
|
|
21
19
|
setZOrderOnTop(zOrderOnTop);
|
|
22
20
|
setOpaque(opaque);
|
|
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
import android.graphics.SurfaceTexture;
|
|
6
6
|
import android.util.Log;
|
|
7
|
-
import android.view.Surface;
|
|
8
7
|
import android.view.TextureView;
|
|
9
8
|
import androidx.annotation.NonNull;
|
|
10
9
|
|
|
@@ -14,23 +13,16 @@ public class SkiaTextureView extends TextureView implements TextureView.SurfaceT
|
|
|
14
13
|
private String tag = "SkiaTextureView";
|
|
15
14
|
|
|
16
15
|
SkiaViewAPI mApi;
|
|
17
|
-
boolean mDebug;
|
|
18
16
|
|
|
19
|
-
public SkiaTextureView(Context context, SkiaViewAPI api, boolean
|
|
17
|
+
public SkiaTextureView(Context context, SkiaViewAPI api, boolean opaque) {
|
|
20
18
|
super(context);
|
|
21
19
|
mApi = api;
|
|
22
|
-
mDebug = debug;
|
|
23
20
|
// An opaque TextureView lets the UI toolkit skip blending it; it can be
|
|
24
21
|
// toggled on a live view.
|
|
25
22
|
setOpaque(opaque);
|
|
26
23
|
setSurfaceTextureListener(this);
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
@Override
|
|
30
|
-
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
31
|
-
super.onLayout(changed, left, top, right, bottom);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
26
|
@Override
|
|
35
27
|
public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surfaceTexture, int width, int height) {
|
|
36
28
|
Log.i(tag, "onSurfaceTextureAvailable: " + width + "x" + height);
|
|
@@ -49,15 +41,7 @@ public class SkiaTextureView extends TextureView implements TextureView.SurfaceT
|
|
|
49
41
|
return true;
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
private long _prevTimestamp = 0;
|
|
53
44
|
@Override
|
|
54
45
|
public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) {
|
|
55
|
-
if (!mDebug) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
long timestamp = surface.getTimestamp();
|
|
59
|
-
long frameDuration = (timestamp - _prevTimestamp)/1000000;
|
|
60
|
-
Log.i("SkiaTextureView", "onSurfaceTextureUpdated "+frameDuration+"ms");
|
|
61
|
-
_prevTimestamp = timestamp;
|
|
62
46
|
}
|
|
63
47
|
}
|