@shopify/react-native-skia 0.1.167 → 0.1.170
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkPath.h +1 -1
- package/cpp/jsi/JsiValue.h +10 -10
- package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +7 -3
- package/cpp/rnskia/dom/base/JsiDomNode.h +11 -0
- package/cpp/rnskia/dom/base/JsiDomRenderNode.h +7 -3
- package/cpp/rnskia/dom/base/NodeProp.h +1 -3
- package/cpp/rnskia/dom/nodes/JsiGroupNode.h +2 -3
- package/cpp/rnskia/dom/props/FontProp.h +2 -1
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +10 -0
- package/package.json +1 -1
package/cpp/api/JsiSkPath.h
CHANGED
@@ -47,7 +47,7 @@ public:
|
|
47
47
|
count > 1 && !arguments[1].isUndefined() && !arguments[1].isNull()
|
48
48
|
? JsiSkMatrix::fromValue(runtime, arguments[1])
|
49
49
|
: nullptr;
|
50
|
-
auto mode = count > 2 && arguments[2].
|
50
|
+
auto mode = count > 2 && arguments[2].isBool() && arguments[2].getBool()
|
51
51
|
? SkPath::kExtend_AddPathMode
|
52
52
|
: SkPath::kAppend_AddPathMode;
|
53
53
|
if (matrix == nullptr) {
|
package/cpp/jsi/JsiValue.h
CHANGED
@@ -13,15 +13,15 @@ namespace RNJsi {
|
|
13
13
|
namespace jsi = facebook::jsi;
|
14
14
|
|
15
15
|
enum struct PropType {
|
16
|
-
Undefined =
|
17
|
-
Null =
|
18
|
-
Bool =
|
19
|
-
Number =
|
20
|
-
String =
|
21
|
-
Object =
|
22
|
-
HostObject =
|
23
|
-
HostFunction =
|
24
|
-
Array =
|
16
|
+
Undefined = 0,
|
17
|
+
Null = 1, // Keep undefined / null constant so that we can do checks faster
|
18
|
+
Bool = 2,
|
19
|
+
Number = 3,
|
20
|
+
String = 4,
|
21
|
+
Object = 5,
|
22
|
+
HostObject = 6,
|
23
|
+
HostFunction = 7,
|
24
|
+
Array = 8
|
25
25
|
};
|
26
26
|
|
27
27
|
using PropId = const char *;
|
@@ -80,7 +80,7 @@ public:
|
|
80
80
|
/**
|
81
81
|
Returns true if the value is undefined or null.
|
82
82
|
*/
|
83
|
-
bool isUndefinedOrNull() const { return
|
83
|
+
bool isUndefinedOrNull() const { return _type <= PropType::Null; }
|
84
84
|
|
85
85
|
/**
|
86
86
|
Returns true if the value is undefined.
|
@@ -41,9 +41,9 @@ public:
|
|
41
41
|
// Materialize children first so that any inner nodes get the opportunity
|
42
42
|
// to calculate their state before this node continues.
|
43
43
|
for (auto &child : getChildren()) {
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
if (child->getNodeClass() == JsiDomNodeClass::DeclarationNode) {
|
45
|
+
std::static_pointer_cast<JsiBaseDomDeclarationNode>(child)
|
46
|
+
->decorateContext(context);
|
47
47
|
}
|
48
48
|
}
|
49
49
|
|
@@ -55,6 +55,10 @@ public:
|
|
55
55
|
#endif
|
56
56
|
}
|
57
57
|
|
58
|
+
JsiDomNodeClass getNodeClass() override {
|
59
|
+
return JsiDomNodeClass::DeclarationNode;
|
60
|
+
}
|
61
|
+
|
58
62
|
protected:
|
59
63
|
/**
|
60
64
|
Invalidates and marks then context as changed. The implementation in the
|
@@ -30,6 +30,11 @@ public:
|
|
30
30
|
|
31
31
|
static std::atomic<size_t> NodeIdent = 1000;
|
32
32
|
|
33
|
+
typedef enum {
|
34
|
+
RenderNode = 1,
|
35
|
+
DeclarationNode = 2,
|
36
|
+
} JsiDomNodeClass;
|
37
|
+
|
33
38
|
/**
|
34
39
|
Implements an abstract base class for nodes in the Skia Reconciler. This node
|
35
40
|
coresponds to the native implementation of the Node.ts class in Javascript.
|
@@ -174,6 +179,12 @@ public:
|
|
174
179
|
*/
|
175
180
|
virtual void invalidateContext() = 0;
|
176
181
|
|
182
|
+
/*
|
183
|
+
Returns the class of node so that we can do loops faster without
|
184
|
+
having to check using runtime type information
|
185
|
+
*/
|
186
|
+
virtual JsiDomNodeClass getNodeClass() = 0;
|
187
|
+
|
177
188
|
/**
|
178
189
|
Updates any pending property changes in all nodes and child nodes. This
|
179
190
|
function will swap any pending property changes in this and children with any
|
@@ -149,6 +149,10 @@ public:
|
|
149
149
|
}
|
150
150
|
}
|
151
151
|
|
152
|
+
JsiDomNodeClass getNodeClass() override {
|
153
|
+
return JsiDomNodeClass::RenderNode;
|
154
|
+
}
|
155
|
+
|
152
156
|
protected:
|
153
157
|
/**
|
154
158
|
Invalidates and marks then context as changed.
|
@@ -211,9 +215,9 @@ private:
|
|
211
215
|
*/
|
212
216
|
void materializeDeclarations() {
|
213
217
|
for (auto &child : getChildren()) {
|
214
|
-
|
215
|
-
|
216
|
-
|
218
|
+
if (child->getNodeClass() == JsiDomNodeClass::DeclarationNode) {
|
219
|
+
std::static_pointer_cast<JsiBaseDomDeclarationNode>(child)
|
220
|
+
->decorateContext(_localContext.get());
|
217
221
|
}
|
218
222
|
}
|
219
223
|
}
|
@@ -15,9 +15,8 @@ public:
|
|
15
15
|
|
16
16
|
void renderNode(DrawingContext *context) override {
|
17
17
|
for (auto &child : getChildren()) {
|
18
|
-
|
19
|
-
|
20
|
-
renderNode->render(context);
|
18
|
+
if (child->getNodeClass() == JsiDomNodeClass::RenderNode) {
|
19
|
+
std::static_pointer_cast<JsiDomRenderNode>(child)->render(context);
|
21
20
|
}
|
22
21
|
}
|
23
22
|
}
|
@@ -15,7 +15,8 @@ public:
|
|
15
15
|
}
|
16
16
|
|
17
17
|
void updateDerivedValue() override {
|
18
|
-
if (_fontProp->
|
18
|
+
if (!_fontProp->isSet() ||
|
19
|
+
_fontProp->value().getType() != PropType::HostObject) {
|
19
20
|
throw std::runtime_error("Expected SkFont object for the Font property.");
|
20
21
|
}
|
21
22
|
|
@@ -66,6 +66,16 @@ void RNSkMetalCanvasProvider::renderToCanvas(const std::function<void(SkCanvas*)
|
|
66
66
|
return;
|
67
67
|
}
|
68
68
|
|
69
|
+
// Make sure to NOT render or try any render operations while we're in the background or inactive.
|
70
|
+
// This will cause an error that might clear the CAMetalLayer so that the canvas is empty when
|
71
|
+
// the app receives focus again.
|
72
|
+
// Reference: https://github.com/Shopify/react-native-skia/issues/1257
|
73
|
+
auto state = UIApplication.sharedApplication.applicationState;
|
74
|
+
if (state == UIApplicationStateBackground || state == UIApplicationStateInactive)
|
75
|
+
{
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
|
69
79
|
// Get render context for current thread
|
70
80
|
auto renderContext = getMetalRenderContext();
|
71
81
|
|
package/package.json
CHANGED