@shopify/react-native-skia 1.5.10 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/android/cpp/jni/include/JniSkiaBaseView.h +6 -5
- package/android/cpp/jni/include/JniSkiaDomView.h +6 -4
- package/android/cpp/jni/include/JniSkiaManager.h +2 -2
- package/android/cpp/jni/include/JniSkiaPictureView.h +6 -4
- package/android/cpp/rnskia-android/MainThreadDispatcher.h +3 -0
- package/android/cpp/rnskia-android/OpenGLContext.h +44 -9
- package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +0 -1
- package/android/cpp/rnskia-android/OpenGLWindowContext.h +2 -2
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +61 -3
- package/android/cpp/rnskia-android/RNSkAndroidView.h +10 -13
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +42 -36
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +2 -2
- package/android/cpp/rnskia-android/gl/Display.h +2 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaAHBView.java +113 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +45 -54
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +5 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomView.java +2 -2
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaPictureView.java +2 -2
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaSurfaceView.java +42 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaTextureView.java +90 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaViewAPI.java +16 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java +3 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java +1 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaPictureViewManagerDelegate.java +3 -1
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaPictureViewManagerInterface.java +1 -0
- package/cpp/api/JsiSkContourMeasure.h +1 -5
- package/cpp/api/JsiSkImage.h +11 -0
- package/cpp/api/JsiSkImageFactory.h +14 -0
- package/cpp/api/JsiSkPicture.h +2 -0
- package/cpp/api/JsiSkSurface.h +7 -0
- package/cpp/api/JsiTextureInfo.h +53 -0
- package/cpp/jsi/ViewProperty.h +48 -0
- package/cpp/rnskia/RNSkDomView.cpp +0 -20
- package/cpp/rnskia/RNSkDomView.h +4 -9
- package/cpp/rnskia/RNSkJsiViewApi.h +3 -3
- package/cpp/rnskia/RNSkPictureView.h +11 -28
- package/cpp/rnskia/RNSkPlatformContext.h +18 -12
- package/cpp/rnskia/RNSkView.h +5 -29
- package/ios/RNSkia-iOS/MetalContext.h +101 -15
- package/ios/RNSkia-iOS/MetalContext.mm +9 -8
- package/ios/RNSkia-iOS/MetalWindowContext.h +39 -0
- package/ios/RNSkia-iOS/MetalWindowContext.mm +60 -0
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +13 -25
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +88 -2
- package/ios/RNSkia-iOS/SkiaCVPixelBufferUtils.mm +9 -2
- package/ios/RNSkia-iOS/SkiaDomViewManager.mm +5 -0
- package/ios/RNSkia-iOS/SkiaManager.mm +1 -2
- package/ios/RNSkia-iOS/SkiaPictureView.mm +1 -0
- package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +5 -0
- package/ios/RNSkia-iOS/SkiaUIView.h +1 -0
- package/ios/RNSkia-iOS/SkiaUIView.mm +21 -14
- package/lib/commonjs/skia/types/Image/ColorType.d.ts +21 -0
- package/lib/commonjs/skia/types/Image/ColorType.js +29 -0
- package/lib/commonjs/skia/types/Image/ColorType.js.map +1 -0
- package/lib/commonjs/skia/types/Image/ColorType.web.d.ts +19 -0
- package/lib/commonjs/skia/types/Image/ColorType.web.js +27 -0
- package/lib/commonjs/skia/types/Image/ColorType.web.js.map +1 -0
- package/lib/commonjs/skia/types/Image/Image.d.ts +10 -0
- package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +19 -19
- package/lib/commonjs/skia/types/Image/ImageFactory.js +1 -21
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Image/index.d.ts +1 -0
- package/lib/commonjs/skia/types/Image/index.js +11 -0
- package/lib/commonjs/skia/types/Image/index.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +6 -0
- package/lib/commonjs/skia/types/Matrix4.js +69 -1
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/Surface.d.ts +11 -0
- package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkImage.js +4 -0
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +3 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkSurface.js +4 -0
- package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.js +3 -1
- package/lib/commonjs/views/SkiaDomView.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.js +5 -1
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +2 -0
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/skia/types/Image/ColorType.d.ts +21 -0
- package/lib/module/skia/types/Image/ColorType.js +23 -0
- package/lib/module/skia/types/Image/ColorType.js.map +1 -0
- package/lib/module/skia/types/Image/ColorType.web.d.ts +19 -0
- package/lib/module/skia/types/Image/ColorType.web.js +21 -0
- package/lib/module/skia/types/Image/ColorType.web.js.map +1 -0
- package/lib/module/skia/types/Image/Image.d.ts +10 -0
- package/lib/module/skia/types/Image/Image.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +19 -19
- package/lib/module/skia/types/Image/ImageFactory.js +0 -20
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Image/index.d.ts +1 -0
- package/lib/module/skia/types/Image/index.js +1 -0
- package/lib/module/skia/types/Image/index.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +6 -0
- package/lib/module/skia/types/Matrix4.js +67 -0
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/skia/types/Surface/Surface.d.ts +11 -0
- package/lib/module/skia/types/Surface/Surface.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/module/skia/web/JsiSkImage.js +4 -0
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +1 -0
- package/lib/module/skia/web/JsiSkImageFactory.js +3 -0
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/module/skia/web/JsiSkSurface.js +4 -0
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
- package/lib/module/views/SkiaDomView.js +3 -1
- package/lib/module/views/SkiaDomView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.js +5 -1
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/types.d.ts +2 -0
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/types/Image/ColorType.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/types/Image/ColorType.web.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/types/Image/ImageFactory.d.ts +0 -1
- package/lib/typescript/lib/commonjs/skia/types/Matrix4.d.ts +6 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/typescript/lib/module/mock/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Image/ColorType.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Image/ColorType.web.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Image/ImageFactory.d.ts +0 -1
- package/lib/typescript/lib/module/skia/types/Image/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Matrix4.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/typescript/src/skia/types/Image/ColorType.d.ts +21 -0
- package/lib/typescript/src/skia/types/Image/ColorType.web.d.ts +19 -0
- package/lib/typescript/src/skia/types/Image/Image.d.ts +10 -0
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +19 -19
- package/lib/typescript/src/skia/types/Image/index.d.ts +1 -0
- package/lib/typescript/src/skia/types/Matrix4.d.ts +6 -0
- package/lib/typescript/src/skia/types/Surface/Surface.d.ts +11 -0
- package/lib/typescript/src/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
- package/lib/typescript/src/views/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/renderer/__tests__/e2e/Matrix4.spec.tsx +93 -0
- package/src/skia/__tests__/Enums.spec.ts +2 -2
- package/src/skia/types/Image/ColorType.ts +21 -0
- package/src/skia/types/Image/ColorType.web.ts +19 -0
- package/src/skia/types/Image/Image.ts +11 -0
- package/src/skia/types/Image/ImageFactory.ts +25 -20
- package/src/skia/types/Image/index.ts +1 -0
- package/src/skia/types/Matrix4.ts +101 -0
- package/src/skia/types/Surface/Surface.ts +12 -0
- package/src/skia/web/JsiSkImage.ts +5 -0
- package/src/skia/web/JsiSkImageFactory.ts +4 -0
- package/src/skia/web/JsiSkSurface.ts +5 -0
- package/src/specs/SkiaPictureViewNativeComponent.ts +1 -0
- package/src/views/SkiaDomView.tsx +2 -1
- package/src/views/SkiaPictureView.tsx +4 -1
- package/src/views/types.ts +3 -0
- package/cpp/jsi/JsiValueWrapper.h +0 -164
- package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.h +0 -128
- package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.mm +0 -92
@@ -1,128 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#import <MetalKit/MetalKit.h>
|
4
|
-
|
5
|
-
#include <memory>
|
6
|
-
|
7
|
-
#include "RNSkLog.h"
|
8
|
-
#include "WindowContext.h"
|
9
|
-
|
10
|
-
#pragma clang diagnostic push
|
11
|
-
#pragma clang diagnostic ignored "-Wdocumentation"
|
12
|
-
|
13
|
-
#import "include/core/SkCanvas.h"
|
14
|
-
#import "include/core/SkColorSpace.h"
|
15
|
-
|
16
|
-
#import <CoreMedia/CMSampleBuffer.h>
|
17
|
-
#import <CoreVideo/CVMetalTextureCache.h>
|
18
|
-
|
19
|
-
#import <include/gpu/ganesh/GrBackendSurface.h>
|
20
|
-
#import <include/gpu/ganesh/GrDirectContext.h>
|
21
|
-
#import <include/gpu/ganesh/SkImageGanesh.h>
|
22
|
-
#import <include/gpu/ganesh/SkSurfaceGanesh.h>
|
23
|
-
#import <include/gpu/ganesh/mtl/GrMtlBackendContext.h>
|
24
|
-
#import <include/gpu/ganesh/mtl/GrMtlBackendSurface.h>
|
25
|
-
#import <include/gpu/ganesh/mtl/GrMtlDirectContext.h>
|
26
|
-
#import <include/gpu/ganesh/mtl/SkSurfaceMetal.h>
|
27
|
-
|
28
|
-
#pragma clang diagnostic pop
|
29
|
-
|
30
|
-
using SkiaMetalContext = struct SkiaMetalContext {
|
31
|
-
id<MTLCommandQueue> commandQueue = nullptr;
|
32
|
-
sk_sp<GrDirectContext> skContext = nullptr;
|
33
|
-
};
|
34
|
-
|
35
|
-
class SkiaMetalSurfaceFactory {
|
36
|
-
friend class IOSSkiaContext;
|
37
|
-
|
38
|
-
public:
|
39
|
-
static sk_sp<SkSurface> makeOffscreenSurface(id<MTLDevice> device,
|
40
|
-
SkiaMetalContext *context,
|
41
|
-
int width, int height);
|
42
|
-
|
43
|
-
static sk_sp<SkImage>
|
44
|
-
makeTextureFromCVPixelBuffer(SkiaMetalContext *context,
|
45
|
-
CVPixelBufferRef pixelBuffer);
|
46
|
-
|
47
|
-
static std::unique_ptr<RNSkia::WindowContext>
|
48
|
-
makeContext(SkiaMetalContext *context, CALayer *texture, int width,
|
49
|
-
int height);
|
50
|
-
};
|
51
|
-
|
52
|
-
class IOSSkiaContext : public RNSkia::WindowContext {
|
53
|
-
public:
|
54
|
-
IOSSkiaContext(SkiaMetalContext *context, CALayer *layer, int width,
|
55
|
-
int height)
|
56
|
-
: _context(context) {
|
57
|
-
#pragma clang diagnostic push
|
58
|
-
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
59
|
-
_layer = (CAMetalLayer *)layer;
|
60
|
-
#pragma clang diagnostic pop
|
61
|
-
_layer.framebufferOnly = NO;
|
62
|
-
_layer.device = MTLCreateSystemDefaultDevice();
|
63
|
-
_layer.opaque = false;
|
64
|
-
_layer.contentsScale = [UIScreen mainScreen].scale;
|
65
|
-
_layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
66
|
-
_layer.contentsGravity = kCAGravityBottomLeft;
|
67
|
-
_layer.drawableSize = CGSizeMake(width, height);
|
68
|
-
}
|
69
|
-
|
70
|
-
~IOSSkiaContext() {}
|
71
|
-
|
72
|
-
sk_sp<SkSurface> getSurface() override {
|
73
|
-
if (_skSurface) {
|
74
|
-
return _skSurface;
|
75
|
-
}
|
76
|
-
|
77
|
-
// Get the next drawable from the CAMetalLayer
|
78
|
-
_currentDrawable = [_layer nextDrawable];
|
79
|
-
if (!_currentDrawable) {
|
80
|
-
RNSkia::RNSkLogger::logToConsole(
|
81
|
-
"Could not retrieve drawable from CAMetalLayer");
|
82
|
-
return nullptr;
|
83
|
-
}
|
84
|
-
|
85
|
-
// Get the texture from the drawable
|
86
|
-
GrMtlTextureInfo fbInfo;
|
87
|
-
fbInfo.fTexture.retain((__bridge void *)_currentDrawable.texture);
|
88
|
-
|
89
|
-
GrBackendRenderTarget backendRT = GrBackendRenderTargets::MakeMtl(
|
90
|
-
_layer.drawableSize.width, _layer.drawableSize.height, fbInfo);
|
91
|
-
|
92
|
-
_skSurface = SkSurfaces::WrapBackendRenderTarget(
|
93
|
-
_context->skContext.get(), backendRT, kTopLeft_GrSurfaceOrigin,
|
94
|
-
kBGRA_8888_SkColorType, nullptr, nullptr);
|
95
|
-
|
96
|
-
return _skSurface;
|
97
|
-
}
|
98
|
-
|
99
|
-
void present() override {
|
100
|
-
if (auto dContext = GrAsDirectContext(_skSurface->recordingContext())) {
|
101
|
-
dContext->flushAndSubmit();
|
102
|
-
}
|
103
|
-
|
104
|
-
id<MTLCommandBuffer> commandBuffer([_context->commandQueue commandBuffer]);
|
105
|
-
[commandBuffer presentDrawable:_currentDrawable];
|
106
|
-
[commandBuffer commit];
|
107
|
-
_skSurface = nullptr;
|
108
|
-
}
|
109
|
-
|
110
|
-
int getWidth() override {
|
111
|
-
return _layer.frame.size.width * _layer.contentsScale;
|
112
|
-
};
|
113
|
-
|
114
|
-
int getHeight() override {
|
115
|
-
return _layer.frame.size.height * _layer.contentsScale;
|
116
|
-
};
|
117
|
-
|
118
|
-
void resize(int width, int height) override { _skSurface = nullptr; }
|
119
|
-
|
120
|
-
private:
|
121
|
-
SkiaMetalContext *_context;
|
122
|
-
sk_sp<SkSurface> _skSurface = nullptr;
|
123
|
-
#pragma clang diagnostic push
|
124
|
-
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
125
|
-
CAMetalLayer *_layer;
|
126
|
-
#pragma clang diagnostic pop
|
127
|
-
id<CAMetalDrawable> _currentDrawable = nil;
|
128
|
-
};
|
@@ -1,92 +0,0 @@
|
|
1
|
-
#import "RNSkLog.h"
|
2
|
-
|
3
|
-
#import "SkiaCVPixelBufferUtils.h"
|
4
|
-
#import "SkiaMetalSurfaceFactory.h"
|
5
|
-
|
6
|
-
#pragma clang diagnostic push
|
7
|
-
#pragma clang diagnostic ignored "-Wdocumentation"
|
8
|
-
|
9
|
-
#import "include/core/SkCanvas.h"
|
10
|
-
#import "include/core/SkColorSpace.h"
|
11
|
-
#import "include/core/SkSurface.h"
|
12
|
-
|
13
|
-
#import <include/gpu/ganesh/GrBackendSurface.h>
|
14
|
-
#import <include/gpu/ganesh/GrDirectContext.h>
|
15
|
-
#import <include/gpu/ganesh/SkImageGanesh.h>
|
16
|
-
#import <include/gpu/ganesh/SkSurfaceGanesh.h>
|
17
|
-
#import <include/gpu/ganesh/mtl/GrMtlBackendContext.h>
|
18
|
-
#import <include/gpu/ganesh/mtl/GrMtlBackendSurface.h>
|
19
|
-
#import <include/gpu/ganesh/mtl/GrMtlDirectContext.h>
|
20
|
-
#import <include/gpu/ganesh/mtl/SkSurfaceMetal.h>
|
21
|
-
|
22
|
-
#pragma clang diagnostic pop
|
23
|
-
|
24
|
-
struct OffscreenRenderContext {
|
25
|
-
id<MTLTexture> texture;
|
26
|
-
|
27
|
-
OffscreenRenderContext(id<MTLDevice> device,
|
28
|
-
sk_sp<GrDirectContext> skiaContext,
|
29
|
-
id<MTLCommandQueue> commandQueue, int width,
|
30
|
-
int height) {
|
31
|
-
// Create a Metal texture descriptor
|
32
|
-
MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor
|
33
|
-
texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
|
34
|
-
width:width
|
35
|
-
height:height
|
36
|
-
mipmapped:NO];
|
37
|
-
textureDescriptor.usage =
|
38
|
-
MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
|
39
|
-
texture = [device newTextureWithDescriptor:textureDescriptor];
|
40
|
-
}
|
41
|
-
};
|
42
|
-
|
43
|
-
std::unique_ptr<RNSkia::WindowContext>
|
44
|
-
SkiaMetalSurfaceFactory::makeContext(SkiaMetalContext *context,
|
45
|
-
CALayer *texture, int width, int height) {
|
46
|
-
return std::make_unique<IOSSkiaContext>(context, texture, width, height);
|
47
|
-
}
|
48
|
-
|
49
|
-
sk_sp<SkSurface> SkiaMetalSurfaceFactory::makeOffscreenSurface(
|
50
|
-
id<MTLDevice> device, SkiaMetalContext *context, int width, int height) {
|
51
|
-
|
52
|
-
auto ctx = new OffscreenRenderContext(device, context->skContext,
|
53
|
-
context->commandQueue, width, height);
|
54
|
-
|
55
|
-
// Create a GrBackendTexture from the Metal texture
|
56
|
-
GrMtlTextureInfo info;
|
57
|
-
info.fTexture.retain((__bridge void *)ctx->texture);
|
58
|
-
GrBackendTexture backendTexture =
|
59
|
-
GrBackendTextures::MakeMtl(width, height, skgpu::Mipmapped::kNo, info);
|
60
|
-
|
61
|
-
// Create a SkSurface from the GrBackendTexture
|
62
|
-
auto surface = SkSurfaces::WrapBackendTexture(
|
63
|
-
context->skContext.get(), backendTexture, kTopLeft_GrSurfaceOrigin, 0,
|
64
|
-
kBGRA_8888_SkColorType, nullptr, nullptr,
|
65
|
-
[](void *addr) { delete (OffscreenRenderContext *)addr; }, ctx);
|
66
|
-
|
67
|
-
return surface;
|
68
|
-
}
|
69
|
-
|
70
|
-
sk_sp<SkImage> SkiaMetalSurfaceFactory::makeTextureFromCVPixelBuffer(
|
71
|
-
SkiaMetalContext *context, CVPixelBufferRef pixelBuffer) {
|
72
|
-
SkiaCVPixelBufferUtils::CVPixelBufferBaseFormat format =
|
73
|
-
SkiaCVPixelBufferUtils::getCVPixelBufferBaseFormat(pixelBuffer);
|
74
|
-
switch (format) {
|
75
|
-
case SkiaCVPixelBufferUtils::CVPixelBufferBaseFormat::rgb: {
|
76
|
-
// CVPixelBuffer is in any RGB format, single-plane
|
77
|
-
return SkiaCVPixelBufferUtils::RGB::makeSkImageFromCVPixelBuffer(
|
78
|
-
context->skContext.get(), pixelBuffer);
|
79
|
-
}
|
80
|
-
case SkiaCVPixelBufferUtils::CVPixelBufferBaseFormat::yuv: {
|
81
|
-
// CVPixelBuffer is in any YUV format, multi-plane
|
82
|
-
return SkiaCVPixelBufferUtils::YUV::makeSkImageFromCVPixelBuffer(
|
83
|
-
context->skContext.get(), pixelBuffer);
|
84
|
-
}
|
85
|
-
default:
|
86
|
-
[[unlikely]] {
|
87
|
-
throw std::runtime_error("Failed to convert NativeBuffer to SkImage - "
|
88
|
-
"NativeBuffer has unsupported PixelFormat! " +
|
89
|
-
std::to_string(static_cast<int>(format)));
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|