@shopify/react-native-skia 1.5.10 → 1.6.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.
Files changed (94) hide show
  1. package/android/cpp/jni/include/JniSkiaBaseView.h +6 -4
  2. package/android/cpp/jni/include/JniSkiaDomView.h +6 -4
  3. package/android/cpp/jni/include/JniSkiaPictureView.h +6 -4
  4. package/android/cpp/rnskia-android/MainThreadDispatcher.h +5 -0
  5. package/android/cpp/rnskia-android/OpenGLContext.h +37 -10
  6. package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +0 -1
  7. package/android/cpp/rnskia-android/RNSkAndroidView.h +10 -9
  8. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +42 -36
  9. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +2 -2
  10. package/android/src/main/java/com/shopify/reactnative/skia/SkiaAHBView.java +113 -0
  11. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +45 -54
  12. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +5 -0
  13. package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomView.java +2 -2
  14. package/android/src/main/java/com/shopify/reactnative/skia/SkiaPictureView.java +2 -2
  15. package/android/src/main/java/com/shopify/reactnative/skia/SkiaSurfaceView.java +42 -0
  16. package/android/src/main/java/com/shopify/reactnative/skia/SkiaTextureView.java +90 -0
  17. package/android/src/main/java/com/shopify/reactnative/skia/SkiaViewAPI.java +16 -0
  18. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java +3 -0
  19. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java +1 -0
  20. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaPictureViewManagerDelegate.java +3 -1
  21. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaPictureViewManagerInterface.java +1 -0
  22. package/cpp/rnskia/RNSkDomView.cpp +0 -20
  23. package/cpp/rnskia/RNSkDomView.h +0 -2
  24. package/cpp/rnskia/RNSkPictureView.h +5 -12
  25. package/cpp/rnskia/RNSkView.h +3 -21
  26. package/ios/RNSkia-iOS/SkiaCVPixelBufferUtils.mm +4 -8
  27. package/ios/RNSkia-iOS/SkiaDomViewManager.mm +5 -0
  28. package/ios/RNSkia-iOS/SkiaPictureView.mm +1 -0
  29. package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +5 -0
  30. package/ios/RNSkia-iOS/SkiaUIView.h +1 -0
  31. package/ios/RNSkia-iOS/SkiaUIView.mm +5 -0
  32. package/lib/commonjs/skia/types/Image/ColorType.d.ts +21 -0
  33. package/lib/commonjs/skia/types/Image/ColorType.js +29 -0
  34. package/lib/commonjs/skia/types/Image/ColorType.js.map +1 -0
  35. package/lib/commonjs/skia/types/Image/ColorType.web.d.ts +19 -0
  36. package/lib/commonjs/skia/types/Image/ColorType.web.js +27 -0
  37. package/lib/commonjs/skia/types/Image/ColorType.web.js.map +1 -0
  38. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +1 -19
  39. package/lib/commonjs/skia/types/Image/ImageFactory.js +1 -21
  40. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  41. package/lib/commonjs/skia/types/Image/index.d.ts +1 -0
  42. package/lib/commonjs/skia/types/Image/index.js +11 -0
  43. package/lib/commonjs/skia/types/Image/index.js.map +1 -1
  44. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
  45. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  46. package/lib/commonjs/views/SkiaDomView.js +3 -1
  47. package/lib/commonjs/views/SkiaDomView.js.map +1 -1
  48. package/lib/commonjs/views/SkiaPictureView.js +5 -1
  49. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  50. package/lib/commonjs/views/types.d.ts +2 -0
  51. package/lib/commonjs/views/types.js.map +1 -1
  52. package/lib/module/skia/types/Image/ColorType.d.ts +21 -0
  53. package/lib/module/skia/types/Image/ColorType.js +23 -0
  54. package/lib/module/skia/types/Image/ColorType.js.map +1 -0
  55. package/lib/module/skia/types/Image/ColorType.web.d.ts +19 -0
  56. package/lib/module/skia/types/Image/ColorType.web.js +21 -0
  57. package/lib/module/skia/types/Image/ColorType.web.js.map +1 -0
  58. package/lib/module/skia/types/Image/ImageFactory.d.ts +1 -19
  59. package/lib/module/skia/types/Image/ImageFactory.js +0 -20
  60. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  61. package/lib/module/skia/types/Image/index.d.ts +1 -0
  62. package/lib/module/skia/types/Image/index.js +1 -0
  63. package/lib/module/skia/types/Image/index.js.map +1 -1
  64. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
  65. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  66. package/lib/module/views/SkiaDomView.js +3 -1
  67. package/lib/module/views/SkiaDomView.js.map +1 -1
  68. package/lib/module/views/SkiaPictureView.js +5 -1
  69. package/lib/module/views/SkiaPictureView.js.map +1 -1
  70. package/lib/module/views/types.d.ts +2 -0
  71. package/lib/module/views/types.js.map +1 -1
  72. package/lib/typescript/lib/commonjs/skia/types/Image/ColorType.d.ts +2 -0
  73. package/lib/typescript/lib/commonjs/skia/types/Image/ColorType.web.d.ts +2 -0
  74. package/lib/typescript/lib/commonjs/skia/types/Image/ImageFactory.d.ts +0 -1
  75. package/lib/typescript/lib/module/skia/types/Image/ColorType.d.ts +1 -0
  76. package/lib/typescript/lib/module/skia/types/Image/ColorType.web.d.ts +1 -0
  77. package/lib/typescript/lib/module/skia/types/Image/ImageFactory.d.ts +0 -1
  78. package/lib/typescript/lib/module/skia/types/Image/index.d.ts +1 -0
  79. package/lib/typescript/src/skia/types/Image/ColorType.d.ts +21 -0
  80. package/lib/typescript/src/skia/types/Image/ColorType.web.d.ts +19 -0
  81. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +1 -19
  82. package/lib/typescript/src/skia/types/Image/index.d.ts +1 -0
  83. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
  84. package/lib/typescript/src/views/types.d.ts +2 -0
  85. package/package.json +1 -1
  86. package/src/skia/__tests__/Enums.spec.ts +2 -2
  87. package/src/skia/types/Image/ColorType.ts +21 -0
  88. package/src/skia/types/Image/ColorType.web.ts +19 -0
  89. package/src/skia/types/Image/ImageFactory.ts +1 -20
  90. package/src/skia/types/Image/index.ts +1 -0
  91. package/src/specs/SkiaPictureViewNativeComponent.ts +1 -0
  92. package/src/views/SkiaDomView.tsx +2 -1
  93. package/src/views/SkiaPictureView.tsx +4 -1
  94. package/src/views/types.ts +3 -0
