@shopify/react-native-skia 0.1.119 → 0.1.120
Sign up to get free protection for your applications and to get access to all the features.
@@ -18,14 +18,13 @@
|
|
18
18
|
|
19
19
|
#pragma clang diagnostic pop
|
20
20
|
|
21
|
-
@class SkiaDrawView;
|
22
|
-
|
23
21
|
class RNSkDrawViewImpl : public RNSkia::RNSkDrawView {
|
24
22
|
public:
|
25
|
-
RNSkDrawViewImpl(
|
26
|
-
std::shared_ptr<RNSkia::RNSkPlatformContext> context);
|
23
|
+
RNSkDrawViewImpl(std::shared_ptr<RNSkia::RNSkPlatformContext> context);
|
27
24
|
|
28
25
|
void setSize(int width, int height);
|
26
|
+
|
27
|
+
CALayer* getLayer() { return _layer; };
|
29
28
|
|
30
29
|
protected:
|
31
30
|
int getWidth() override { return _width * _context->getPixelDensity(); };
|
@@ -42,8 +41,6 @@ private:
|
|
42
41
|
int _width = -1;
|
43
42
|
int _height = -1;
|
44
43
|
|
45
|
-
SkiaDrawView *_view;
|
46
|
-
|
47
44
|
#pragma clang diagnostic push
|
48
45
|
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
49
46
|
CAMetalLayer *_layer;
|
@@ -17,8 +17,8 @@ id<MTLCommandQueue> RNSkDrawViewImpl::_commandQueue = id<MTLCommandQueue>(CFReta
|
|
17
17
|
|
18
18
|
sk_sp<GrDirectContext> RNSkDrawViewImpl::_skContext = nullptr;
|
19
19
|
|
20
|
-
RNSkDrawViewImpl::RNSkDrawViewImpl(
|
21
|
-
|
20
|
+
RNSkDrawViewImpl::RNSkDrawViewImpl(std::shared_ptr<RNSkia::RNSkPlatformContext> context):
|
21
|
+
_context(context), RNSkia::RNSkDrawView(context) {
|
22
22
|
|
23
23
|
#pragma clang diagnostic push
|
24
24
|
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
@@ -30,8 +30,6 @@ RNSkDrawViewImpl::RNSkDrawViewImpl(SkiaDrawView* view, std::shared_ptr<RNSkia::R
|
|
30
30
|
_layer.opaque = false;
|
31
31
|
_layer.contentsScale = _context->getPixelDensity();
|
32
32
|
_layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
33
|
-
_layer.frame = _view.bounds;
|
34
|
-
[_view.layer addSublayer:_layer];
|
35
33
|
|
36
34
|
setNativeDrawFunc(std::bind(&RNSkDrawViewImpl::drawFrame, this, std::placeholders::_1));
|
37
35
|
}
|
@@ -56,13 +56,14 @@
|
|
56
56
|
if(_nativeId != 0 && _manager != nullptr) {
|
57
57
|
_manager->setSkiaDrawView(_nativeId, nullptr);
|
58
58
|
}
|
59
|
+
[_impl->getLayer() removeFromSuperlayer];
|
59
60
|
_impl = nullptr;
|
60
61
|
}
|
61
62
|
} else {
|
62
63
|
// Create implementation view when the parent view is set
|
63
64
|
if(_impl == nullptr && _manager != nullptr) {
|
64
|
-
|
65
|
-
_impl
|
65
|
+
_impl = std::make_shared<RNSkDrawViewImpl>(_manager->getPlatformContext());
|
66
|
+
[self.layer addSublayer:_impl->getLayer()];
|
66
67
|
if(_nativeId != 0) {
|
67
68
|
_manager->setSkiaDrawView(_nativeId, _impl.get());
|
68
69
|
}
|