@@ -0,0 +1,42 @@
1
+ package com.shopify.reactnative.skia;
2
+
3
+ import android.annotation.SuppressLint;
4
+ import android.content.Context;
5
+ import android.view.SurfaceHolder;
6
+ import android.view.SurfaceView;
7
+ import androidx.annotation.NonNull;
8
+
9
+ @SuppressLint("ViewConstructor")
10
+ public class SkiaSurfaceView extends SurfaceView implements SurfaceHolder.Callback {
11
+
12
+ SkiaViewAPI mApi;
13
+ boolean mDebug;
14
+
15
+ public SkiaSurfaceView(Context context, SkiaViewAPI api, boolean debug) {
16
+ super(context);
17
+ mApi = api;
18
+ mDebug = debug;
19
+ getHolder().addCallback(this);
20
+ }
21
+
22
+ @Override
23
+ protected void onDetachedFromWindow() {
24
+ super.onDetachedFromWindow();
25
+ mApi.onSurfaceDestroyed();
26
+ }
27
+
28
+ @Override
29
+ public void surfaceCreated(@NonNull SurfaceHolder holder) {
30
+ mApi.onSurfaceCreated(holder.getSurface(), getWidth(), getHeight());
31
+ }
32
+
33
+ @Override
34
+ public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) {
35
+ mApi.onSurfaceChanged(holder.getSurface(), getWidth(), getHeight());
36
+ }
37
+
38
+ @Override
39
+ public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
40
+ mApi.onSurfaceDestroyed();
41
+ }
42
+ }
@@ -0,0 +1,90 @@
1
+ package com.shopify.reactnative.skia;
2
+
3
+ import android.annotation.SuppressLint;
4
+ import android.content.Context;
5
+ import android.graphics.SurfaceTexture;
6
+ import android.util.Log;
7
+ import android.view.Surface;
8
+ import android.view.TextureView;
9
+ import androidx.annotation.NonNull;
10
+
11
+ @SuppressLint("ViewConstructor")
12
+ public class SkiaTextureView extends TextureView implements TextureView.SurfaceTextureListener {
13
+
14
+ private String tag = "SkiaTextureView";
15
+
16
+ SkiaViewAPI mApi;
17
+ boolean mDebug;
18
+ boolean pristine = true;
19
+
20
+ public boolean isDropped = false;
21
+
22
+ public SkiaTextureView(Context context, SkiaViewAPI api, boolean debug) {
23
+ super(context);
24
+ mApi = api;
25
+ mDebug = debug;
26
+ setOpaque(false);
27
+ setSurfaceTextureListener(this);
28
+ }
29
+
30
+ public void createSurfaceTexture() {
31
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
32
+ Log.i(tag, "Create SurfaceTexture");
33
+ SurfaceTexture surfaceTexture = new SurfaceTexture(false);
34
+ setSurfaceTexture(surfaceTexture);
35
+ onSurfaceTextureAvailable(surfaceTexture, getWidth(), getHeight());
36
+ }
37
+ }
38
+
39
+ private void reCreateSurfaceTexture() {
40
+ boolean surfaceIsAlreadyAvailable = getSurfaceTexture() != null;
41
+ if (surfaceIsAlreadyAvailable) {
42
+ createSurfaceTexture();
43
+ }
44
+ }
45
+
46
+ @Override
47
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
48
+ super.onLayout(changed, left, top, right, bottom);
49
+ }
50
+
51
+ @Override
52
+ public void onSurfaceTextureAvailable(@NonNull SurfaceTexture surfaceTexture, int width, int height) {
53
+ Log.i(tag, "onSurfaceTextureAvailable: " + width + "x" + height);
54
+ mApi.onSurfaceTextureCreated(surfaceTexture, width, height);
55
+ }
56
+
57
+ @Override
58
+ public void onSurfaceTextureSizeChanged(@NonNull SurfaceTexture surfaceTexture, int width, int height) {
59
+ Log.i(tag, "onSurfaceTextureSizeChanged: " + width + "x" + height);
60
+ if (isDropped) {
61
+ return;
62
+ }
63
+ mApi.onSurfaceTextureCreated(surfaceTexture, width, height);
64
+ }
65
+
66
+ @Override
67
+ public boolean onSurfaceTextureDestroyed(@NonNull SurfaceTexture surfaceTexture) {
68
+ mApi.onSurfaceDestroyed();
69
+ // Because of React Native Screens (which dettach the view), we always keep the surface alive.
70
+ // If not, Texture view will recreate the texture surface by itself and
71
+ // we will lose the fast first time to frame.
72
+ // We only delete the surface when the view is dropped (destroySurface invoked by SkiaBaseViewManager);
73
+ if (!isDropped) {
74
+ reCreateSurfaceTexture();
75
+ }
76
+ return false;
77
+ }
78
+
79
+ private long _prevTimestamp = 0;
80
+ @Override
81
+ public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) {
82
+ if (!mDebug) {
83
+ return;
84
+ }
85
+ long timestamp = surface.getTimestamp();
86
+ long frameDuration = (timestamp - _prevTimestamp)/1000000;
87
+ Log.i("SkiaTextureView", "onSurfaceTextureUpdated "+frameDuration+"ms");
88
+ _prevTimestamp = timestamp;
89
+ }
90
+ }
@@ -0,0 +1,16 @@
1
+ package com.shopify.reactnative.skia;
2
+
3
+ import android.graphics.SurfaceTexture;
4
+ import android.view.Surface;
5
+
6
+ public interface SkiaViewAPI {
7
+ void onSurfaceCreated(Surface surface, int width, int height);
8
+
9
+ void onSurfaceChanged(Surface surface, int width, int height);
10
+
11
+ void onSurfaceTextureCreated(SurfaceTexture surface, int width, int height);
12
+
13
+ void onSurfaceTextureChanged(SurfaceTexture surface, int width, int height);
14
+
15
+ void onSurfaceDestroyed();
16
+ }
@@ -21,6 +21,9 @@ public class SkiaDomViewManagerDelegate<T extends View, U extends BaseViewManage
21
21
  @Override
22
22
  public void setProperty(T view, String propName, @Nullable Object value) {
23
23
  switch (propName) {
24
+ case "opaque":
25
+ mViewManager.setOpaque(view, value != null && (boolean) value);
26
+ break;
24
27
  case "debug":
25
28
  mViewManager.setDebug(view, value != null && (boolean) value);
26
29
  break;
@@ -14,4 +14,5 @@ import androidx.annotation.Nullable;
14
14
 
15
15
  public interface SkiaDomViewManagerInterface<T extends View> {
16
16
  void setDebug(T view, boolean value);
17
+ void setOpaque(T view, boolean value);
17
18
  }
@@ -24,8 +24,10 @@ public class SkiaPictureViewManagerDelegate<T extends View, U extends BaseViewMa
24
24
  case "mode":
25
25
  mViewManager.setMode(view, value == null ? null : (String) value);
26
26
  break;
27
+ case "opaque":
28
+ mViewManager.setOpaque(view, value != null && (boolean) value);
27
29
  case "debug":
28
- mViewManager.setDebug(view, value == null ? false : (boolean) value);
30
+ mViewManager.setDebug(view, value != null && (boolean) value);
29
31
  break;
30
32
  default:
31
33
  super.setProperty(view, propName, value);
@@ -15,4 +15,5 @@ import androidx.annotation.Nullable;
15
15
  public interface SkiaPictureViewManagerInterface<T extends View> {
16
16
  void setMode(T view, @Nullable String value);
17
17
  void setDebug(T view, boolean value);
18
+ void setOpaque(T view, boolean value);
18
19
  }
@@ -26,26 +26,6 @@ RNSkDomRenderer::~RNSkDomRenderer() {
26
26
  }
27
27
  }
28
28
 
29
- bool RNSkDomRenderer::tryRender(
30
- std::shared_ptr<RNSkCanvasProvider> canvasProvider) {
31
-
32
- // We render on the main thread
33
- if (_renderLock->try_lock()) {
34
- bool result = false;
35
- // If we have a Dom Node we can render directly on the main thread
36
- if (_root != nullptr) {
37
- result = canvasProvider->renderToCanvas(std::bind(
38
- &RNSkDomRenderer::renderCanvas, this, std::placeholders::_1,
39
- canvasProvider->getScaledWidth(), canvasProvider->getScaledHeight()));
40
- }
41
-
42
- _renderLock->unlock();
43
- return result;
44
- } else {
45
- return false;
46
- }
47
- }
48
-
49
29
  void RNSkDomRenderer::renderImmediate(
50
30
  std::shared_ptr<RNSkCanvasProvider> canvasProvider) {
51
31
  auto prevDebugOverlay = getShowDebugOverlays();
@@ -42,8 +42,6 @@ public:
42
42
 
43
43
  ~RNSkDomRenderer();
44
44
 
45
- bool tryRender(std::shared_ptr<RNSkCanvasProvider> canvasProvider) override;
46
-
47
45
  void
48
46
  renderImmediate(std::shared_ptr<RNSkCanvasProvider> canvasProvider) override;
49
47
 
@@ -40,11 +40,7 @@ class RNSkPictureRenderer
40
40
  public:
41
41
  RNSkPictureRenderer(std::function<void()> requestRedraw,
42
42
  std::shared_ptr<RNSkPlatformContext> context)
43
- : RNSkRenderer(requestRedraw), _platformContext(context) {}
44
-
45
- bool tryRender(std::shared_ptr<RNSkCanvasProvider> canvasProvider) override {
46
- return performDraw(canvasProvider);
47
- }
43
+ : RNSkRenderer(std::move(requestRedraw)), _platformContext(std::move(context)) {}
48
44
 
49
45
  void
50
46
  renderImmediate(std::shared_ptr<RNSkCanvasProvider> canvasProvider) override {
@@ -55,31 +51,28 @@ public:
55
51
  if (picture == nullptr) {
56
52
  _picture = nullptr;
57
53
  } else {
58
- _picture = std::dynamic_pointer_cast<JsiSkPicture>(picture);
54
+ _picture = std::dynamic_pointer_cast<JsiSkPicture>(picture)->getObject();
59
55
  }
60
56
  _requestRedraw();
61
57
  }
62
58
 
63
59
  private:
64
60
  bool performDraw(std::shared_ptr<RNSkCanvasProvider> canvasProvider) {
65
- canvasProvider->renderToCanvas([=](SkCanvas *canvas) {
61
+ return canvasProvider->renderToCanvas([=](SkCanvas *canvas) {
66
62
  // Make sure to scale correctly
67
63
  auto pd = _platformContext->getPixelDensity();
68
64
  canvas->clear(SK_ColorTRANSPARENT);
69
65
  canvas->save();
70
66
  canvas->scale(pd, pd);
71
-
72
67
  if (_picture != nullptr) {
73
- canvas->drawPicture(_picture->getObject());
68
+ canvas->drawPicture(_picture);
74
69
  }
75
-
76
70
  canvas->restore();
77
71
  });
78
- return true;
79
72
  }
80
73
 
81
74
  std::shared_ptr<RNSkPlatformContext> _platformContext;
82
- std::shared_ptr<JsiSkPicture> _picture;
75
+ sk_sp<SkPicture> _picture;
83
76
  };
84
77
 
85
78
  class RNSkPictureView : public RNSkView {
@@ -52,33 +52,15 @@ protected:
52
52
  class RNSkRenderer {
53
53
  public:
54
54
  explicit RNSkRenderer(std::function<void()> requestRedraw)
55
- : _requestRedraw(requestRedraw) {}
56
-
57
- /**
58
- Tries to render the current set of drawing operations. If we're busy we'll
59
- return false so that the calling RNSkBaseDrawView can request a new render
60
- next frame. The tryRender method is typically called on each frame if there
61
- are any redraw requests. The method will be called from the main thread, so
62
- the implementor must make sure any thread requirements are met before
63
- rendering. This method will also allow the rendering to be dispatched to
64
- another thread.
65
- */
66
- virtual bool
67
- tryRender(std::shared_ptr<RNSkCanvasProvider> canvasProvider) = 0;
55
+ : _requestRedraw(std::move(requestRedraw)), _showDebugOverlays(false) {}
68
56
 
69
- /**
70
- Renders directly to the canvas in the canvas provider. This method is called
71
- from a Javascript call to render a snapshot of the SkiaView to an image, and
72
- can therefore run outside the tryRender loop and directly in the javascript
73
- thread.
74
- */
75
57
  virtual void
76
58
  renderImmediate(std::shared_ptr<RNSkCanvasProvider> canvasProvider) = 0;
77
59
 
78
60
  void setShowDebugOverlays(bool showDebugOverlays) {
79
61
  _showDebugOverlays = showDebugOverlays;
80
62
  }
81
- bool getShowDebugOverlays() { return _showDebugOverlays; }
63
+ bool getShowDebugOverlays() const { return _showDebugOverlays; }
82
64
 
83
65
  protected:
84
66
  std::function<void()> _requestRedraw;
@@ -180,7 +162,7 @@ public:
180
162
  // Try to lock the weak pointer
181
163
  if (auto strongThis = weakThis.lock()) {
182
164
  // Only proceed if the object still exists
183
- if (strongThis->_renderer) {
165
+ if (strongThis->_renderer && strongThis->_redrawRequested) {
184
166
  strongThis->_renderer->renderImmediate(strongThis->_canvasProvider);
185
167
  strongThis->_redrawRequested = false;
186
168
  }
@@ -23,16 +23,12 @@
23
23
  #include <TargetConditionals.h>
24
24
  #if TARGET_RT_BIG_ENDIAN
25
25
  #define FourCC2Str(fourcc) \
26
- (const char[]) { \
27
- *((char *)&fourcc), *(((char *)&fourcc) + 1), *(((char *)&fourcc) + 2), \
28
- *(((char *)&fourcc) + 3), 0 \
29
- }
26
+ (const char[]){*((char *)&fourcc), *(((char *)&fourcc) + 1), \
27
+ *(((char *)&fourcc) + 2), *(((char *)&fourcc) + 3), 0}
30
28
  #else
31
29
  #define FourCC2Str(fourcc) \
32
- (const char[]) { \
33
- *(((char *)&fourcc) + 3), *(((char *)&fourcc) + 2), \
34
- *(((char *)&fourcc) + 1), *(((char *)&fourcc) + 0), 0 \
35
- }
30
+ (const char[]){*(((char *)&fourcc) + 3), *(((char *)&fourcc) + 2), \
31
+ *(((char *)&fourcc) + 1), *(((char *)&fourcc) + 0), 0}
36
32
  #endif
37
33
 
38
34
  // pragma MARK: TextureHolder
@@ -31,6 +31,11 @@ RCT_CUSTOM_VIEW_PROPERTY(debug, BOOL, SkiaUIView) {
31
31
  [(SkiaUIView *)view setDebugMode:debug];
32
32
  }
33
33
 
34
+ RCT_CUSTOM_VIEW_PROPERTY(opaque, BOOL, SkiaUIView) {
35
+ bool debug = json != NULL ? [RCTConvert BOOL:json] : false;
36
+ [(SkiaUIView *)view setOpaque:debug];
37
+ }
38
+
34
39
  - (UIView *)view {
35
40
  auto skManager = [[self skiaManager] skManager];
36
41
  // Pass SkManager as a raw pointer to avoid circular dependenciesr
@@ -54,6 +54,7 @@ using namespace facebook::react;
54
54
  [[RCTConvert NSString:RCTNSStringFromString(newProps.nativeId)] intValue];
55
55
  [self setNativeId:nativeId];
56
56
  [self setDebugMode:newProps.debug];
57
+ [self setOpaque:newProps.opaque];
57
58
  }
58
59
 
59
60
  @end
@@ -31,6 +31,11 @@ RCT_CUSTOM_VIEW_PROPERTY(debug, BOOL, SkiaUIView) {
31
31
  [(SkiaUIView *)view setDebugMode:debug];
32
32
  }
33
33
 
34
+ RCT_CUSTOM_VIEW_PROPERTY(opaque, BOOL, SkiaUIView) {
35
+ bool opaque = json != NULL ? [RCTConvert BOOL:json] : false;
36
+ [(SkiaUIView *)view setOpaque:opaque];
37
+ }
38
+
34
39
  - (UIView *)view {
35
40
  auto skManager = [[self skiaManager] skManager];
36
41
  // Pass SkManager as a raw pointer to avoid circular dependenciesr
@@ -32,6 +32,7 @@
32
32
  - (SkiaManager *)skiaManager;
33
33
 
34
34
  - (void)setDebugMode:(bool)debugMode;
35
+ - (void)setOpaque:(bool)opaque;
35
36
  - (void)setNativeId:(size_t)nativeId;
36
37
 
37
38
  @end
@@ -15,6 +15,7 @@
15
15
  std::shared_ptr<RNSkia::RNSkPlatformContext>)>
16
16
  _factory;
17
17
  bool _debugMode;
18
+ bool _opaque;
18
19
  size_t _nativeId;
19
20
  }
20
21
 
@@ -150,6 +151,10 @@
150
151
  }
151
152
  }
152
153
 
154
+ - (void)setOpaque:(bool)opaque {
155
+ _opaque = opaque;
156
+ }
157
+
153
158
  - (void)setNativeId:(size_t)nativeId {
154
159
  _nativeId = nativeId;
155
160
 
@@ -0,0 +1,21 @@
1
+ export declare enum ColorType {
2
+ Unknown = 0,// uninitialized
3
+ Alpha_8 = 1,// pixel with alpha in 8-bit byte
4
+ RGB_565 = 2,// pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
5
+ ARGB_4444 = 3,// pixel with 4 bits for alpha, red, green, blue; in 16-bit word
6
+ RGBA_8888 = 4,// pixel with 8 bits for red, green, blue, alpha; in 32-bit word
7
+ RGB_888x = 5,// pixel with 8 bits each for red, green, blue; in 32-bit word
8
+ BGRA_8888 = 6,// pixel with 8 bits for blue, green, red, alpha; in 32-bit word
9
+ RGBA_1010102 = 7,// 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
10
+ BGRA_1010102 = 8,// 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
11
+ RGB_101010x = 9,// pixel with 10 bits each for red, green, blue; in 32-bit word
12
+ BGR_101010x = 10,// pixel with 10 bits each for blue, green, red; in 32-bit word
13
+ BGR_101010x_XR = 11,// pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
14
+ BGRA_10101010_XR = 12,// pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
15
+ RGBA_10x6 = 13,// pixel with 10 used bits (most significant) followed by 6 unused
16
+ Gray_8 = 14,// pixel with grayscale level in 8-bit byte
17
+ RGBA_F16Norm = 15,// pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word
18
+ RGBA_F16 = 16,// pixel with half floats for red, green, blue, alpha; in 64-bit word
19
+ RGB_F16F16F16x = 17,// pixel with half floats for red, green, blue; in 64-bit word
20
+ RGBA_F32 = 18
21
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ColorType = void 0;
7
+ let ColorType = exports.ColorType = /*#__PURE__*/function (ColorType) {
8
+ ColorType[ColorType["Unknown"] = 0] = "Unknown";
9
+ ColorType[ColorType["Alpha_8"] = 1] = "Alpha_8";
10
+ ColorType[ColorType["RGB_565"] = 2] = "RGB_565";
11
+ ColorType[ColorType["ARGB_4444"] = 3] = "ARGB_4444";
12
+ ColorType[ColorType["RGBA_8888"] = 4] = "RGBA_8888";
13
+ ColorType[ColorType["RGB_888x"] = 5] = "RGB_888x";
14
+ ColorType[ColorType["BGRA_8888"] = 6] = "BGRA_8888";
15
+ ColorType[ColorType["RGBA_1010102"] = 7] = "RGBA_1010102";
16
+ ColorType[ColorType["BGRA_1010102"] = 8] = "BGRA_1010102";
17
+ ColorType[ColorType["RGB_101010x"] = 9] = "RGB_101010x";
18
+ ColorType[ColorType["BGR_101010x"] = 10] = "BGR_101010x";
19
+ ColorType[ColorType["BGR_101010x_XR"] = 11] = "BGR_101010x_XR";
20
+ ColorType[ColorType["BGRA_10101010_XR"] = 12] = "BGRA_10101010_XR";
21
+ ColorType[ColorType["RGBA_10x6"] = 13] = "RGBA_10x6";
22
+ ColorType[ColorType["Gray_8"] = 14] = "Gray_8";
23
+ ColorType[ColorType["RGBA_F16Norm"] = 15] = "RGBA_F16Norm";
24
+ ColorType[ColorType["RGBA_F16"] = 16] = "RGBA_F16";
25
+ ColorType[ColorType["RGB_F16F16F16x"] = 17] = "RGB_F16F16F16x";
26
+ ColorType[ColorType["RGBA_F32"] = 18] = "RGBA_F32";
27
+ return ColorType;
28
+ }({}); // pixel using C float for red, green, blue, alpha; in 128-bit word
29
+ //# sourceMappingURL=ColorType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ColorType","exports"],"sources":["ColorType.ts"],"sourcesContent":["export enum ColorType {\n Unknown, // uninitialized\n Alpha_8, // pixel with alpha in 8-bit byte\n RGB_565, // pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, // pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, // pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, // pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, // pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, // 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, // 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, // pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, // pixel with 10 bits each for blue, green, red; in 32-bit word\n BGR_101010x_XR, // pixel with 10 bits each for blue, green, red; in 32-bit word, extended range\n BGRA_10101010_XR, // pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range\n RGBA_10x6, // pixel with 10 used bits (most significant) followed by 6 unused\n Gray_8, // pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, // pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word\n RGBA_F16, // pixel with half floats for red, green, blue, alpha; in 64-bit word\n RGB_F16F16F16x, // pixel with half floats for red, green, blue; in 64-bit word\n RGBA_F32, // pixel using C float for red, green, blue, alpha; in 128-bit word\n}\n"],"mappings":";;;;;;IAAYA,SAAS,GAAAC,OAAA,CAAAD,SAAA,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA,OAmBT","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ export declare enum ColorTypeCanvasKit {
2
+ Unknown = 0,// uninitialized
3
+ Alpha_8 = 1,// pixel with alpha in 8-bit byte
4
+ RGB_565 = 2,// pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
5
+ ARGB_4444 = 3,// pixel with 4 bits for alpha, red, green, blue; in 16-bit word
6
+ RGBA_8888 = 4,// pixel with 8 bits for red, green, blue, alpha; in 32-bit word
7
+ RGB_888x = 5,// pixel with 8 bits each for red, green, blue; in 32-bit word
8
+ BGRA_8888 = 6,// pixel with 8 bits for blue, green, red, alpha; in 32-bit word
9
+ RGBA_1010102 = 7,// 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
10
+ BGRA_1010102 = 8,// 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
11
+ RGB_101010x = 9,// pixel with 10 bits each for red, green, blue; in 32-bit word
12
+ BGR_101010x = 10,// pixel with 10 bits each for blue, green, red; in 32-bit word
13
+ BGR_101010x_XR = 11,// pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
14
+ RGBA_10x6 = 12,// pixel with 10 used bits (most significant) followed by 6 unused
15
+ Gray_8 = 13,// pixel with grayscale level in 8-bit byte
16
+ RGBA_F16Norm = 14,// pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word
17
+ RGBA_F16 = 15,// pixel with half floats for red, green, blue, alpha; in 64-bit word
18
+ RGBA_F32 = 16
19
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ColorTypeCanvasKit = void 0;
7
+ let ColorTypeCanvasKit = exports.ColorTypeCanvasKit = /*#__PURE__*/function (ColorTypeCanvasKit) {
8
+ ColorTypeCanvasKit[ColorTypeCanvasKit["Unknown"] = 0] = "Unknown";
9
+ ColorTypeCanvasKit[ColorTypeCanvasKit["Alpha_8"] = 1] = "Alpha_8";
10
+ ColorTypeCanvasKit[ColorTypeCanvasKit["RGB_565"] = 2] = "RGB_565";
11
+ ColorTypeCanvasKit[ColorTypeCanvasKit["ARGB_4444"] = 3] = "ARGB_4444";
12
+ ColorTypeCanvasKit[ColorTypeCanvasKit["RGBA_8888"] = 4] = "RGBA_8888";
13
+ ColorTypeCanvasKit[ColorTypeCanvasKit["RGB_888x"] = 5] = "RGB_888x";
14
+ ColorTypeCanvasKit[ColorTypeCanvasKit["BGRA_8888"] = 6] = "BGRA_8888";
15
+ ColorTypeCanvasKit[ColorTypeCanvasKit["RGBA_1010102"] = 7] = "RGBA_1010102";
16
+ ColorTypeCanvasKit[ColorTypeCanvasKit["BGRA_1010102"] = 8] = "BGRA_1010102";
17
+ ColorTypeCanvasKit[ColorTypeCanvasKit["RGB_101010x"] = 9] = "RGB_101010x";
18
+ ColorTypeCanvasKit[ColorTypeCanvasKit["BGR_101010x"] = 10] = "BGR_101010x";
19
+ ColorTypeCanvasKit[ColorTypeCanvasKit["BGR_101010x_XR"] = 11] = "BGR_101010x_XR";
20
+ ColorTypeCanvasKit[ColorTypeCanvasKit["RGBA_10x6"] = 12] = "RGBA_10x6";
21
+ ColorTypeCanvasKit[ColorTypeCanvasKit["Gray_8"] = 13] = "Gray_8";
22
+ ColorTypeCanvasKit[ColorTypeCanvasKit["RGBA_F16Norm"] = 14] = "RGBA_F16Norm";
23
+ ColorTypeCanvasKit[ColorTypeCanvasKit["RGBA_F16"] = 15] = "RGBA_F16";
24
+ ColorTypeCanvasKit[ColorTypeCanvasKit["RGBA_F32"] = 16] = "RGBA_F32";
25
+ return ColorTypeCanvasKit;
26
+ }({}); // pixel using C float for red, green, blue, alpha; in 128-bit word
27
+ //# sourceMappingURL=ColorType.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ColorTypeCanvasKit","exports"],"sources":["ColorType.web.ts"],"sourcesContent":["export enum ColorTypeCanvasKit {\n Unknown, // uninitialized\n Alpha_8, // pixel with alpha in 8-bit byte\n RGB_565, // pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, // pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, // pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, // pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, // pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, // 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, // 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, // pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, // pixel with 10 bits each for blue, green, red; in 32-bit word\n BGR_101010x_XR, // pixel with 10 bits each for blue, green, red; in 32-bit word, extended range\n RGBA_10x6, // pixel with 10 used bits (most significant) followed by 6 unused\n Gray_8, // pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, // pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word\n RGBA_F16, // pixel with half floats for red, green, blue, alpha; in 64-bit word\n RGBA_F32, // pixel using C float for red, green, blue, alpha; in 128-bit word\n}\n"],"mappings":";;;;;;IAAYA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAlBA,kBAAkB,CAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA,OAiBlB","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import type { SkData } from "../Data";
2
2
  import type { NativeBuffer } from "../NativeBuffer";
3
+ import type { ColorType } from "./ColorType";
3
4
  import type { SkImage } from "./Image";
4
5
  export declare enum AlphaType {
5
6
  Unknown = 0,
@@ -7,25 +8,6 @@ export declare enum AlphaType {
7
8
  Premul = 2,
8
9
  Unpremul = 3
9
10
  }
10
- export declare enum ColorType {
11
- Unknown = 0,// uninitialized
12
- Alpha_8 = 1,// pixel with alpha in 8-bit byte
13
- RGB_565 = 2,// pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
14
- ARGB_4444 = 3,// pixel with 4 bits for alpha, red, green, blue; in 16-bit word
15
- RGBA_8888 = 4,// pixel with 8 bits for red, green, blue, alpha; in 32-bit word
16
- RGB_888x = 5,// pixel with 8 bits each for red, green, blue; in 32-bit word
17
- BGRA_8888 = 6,// pixel with 8 bits for blue, green, red, alpha; in 32-bit word
18
- RGBA_1010102 = 7,// 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
19
- BGRA_1010102 = 8,// 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
20
- RGB_101010x = 9,// pixel with 10 bits each for red, green, blue; in 32-bit word
21
- BGR_101010x = 10,// pixel with 10 bits each for blue, green, red; in 32-bit word
22
- BGR_101010x_XR = 11,// pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
23
- RGBA_10x6 = 12,// pixel with 10 used bits (most significant) followed by 6 unused
24
- Gray_8 = 13,// pixel with grayscale level in 8-bit byte
25
- RGBA_F16Norm = 14,// pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word
26
- RGBA_F16 = 15,// pixel with half floats for red, green, blue, alpha; in 64-bit word
27
- RGBA_F32 = 16
28
- }
29
11
  export interface ImageInfo {
30
12
  alphaType: AlphaType;
31
13
  colorType: ColorType;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ColorType = exports.AlphaType = void 0;
6
+ exports.AlphaType = void 0;
7
7
  let AlphaType = exports.AlphaType = /*#__PURE__*/function (AlphaType) {
8
8
  AlphaType[AlphaType["Unknown"] = 0] = "Unknown";
9
9
  AlphaType[AlphaType["Opaque"] = 1] = "Opaque";
@@ -11,24 +11,4 @@ let AlphaType = exports.AlphaType = /*#__PURE__*/function (AlphaType) {
11
11
  AlphaType[AlphaType["Unpremul"] = 3] = "Unpremul";
12
12
  return AlphaType;
13
13
  }({});
14
- let ColorType = exports.ColorType = /*#__PURE__*/function (ColorType) {
15
- ColorType[ColorType["Unknown"] = 0] = "Unknown";
16
- ColorType[ColorType["Alpha_8"] = 1] = "Alpha_8";
17
- ColorType[ColorType["RGB_565"] = 2] = "RGB_565";
18
- ColorType[ColorType["ARGB_4444"] = 3] = "ARGB_4444";
19
- ColorType[ColorType["RGBA_8888"] = 4] = "RGBA_8888";
20
- ColorType[ColorType["RGB_888x"] = 5] = "RGB_888x";
21
- ColorType[ColorType["BGRA_8888"] = 6] = "BGRA_8888";
22
- ColorType[ColorType["RGBA_1010102"] = 7] = "RGBA_1010102";
23
- ColorType[ColorType["BGRA_1010102"] = 8] = "BGRA_1010102";
24
- ColorType[ColorType["RGB_101010x"] = 9] = "RGB_101010x";
25
- ColorType[ColorType["BGR_101010x"] = 10] = "BGR_101010x";
26
- ColorType[ColorType["BGR_101010x_XR"] = 11] = "BGR_101010x_XR";
27
- ColorType[ColorType["RGBA_10x6"] = 12] = "RGBA_10x6";
28
- ColorType[ColorType["Gray_8"] = 13] = "Gray_8";
29
- ColorType[ColorType["RGBA_F16Norm"] = 14] = "RGBA_F16Norm";
30
- ColorType[ColorType["RGBA_F16"] = 15] = "RGBA_F16";
31
- ColorType[ColorType["RGBA_F32"] = 16] = "RGBA_F32";
32
- return ColorType;
33
- }({}); // pixel using C float for red, green, blue, alpha; in 128-bit word
34
14
  //# sourceMappingURL=ImageFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AlphaType","exports","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\nimport type { NativeBuffer } from \"../NativeBuffer\";\n\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport enum ColorType {\n Unknown, // uninitialized\n Alpha_8, // pixel with alpha in 8-bit byte\n RGB_565, // pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, // pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, // pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, // pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, // pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, // 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, // 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, // pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, // pixel with 10 bits each for blue, green, red; in 32-bit word\n BGR_101010x_XR, // pixel with 10 bits each for blue, green, red; in 32-bit word, extended range\n RGBA_10x6, // pixel with 10 used bits (most significant) followed by 6 unused\n Gray_8, // pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, // pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word\n RGBA_F16, // pixel with half floats for red, green, blue, alpha; in 64-bit word\n RGBA_F32, // pixel using C float for red, green, blue, alpha; in 128-bit word\n}\n\nexport interface ImageInfo {\n alphaType: AlphaType;\n // TODO: add support for color space\n // colorSpace: ColorSpace;\n colorType: ColorType;\n height: number;\n width: number;\n}\n\nexport interface ImageFactory {\n /**\n * Return an Image backed by the encoded data, but attempt to defer decoding until the image\n * is actually used/drawn. This deferral allows the system to cache the result, either on the\n * CPU or on the GPU, depending on where the image is drawn.\n * This decoding uses the codecs that have been compiled into CanvasKit. If the bytes are\n * invalid (or an unrecognized codec), null will be returned. See Image.h for more details.\n * @param data - Data object with bytes of data\n * @returns If the encoded format is not supported, or subset is outside of the bounds of the decoded\n * image, nullptr is returned.\n */\n MakeImageFromEncoded: (encoded: SkData) => SkImage | null;\n\n /**\n * Return an Image backed by a given native buffer.\n * The native buffer must be a valid owning reference.\n *\n * For instance, this API is used by\n * [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera)\n * to render a Skia Camera preview.\n *\n * - On Android; This is an `AHardwareBuffer*`\n * - On iOS, this is a `CVPixelBufferRef`\n * @param nativeBuffer A strong `uintptr_t` pointer to the native buffer\n * @throws Throws an error if the Image could not be created, for example when the given\n * native buffer is invalid.\n */\n MakeImageFromNativeBuffer: (nativeBuffer: NativeBuffer) => SkImage;\n\n /**\n * Returns an image that will be a screenshot of the view represented by\n * the view tag\n * @param viewTag - The tag of the view to make an image from.\n * @returns Returns a valid SkImage, if the view tag is invalid, nullptr is returned.\n */\n MakeImageFromViewTag: (viewTag: number) => Promise<SkImage | null>;\n\n /**\n * Returns an image with the given pixel data and format.\n * Note that we will always make a copy of the pixel data, because of inconsistencies in\n * behavior between GPU and CPU (i.e. the pixel data will be turned into a GPU texture and\n * not modifiable after creation).\n *\n * @param info\n * @param data - bytes representing the pixel data.\n * @param bytesPerRow\n */\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): SkImage | null;\n}\n"],"mappings":";;;;;;IAKYA,SAAS,GAAAC,OAAA,CAAAD,SAAA,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AAAA,IAOTE,SAAS,GAAAD,OAAA,CAAAC,SAAA,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA,OAiBT","ignoreList":[]}
1
+ {"version":3,"names":["AlphaType","exports"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\nimport type { NativeBuffer } from \"../NativeBuffer\";\n\nimport type { ColorType } from \"./ColorType\";\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport interface ImageInfo {\n alphaType: AlphaType;\n // TODO: add support for color space\n // colorSpace: ColorSpace;\n colorType: ColorType;\n height: number;\n width: number;\n}\n\nexport interface ImageFactory {\n /**\n * Return an Image backed by the encoded data, but attempt to defer decoding until the image\n * is actually used/drawn. This deferral allows the system to cache the result, either on the\n * CPU or on the GPU, depending on where the image is drawn.\n * This decoding uses the codecs that have been compiled into CanvasKit. If the bytes are\n * invalid (or an unrecognized codec), null will be returned. See Image.h for more details.\n * @param data - Data object with bytes of data\n * @returns If the encoded format is not supported, or subset is outside of the bounds of the decoded\n * image, nullptr is returned.\n */\n MakeImageFromEncoded: (encoded: SkData) => SkImage | null;\n\n /**\n * Return an Image backed by a given native buffer.\n * The native buffer must be a valid owning reference.\n *\n * For instance, this API is used by\n * [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera)\n * to render a Skia Camera preview.\n *\n * - On Android; This is an `AHardwareBuffer*`\n * - On iOS, this is a `CVPixelBufferRef`\n * @param nativeBuffer A strong `uintptr_t` pointer to the native buffer\n * @throws Throws an error if the Image could not be created, for example when the given\n * native buffer is invalid.\n */\n MakeImageFromNativeBuffer: (nativeBuffer: NativeBuffer) => SkImage;\n\n /**\n * Returns an image that will be a screenshot of the view represented by\n * the view tag\n * @param viewTag - The tag of the view to make an image from.\n * @returns Returns a valid SkImage, if the view tag is invalid, nullptr is returned.\n */\n MakeImageFromViewTag: (viewTag: number) => Promise<SkImage | null>;\n\n /**\n * Returns an image with the given pixel data and format.\n * Note that we will always make a copy of the pixel data, because of inconsistencies in\n * behavior between GPU and CPU (i.e. the pixel data will be turned into a GPU texture and\n * not modifiable after creation).\n *\n * @param info\n * @param data - bytes representing the pixel data.\n * @param bytesPerRow\n */\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): SkImage | null;\n}\n"],"mappings":";;;;;;IAMYA,SAAS,GAAAC,OAAA,CAAAD,SAAA,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA","ignoreList":[]}
@@ -1,2 +1,3 @@
1
1
  export * from "./Image";
2
2
  export * from "./ImageFactory";
3
+ export * from "./ColorType";
@@ -25,4 +25,15 @@ Object.keys(_ImageFactory).forEach(function (key) {
25
25
  }
26
26
  });
27
27
  });
28
+ var _ColorType = require("./ColorType");
29
+ Object.keys(_ColorType).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _ColorType[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _ColorType[key];
36
+ }
37
+ });
38
+ });
28
39
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Image","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_ImageFactory"],"sources":["index.ts"],"sourcesContent":["export * from \"./Image\";\nexport * from \"./ImageFactory\";\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,aAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,aAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,aAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,aAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Image","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_ImageFactory","_ColorType"],"sources":["index.ts"],"sourcesContent":["export * from \"./Image\";\nexport * from \"./ImageFactory\";\nexport * from \"./ColorType\";\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,aAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,aAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,aAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,aAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,UAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,UAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,UAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,UAAA,CAAAN,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}