@shopify/react-native-skia 0.1.119 → 0.1.122
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/android/CMakeLists.txt +30 -16
- package/android/build.gradle +81 -34
- package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +1 -1
- package/cpp/api/JsiSkApi.h +2 -0
- package/cpp/api/JsiSkColor.h +49 -0
- package/cpp/api/JsiSkPath.h +31 -2
- package/cpp/api/JsiSkPathFactory.h +96 -1
- package/cpp/api/third_party/CSSColorParser.h +324 -0
- package/cpp/rnskia/RNSkAnimation.h +4 -7
- package/cpp/rnskia/values/RNSkClockValue.h +4 -4
- package/cpp/rnskia/values/RNSkDerivedValue.h +1 -1
- package/cpp/rnskia/values/RNSkReadonlyValue.h +9 -15
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.h +3 -6
- package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +2 -4
- package/ios/RNSkia-iOS/SkiaDrawView.mm +3 -2
- package/lib/commonjs/renderer/components/shapes/Path.js +1 -1
- package/lib/commonjs/renderer/components/shapes/Path.js.map +1 -1
- package/lib/commonjs/renderer/nodes/Node.js +3 -3
- package/lib/commonjs/renderer/nodes/Node.js.map +1 -1
- package/lib/commonjs/skia/Color.js +3 -25
- package/lib/commonjs/skia/Color.js.map +1 -1
- package/lib/commonjs/skia/Image/Image.js.map +1 -1
- package/lib/commonjs/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/Paint/Paint.js.map +1 -1
- package/lib/commonjs/skia/Path/Path.js +13 -1
- package/lib/commonjs/skia/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/Shader/Shader.js.map +1 -1
- package/lib/commonjs/skia/Skia.js +41 -3
- package/lib/commonjs/skia/Skia.js.map +1 -1
- package/lib/module/renderer/components/shapes/Path.js +1 -1
- package/lib/module/renderer/components/shapes/Path.js.map +1 -1
- package/lib/module/renderer/nodes/Node.js +3 -3
- package/lib/module/renderer/nodes/Node.js.map +1 -1
- package/lib/module/skia/Color.js +2 -21
- package/lib/module/skia/Color.js.map +1 -1
- package/lib/module/skia/Image/Image.js.map +1 -1
- package/lib/module/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/module/skia/Paint/Paint.js.map +1 -1
- package/lib/module/skia/Path/Path.js +11 -0
- package/lib/module/skia/Path/Path.js.map +1 -1
- package/lib/module/skia/Shader/Shader.js.map +1 -1
- package/lib/module/skia/Skia.js +43 -2
- package/lib/module/skia/Skia.js.map +1 -1
- package/lib/typescript/src/skia/Color.d.ts +0 -1
- package/lib/typescript/src/skia/Image/Image.d.ts +3 -3
- package/lib/typescript/src/skia/ImageFilter/ImageFilterFactory.d.ts +2 -2
- package/lib/typescript/src/skia/Paint/Paint.d.ts +2 -2
- package/lib/typescript/src/skia/Path/Path.d.ts +13 -0
- package/lib/typescript/src/skia/Path/PathFactory.d.ts +7 -1
- package/lib/typescript/src/skia/Picture/Picture.d.ts +2 -2
- package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffect.d.ts +3 -3
- package/lib/typescript/src/skia/Shader/Shader.d.ts +2 -2
- package/lib/typescript/src/skia/Shader/ShaderFactory.d.ts +9 -9
- package/lib/typescript/src/skia/Skia.d.ts +5 -3
- package/package.json +1 -1
- package/scripts/install-npm.js +1 -1
- package/src/renderer/components/shapes/Path.tsx +1 -1
- package/src/renderer/nodes/Node.ts +3 -3
- package/src/skia/Color.ts +3 -20
- package/src/skia/Image/Image.ts +3 -3
- package/src/skia/ImageFilter/ImageFilterFactory.ts +2 -2
- package/src/skia/Paint/Paint.ts +2 -2
- package/src/skia/Path/Path.ts +16 -0
- package/src/skia/Path/PathFactory.ts +8 -1
- package/src/skia/Picture/Picture.ts +2 -2
- package/src/skia/RuntimeEffect/RuntimeEffect.ts +4 -4
- package/src/skia/Shader/Shader.ts +2 -2
- package/src/skia/Shader/ShaderFactory.ts +9 -9
- package/src/skia/Skia.ts +44 -3
@@ -0,0 +1,324 @@
|
|
1
|
+
// (c) Dean McNamee <dean@gmail.com>, 2012.
|
2
|
+
// C++ port by Mapbox, Konstantin Käfer <mail@kkaefer.com>, 2014-2017.
|
3
|
+
//
|
4
|
+
// https://github.com/deanm/css-color-parser-js
|
5
|
+
// https://github.com/kkaefer/css-color-parser-cpp
|
6
|
+
//
|
7
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
// of this software and associated documentation files (the "Software"), to
|
9
|
+
// deal in the Software without restriction, including without limitation the
|
10
|
+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
11
|
+
// sell copies of the Software, and to permit persons to whom the Software is
|
12
|
+
// furnished to do so, subject to the following conditions:
|
13
|
+
//
|
14
|
+
// The above copyright notice and this permission notice shall be included in
|
15
|
+
// all copies or substantial portions of the Software.
|
16
|
+
//
|
17
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
23
|
+
// IN THE SOFTWARE.
|
24
|
+
|
25
|
+
#pragma once
|
26
|
+
|
27
|
+
#include <cstdint>
|
28
|
+
#include <vector>
|
29
|
+
#include <sstream>
|
30
|
+
#include <algorithm>
|
31
|
+
#include <string>
|
32
|
+
#include <cmath>
|
33
|
+
|
34
|
+
namespace CSSColorParser {
|
35
|
+
|
36
|
+
struct Color {
|
37
|
+
inline Color() {
|
38
|
+
}
|
39
|
+
inline Color(unsigned char r_, unsigned char g_, unsigned char b_, float a_)
|
40
|
+
: r(r_), g(g_), b(b_), a(a_ > 1 ? 1 : a_ < 0 ? 0 : a_) {
|
41
|
+
}
|
42
|
+
unsigned char r = 0, g = 0, b = 0;
|
43
|
+
float a = -1.0f;
|
44
|
+
};
|
45
|
+
|
46
|
+
struct NamedColor { const char *const name; const Color color; };
|
47
|
+
|
48
|
+
const NamedColor namedColors[] = {
|
49
|
+
{ "transparent", { 0, 0, 0, 0 } }, { "aliceblue", { 240, 248, 255, 1 } },
|
50
|
+
{ "antiquewhite", { 250, 235, 215, 1 } }, { "aqua", { 0, 255, 255, 1 } },
|
51
|
+
{ "aquamarine", { 127, 255, 212, 1 } }, { "azure", { 240, 255, 255, 1 } },
|
52
|
+
{ "beige", { 245, 245, 220, 1 } }, { "bisque", { 255, 228, 196, 1 } },
|
53
|
+
{ "black", { 0, 0, 0, 1 } }, { "blanchedalmond", { 255, 235, 205, 1 } },
|
54
|
+
{ "blue", { 0, 0, 255, 1 } }, { "blueviolet", { 138, 43, 226, 1 } },
|
55
|
+
{ "brown", { 165, 42, 42, 1 } }, { "burlywood", { 222, 184, 135, 1 } },
|
56
|
+
{ "cadetblue", { 95, 158, 160, 1 } }, { "chartreuse", { 127, 255, 0, 1 } },
|
57
|
+
{ "chocolate", { 210, 105, 30, 1 } }, { "coral", { 255, 127, 80, 1 } },
|
58
|
+
{ "cornflowerblue", { 100, 149, 237, 1 } }, { "cornsilk", { 255, 248, 220, 1 } },
|
59
|
+
{ "crimson", { 220, 20, 60, 1 } }, { "cyan", { 0, 255, 255, 1 } },
|
60
|
+
{ "darkblue", { 0, 0, 139, 1 } }, { "darkcyan", { 0, 139, 139, 1 } },
|
61
|
+
{ "darkgoldenrod", { 184, 134, 11, 1 } }, { "darkgray", { 169, 169, 169, 1 } },
|
62
|
+
{ "darkgreen", { 0, 100, 0, 1 } }, { "darkgrey", { 169, 169, 169, 1 } },
|
63
|
+
{ "darkkhaki", { 189, 183, 107, 1 } }, { "darkmagenta", { 139, 0, 139, 1 } },
|
64
|
+
{ "darkolivegreen", { 85, 107, 47, 1 } }, { "darkorange", { 255, 140, 0, 1 } },
|
65
|
+
{ "darkorchid", { 153, 50, 204, 1 } }, { "darkred", { 139, 0, 0, 1 } },
|
66
|
+
{ "darksalmon", { 233, 150, 122, 1 } }, { "darkseagreen", { 143, 188, 143, 1 } },
|
67
|
+
{ "darkslateblue", { 72, 61, 139, 1 } }, { "darkslategray", { 47, 79, 79, 1 } },
|
68
|
+
{ "darkslategrey", { 47, 79, 79, 1 } }, { "darkturquoise", { 0, 206, 209, 1 } },
|
69
|
+
{ "darkviolet", { 148, 0, 211, 1 } }, { "deeppink", { 255, 20, 147, 1 } },
|
70
|
+
{ "deepskyblue", { 0, 191, 255, 1 } }, { "dimgray", { 105, 105, 105, 1 } },
|
71
|
+
{ "dimgrey", { 105, 105, 105, 1 } }, { "dodgerblue", { 30, 144, 255, 1 } },
|
72
|
+
{ "firebrick", { 178, 34, 34, 1 } }, { "floralwhite", { 255, 250, 240, 1 } },
|
73
|
+
{ "forestgreen", { 34, 139, 34, 1 } }, { "fuchsia", { 255, 0, 255, 1 } },
|
74
|
+
{ "gainsboro", { 220, 220, 220, 1 } }, { "ghostwhite", { 248, 248, 255, 1 } },
|
75
|
+
{ "gold", { 255, 215, 0, 1 } }, { "goldenrod", { 218, 165, 32, 1 } },
|
76
|
+
{ "gray", { 128, 128, 128, 1 } }, { "green", { 0, 128, 0, 1 } },
|
77
|
+
{ "greenyellow", { 173, 255, 47, 1 } }, { "grey", { 128, 128, 128, 1 } },
|
78
|
+
{ "honeydew", { 240, 255, 240, 1 } }, { "hotpink", { 255, 105, 180, 1 } },
|
79
|
+
{ "indianred", { 205, 92, 92, 1 } }, { "indigo", { 75, 0, 130, 1 } },
|
80
|
+
{ "ivory", { 255, 255, 240, 1 } }, { "khaki", { 240, 230, 140, 1 } },
|
81
|
+
{ "lavender", { 230, 230, 250, 1 } }, { "lavenderblush", { 255, 240, 245, 1 } },
|
82
|
+
{ "lawngreen", { 124, 252, 0, 1 } }, { "lemonchiffon", { 255, 250, 205, 1 } },
|
83
|
+
{ "lightblue", { 173, 216, 230, 1 } }, { "lightcoral", { 240, 128, 128, 1 } },
|
84
|
+
{ "lightcyan", { 224, 255, 255, 1 } }, { "lightgoldenrodyellow", { 250, 250, 210, 1 } },
|
85
|
+
{ "lightgray", { 211, 211, 211, 1 } }, { "lightgreen", { 144, 238, 144, 1 } },
|
86
|
+
{ "lightgrey", { 211, 211, 211, 1 } }, { "lightpink", { 255, 182, 193, 1 } },
|
87
|
+
{ "lightsalmon", { 255, 160, 122, 1 } }, { "lightseagreen", { 32, 178, 170, 1 } },
|
88
|
+
{ "lightskyblue", { 135, 206, 250, 1 } }, { "lightslategray", { 119, 136, 153, 1 } },
|
89
|
+
{ "lightslategrey", { 119, 136, 153, 1 } }, { "lightsteelblue", { 176, 196, 222, 1 } },
|
90
|
+
{ "lightyellow", { 255, 255, 224, 1 } }, { "lime", { 0, 255, 0, 1 } },
|
91
|
+
{ "limegreen", { 50, 205, 50, 1 } }, { "linen", { 250, 240, 230, 1 } },
|
92
|
+
{ "magenta", { 255, 0, 255, 1 } }, { "maroon", { 128, 0, 0, 1 } },
|
93
|
+
{ "mediumaquamarine", { 102, 205, 170, 1 } }, { "mediumblue", { 0, 0, 205, 1 } },
|
94
|
+
{ "mediumorchid", { 186, 85, 211, 1 } }, { "mediumpurple", { 147, 112, 219, 1 } },
|
95
|
+
{ "mediumseagreen", { 60, 179, 113, 1 } }, { "mediumslateblue", { 123, 104, 238, 1 } },
|
96
|
+
{ "mediumspringgreen", { 0, 250, 154, 1 } }, { "mediumturquoise", { 72, 209, 204, 1 } },
|
97
|
+
{ "mediumvioletred", { 199, 21, 133, 1 } }, { "midnightblue", { 25, 25, 112, 1 } },
|
98
|
+
{ "mintcream", { 245, 255, 250, 1 } }, { "mistyrose", { 255, 228, 225, 1 } },
|
99
|
+
{ "moccasin", { 255, 228, 181, 1 } }, { "navajowhite", { 255, 222, 173, 1 } },
|
100
|
+
{ "navy", { 0, 0, 128, 1 } }, { "oldlace", { 253, 245, 230, 1 } },
|
101
|
+
{ "olive", { 128, 128, 0, 1 } }, { "olivedrab", { 107, 142, 35, 1 } },
|
102
|
+
{ "orange", { 255, 165, 0, 1 } }, { "orangered", { 255, 69, 0, 1 } },
|
103
|
+
{ "orchid", { 218, 112, 214, 1 } }, { "palegoldenrod", { 238, 232, 170, 1 } },
|
104
|
+
{ "palegreen", { 152, 251, 152, 1 } }, { "paleturquoise", { 175, 238, 238, 1 } },
|
105
|
+
{ "palevioletred", { 219, 112, 147, 1 } }, { "papayawhip", { 255, 239, 213, 1 } },
|
106
|
+
{ "peachpuff", { 255, 218, 185, 1 } }, { "peru", { 205, 133, 63, 1 } },
|
107
|
+
{ "pink", { 255, 192, 203, 1 } }, { "plum", { 221, 160, 221, 1 } },
|
108
|
+
{ "powderblue", { 176, 224, 230, 1 } }, { "purple", { 128, 0, 128, 1 } },
|
109
|
+
{ "red", { 255, 0, 0, 1 } }, { "rosybrown", { 188, 143, 143, 1 } },
|
110
|
+
{ "royalblue", { 65, 105, 225, 1 } }, { "saddlebrown", { 139, 69, 19, 1 } },
|
111
|
+
{ "salmon", { 250, 128, 114, 1 } }, { "sandybrown", { 244, 164, 96, 1 } },
|
112
|
+
{ "seagreen", { 46, 139, 87, 1 } }, { "seashell", { 255, 245, 238, 1 } },
|
113
|
+
{ "sienna", { 160, 82, 45, 1 } }, { "silver", { 192, 192, 192, 1 } },
|
114
|
+
{ "skyblue", { 135, 206, 235, 1 } }, { "slateblue", { 106, 90, 205, 1 } },
|
115
|
+
{ "slategray", { 112, 128, 144, 1 } }, { "slategrey", { 112, 128, 144, 1 } },
|
116
|
+
{ "snow", { 255, 250, 250, 1 } }, { "springgreen", { 0, 255, 127, 1 } },
|
117
|
+
{ "steelblue", { 70, 130, 180, 1 } }, { "tan", { 210, 180, 140, 1 } },
|
118
|
+
{ "teal", { 0, 128, 128, 1 } }, { "thistle", { 216, 191, 216, 1 } },
|
119
|
+
{ "tomato", { 255, 99, 71, 1 } }, { "turquoise", { 64, 224, 208, 1 } },
|
120
|
+
{ "violet", { 238, 130, 238, 1 } }, { "wheat", { 245, 222, 179, 1 } },
|
121
|
+
{ "white", { 255, 255, 255, 1 } }, { "whitesmoke", { 245, 245, 245, 1 } },
|
122
|
+
{ "yellow", { 255, 255, 0, 1 } }, { "yellowgreen", { 154, 205, 50, 1 } }
|
123
|
+
};
|
124
|
+
|
125
|
+
template <typename T>
|
126
|
+
uint8_t clamp_css_byte(T i) { // Clamp to integer 0 .. 255.
|
127
|
+
i = ::round(i); // Seems to be what Chrome does (vs truncation).
|
128
|
+
return i < 0 ? 0 : i > 255 ? 255 : uint8_t(i);
|
129
|
+
}
|
130
|
+
|
131
|
+
template <typename T>
|
132
|
+
float clamp_css_float(T f) { // Clamp to float 0.0 .. 1.0.
|
133
|
+
return f < 0 ? 0 : f > 1 ? 1 : float(f);
|
134
|
+
}
|
135
|
+
|
136
|
+
float parseFloat(const std::string& str) {
|
137
|
+
return strtof(str.c_str(), nullptr);
|
138
|
+
}
|
139
|
+
|
140
|
+
int64_t parseInt(const std::string& str, uint8_t base = 10) {
|
141
|
+
return strtoll(str.c_str(), nullptr, base);
|
142
|
+
}
|
143
|
+
|
144
|
+
uint8_t parse_css_int(const std::string& str) { // int or percentage.
|
145
|
+
if (str.length() && str.back() == '%') {
|
146
|
+
return clamp_css_byte(parseFloat(str) / 100.0f * 255.0f);
|
147
|
+
} else {
|
148
|
+
return clamp_css_byte(parseInt(str));
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
float parse_css_float(const std::string& str) { // float or percentage.
|
153
|
+
if (str.length() && str.back() == '%') {
|
154
|
+
return clamp_css_float(parseFloat(str) / 100.0f);
|
155
|
+
} else {
|
156
|
+
return clamp_css_float(parseFloat(str));
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
float css_hue_to_rgb(float m1, float m2, float h) {
|
161
|
+
if (h < 0.0f) {
|
162
|
+
h += 1.0f;
|
163
|
+
} else if (h > 1.0f) {
|
164
|
+
h -= 1.0f;
|
165
|
+
}
|
166
|
+
|
167
|
+
if (h * 6.0f < 1.0f) {
|
168
|
+
return m1 + (m2 - m1) * h * 6.0f;
|
169
|
+
}
|
170
|
+
if (h * 2.0f < 1.0f) {
|
171
|
+
return m2;
|
172
|
+
}
|
173
|
+
if (h * 3.0f < 2.0f) {
|
174
|
+
return m1 + (m2 - m1) * (2.0f / 3.0f - h) * 6.0f;
|
175
|
+
}
|
176
|
+
return m1;
|
177
|
+
}
|
178
|
+
|
179
|
+
std::vector<std::string> split(const std::string& s, char delim) {
|
180
|
+
std::vector<std::string> elems;
|
181
|
+
std::stringstream ss(s);
|
182
|
+
std::string item;
|
183
|
+
while (std::getline(ss, item, delim)) {
|
184
|
+
elems.push_back(item);
|
185
|
+
}
|
186
|
+
return elems;
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
inline bool operator==(const Color& lhs, const Color& rhs) {
|
191
|
+
return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b && ::fabs(lhs.a - rhs.a) < 0.0001f;
|
192
|
+
}
|
193
|
+
|
194
|
+
inline bool operator!=(const Color& lhs, const Color& rhs) {
|
195
|
+
return !(lhs == rhs);
|
196
|
+
}
|
197
|
+
|
198
|
+
Color parse(const std::string& css_str) {
|
199
|
+
std::string str = css_str;
|
200
|
+
|
201
|
+
// Remove all whitespace, not compliant, but should just be more accepting.
|
202
|
+
str.erase(std::remove(str.begin(), str.end(), ' '), str.end());
|
203
|
+
|
204
|
+
// Convert to lowercase.
|
205
|
+
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
|
206
|
+
|
207
|
+
for (const auto& namedColor : namedColors) {
|
208
|
+
if (str == namedColor.name) {
|
209
|
+
return { namedColor.color };
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
// #abc and #abc123 syntax.
|
214
|
+
if (str.length() && str.front() == '#') {
|
215
|
+
auto iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
|
216
|
+
if (str.length() == 4) {
|
217
|
+
if (!(iv >= 0 && iv <= 0xfff)) {
|
218
|
+
return {};
|
219
|
+
} else {
|
220
|
+
return {
|
221
|
+
static_cast<uint8_t>(((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8)),
|
222
|
+
static_cast<uint8_t>((iv & 0xf0) | ((iv & 0xf0) >> 4)),
|
223
|
+
static_cast<uint8_t>((iv & 0xf) | ((iv & 0xf) << 4)),
|
224
|
+
1
|
225
|
+
};
|
226
|
+
}
|
227
|
+
} else if (str.length() == 7) {
|
228
|
+
if (!(iv >= 0 && iv <= 0xffffff)) {
|
229
|
+
return {}; // Covers NaN.
|
230
|
+
} else {
|
231
|
+
return {
|
232
|
+
static_cast<uint8_t>((iv & 0xff0000) >> 16),
|
233
|
+
static_cast<uint8_t>((iv & 0xff00) >> 8),
|
234
|
+
static_cast<uint8_t>(iv & 0xff),
|
235
|
+
1
|
236
|
+
};
|
237
|
+
}
|
238
|
+
}else if (str.length() == 5) {
|
239
|
+
// #rgba
|
240
|
+
if (!(iv >= 0 && iv <= 0xffff)) return {}; // Covers NaN.
|
241
|
+
return {
|
242
|
+
static_cast<uint8_t>(((iv & 0xf000) >> 8) | ((iv & 0xf000) >> 12)),
|
243
|
+
static_cast<uint8_t>(((iv & 0x0f00) >> 4) | ((iv & 0x0f00) >> 8)),
|
244
|
+
static_cast<uint8_t>((iv & 0x00f0) | ((iv & 0x00f0) >> 4)),
|
245
|
+
static_cast<uint8_t>(((iv & 0x000f) << 4 | (iv & 0x000f))) / 255.0f
|
246
|
+
};
|
247
|
+
} else if (str.length() == 9) {
|
248
|
+
// #rrggbbaa
|
249
|
+
if (!(iv >= 0 && iv <= 0xffffffff)) return {}; // Covers NaN.
|
250
|
+
return {
|
251
|
+
static_cast<uint8_t>(((iv & 0xff000000) >> 24) & 0xff),
|
252
|
+
static_cast<uint8_t>((iv & 0x00ff0000) >> 16),
|
253
|
+
static_cast<uint8_t>((iv & 0x0000ff00) >> 8),
|
254
|
+
static_cast<uint8_t>((iv & 0x000000ff)) / 255.0f
|
255
|
+
};
|
256
|
+
}
|
257
|
+
|
258
|
+
return {};
|
259
|
+
}
|
260
|
+
|
261
|
+
size_t op = str.find_first_of('('), ep = str.find_first_of(')');
|
262
|
+
if (op != std::string::npos && ep + 1 == str.length()) {
|
263
|
+
const std::string fname = str.substr(0, op);
|
264
|
+
const std::vector<std::string> params = split(str.substr(op + 1, ep - (op + 1)), ',');
|
265
|
+
|
266
|
+
float alpha = 1.0f;
|
267
|
+
|
268
|
+
if (fname == "rgba" || fname == "rgb") {
|
269
|
+
if (fname == "rgba") {
|
270
|
+
if (params.size() != 4) {
|
271
|
+
return { };
|
272
|
+
}
|
273
|
+
alpha = parse_css_float(params.back());
|
274
|
+
} else {
|
275
|
+
if (params.size() != 3) {
|
276
|
+
return { };
|
277
|
+
}
|
278
|
+
}
|
279
|
+
|
280
|
+
return {
|
281
|
+
parse_css_int(params[0]),
|
282
|
+
parse_css_int(params[1]),
|
283
|
+
parse_css_int(params[2]),
|
284
|
+
alpha
|
285
|
+
};
|
286
|
+
|
287
|
+
} else if (fname == "hsla" || fname == "hsl") {
|
288
|
+
if (fname == "hsla") {
|
289
|
+
if (params.size() != 4) {
|
290
|
+
return { };
|
291
|
+
}
|
292
|
+
alpha = parse_css_float(params.back());
|
293
|
+
} else {
|
294
|
+
if (params.size() != 3) {
|
295
|
+
return { };
|
296
|
+
}
|
297
|
+
}
|
298
|
+
|
299
|
+
float h = parseFloat(params[0]) / 360.0f;
|
300
|
+
float i;
|
301
|
+
// Normalize the hue to [0..1[
|
302
|
+
h = std::modf(h, &i);
|
303
|
+
|
304
|
+
// NOTE(deanm): According to the CSS spec s/l should only be
|
305
|
+
// percentages, but we don't bother and let float or percentage.
|
306
|
+
float s = parse_css_float(params[1]);
|
307
|
+
float l = parse_css_float(params[2]);
|
308
|
+
|
309
|
+
float m2 = l <= 0.5f ? l * (s + 1.0f) : l + s - l * s;
|
310
|
+
float m1 = l * 2.0f - m2;
|
311
|
+
|
312
|
+
return {
|
313
|
+
clamp_css_byte(css_hue_to_rgb(m1, m2, h + 1.0f / 3.0f) * 255.0f),
|
314
|
+
clamp_css_byte(css_hue_to_rgb(m1, m2, h) * 255.0f),
|
315
|
+
clamp_css_byte(css_hue_to_rgb(m1, m2, h - 1.0f / 3.0f) * 255.0f),
|
316
|
+
alpha
|
317
|
+
};
|
318
|
+
}
|
319
|
+
}
|
320
|
+
|
321
|
+
return { };
|
322
|
+
}
|
323
|
+
|
324
|
+
} // namespace CSSColorParser
|
@@ -15,7 +15,7 @@ using namespace facebook;
|
|
15
15
|
/**
|
16
16
|
Implements an animation that can be used to drive other values
|
17
17
|
*/
|
18
|
-
class RNSkAnimation : public RNSkClockValue
|
18
|
+
class RNSkAnimation : public RNSkClockValue
|
19
19
|
{
|
20
20
|
|
21
21
|
public:
|
@@ -23,8 +23,8 @@ public:
|
|
23
23
|
size_t identifier,
|
24
24
|
jsi::Runtime& runtime,
|
25
25
|
const jsi::Value *arguments,
|
26
|
-
size_t count)
|
27
|
-
|
26
|
+
size_t count) :
|
27
|
+
RNSkClockValue(platformContext, identifier, runtime, arguments, count) {
|
28
28
|
// Save the update function
|
29
29
|
_updateFunction = std::make_shared<jsi::Function>(arguments[0].asObject(runtime).asFunction(runtime));
|
30
30
|
|
@@ -32,10 +32,7 @@ public:
|
|
32
32
|
_args[1] = jsi::Value::undefined();
|
33
33
|
}
|
34
34
|
|
35
|
-
~RNSkAnimation() {
|
36
|
-
// We need to stop/unsubscribe
|
37
|
-
stopClock();
|
38
|
-
}
|
35
|
+
virtual ~RNSkAnimation() {}
|
39
36
|
|
40
37
|
JSI_HOST_FUNCTION(cancel) {
|
41
38
|
stopClock();
|
@@ -8,7 +8,6 @@
|
|
8
8
|
#include <algorithm>
|
9
9
|
#include <functional>
|
10
10
|
#include <chrono>
|
11
|
-
#include <mutex>
|
12
11
|
|
13
12
|
namespace RNSkia
|
14
13
|
{
|
@@ -38,7 +37,7 @@ public:
|
|
38
37
|
update(_runtime, static_cast<double>(0));
|
39
38
|
}
|
40
39
|
|
41
|
-
~RNSkClockValue() {
|
40
|
+
virtual ~RNSkClockValue() {
|
42
41
|
stopClock();
|
43
42
|
}
|
44
43
|
|
@@ -100,10 +99,11 @@ protected:
|
|
100
99
|
return;
|
101
100
|
}
|
102
101
|
|
103
|
-
// Avoid moving on if we are being called after the dtor was started
|
104
102
|
// Ensure we call any updates from the draw loop on the javascript thread
|
105
103
|
getContext()->runOnJavascriptThread(
|
106
|
-
|
104
|
+
// To ensure that this shared_ptr instance is not deallocated before we are done
|
105
|
+
// running the update lambda we pass a shared from this to the lambda scope.
|
106
|
+
[self = shared_from_this(), this]() {
|
107
107
|
if(_state == RNSkClockState::Running) {
|
108
108
|
auto now = std::chrono::high_resolution_clock::now();
|
109
109
|
auto deltaFromStart = std::chrono::duration_cast<std::chrono::milliseconds>(now - _start).count();
|
@@ -4,9 +4,7 @@
|
|
4
4
|
#include <algorithm>
|
5
5
|
#include <functional>
|
6
6
|
#include <chrono>
|
7
|
-
#include <mutex>
|
8
7
|
#include <unordered_map>
|
9
|
-
#include <utility>
|
10
8
|
#include <memory>
|
11
9
|
|
12
10
|
#include <jsi/jsi.h>
|
@@ -22,16 +20,15 @@ using namespace facebook;
|
|
22
20
|
Implements a readonly Value that is updated every time the screen is redrawn. Its value will be the
|
23
21
|
number of milliseconds since the animation value was started.
|
24
22
|
*/
|
25
|
-
class RNSkReadonlyValue : public JsiSkHostObject
|
23
|
+
class RNSkReadonlyValue : public JsiSkHostObject,
|
24
|
+
public std::enable_shared_from_this<RNSkReadonlyValue>
|
26
25
|
{
|
27
26
|
public:
|
28
27
|
RNSkReadonlyValue(std::shared_ptr<RNSkPlatformContext> platformContext)
|
29
28
|
: JsiSkHostObject(platformContext),
|
30
29
|
_propNameId(jsi::PropNameID::forUtf8(*platformContext->getJsRuntime(), "value")) {}
|
31
30
|
|
32
|
-
~RNSkReadonlyValue() {
|
33
|
-
_invalidated = true;
|
34
|
-
}
|
31
|
+
virtual ~RNSkReadonlyValue() { }
|
35
32
|
|
36
33
|
JSI_PROPERTY_GET(__typename__) {
|
37
34
|
return jsi::String::createFromUtf8(runtime, "RNSkValue");
|
@@ -43,8 +40,7 @@ public:
|
|
43
40
|
|
44
41
|
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(RNSkReadonlyValue, __typename__),
|
45
42
|
JSI_EXPORT_PROP_GET(RNSkReadonlyValue, current))
|
46
|
-
|
47
|
-
|
43
|
+
|
48
44
|
JSI_HOST_FUNCTION(addListener) {
|
49
45
|
if(!arguments[0].isObject() || !arguments[0].asObject(runtime).isFunction(runtime)) {
|
50
46
|
jsi::detail::throwJSError(runtime, "Expected function as first parameter.");
|
@@ -52,7 +48,9 @@ public:
|
|
52
48
|
}
|
53
49
|
auto callback = std::make_shared<jsi::Function>(arguments[0].asObject(runtime).asFunction(runtime));
|
54
50
|
|
55
|
-
auto unsubscribe = addListener([
|
51
|
+
auto unsubscribe = addListener([self = shared_from_this(),
|
52
|
+
this,
|
53
|
+
callback = std::move(callback)](jsi::Runtime& runtime){
|
56
54
|
callback->call(runtime, get_current(runtime));
|
57
55
|
});
|
58
56
|
|
@@ -76,10 +74,8 @@ public:
|
|
76
74
|
std::lock_guard<std::mutex> lock(_mutex);
|
77
75
|
auto listenerId = _listenerId++;
|
78
76
|
_listeners.emplace(listenerId, cb);
|
79
|
-
return [this, listenerId]() {
|
80
|
-
|
81
|
-
removeListener(listenerId);
|
82
|
-
}
|
77
|
+
return [self = shared_from_this(), this, listenerId]() {
|
78
|
+
removeListener(listenerId);
|
83
79
|
};
|
84
80
|
}
|
85
81
|
|
@@ -128,8 +124,6 @@ protected:
|
|
128
124
|
_listeners.erase(listenerId);
|
129
125
|
}
|
130
126
|
|
131
|
-
std::atomic<bool> _invalidated = { false };
|
132
|
-
|
133
127
|
private:
|
134
128
|
jsi::PropNameID _propNameId;
|
135
129
|
std::shared_ptr<jsi::Object> _valueHolder;
|
@@ -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
|
}
|
@@ -27,7 +27,7 @@ const onDraw = (0, _nodes.createDrawing)((_ref, _ref2) => {
|
|
27
27
|
...pathProps
|
28
28
|
} = _ref2;
|
29
29
|
const hasStartOffset = start !== 0;
|
30
|
-
const hasEndOffset =
|
30
|
+
const hasEndOffset = end !== 1;
|
31
31
|
const hasStrokeOptions = stroke !== undefined;
|
32
32
|
const willMutatePath = hasStartOffset || hasEndOffset || hasStrokeOptions;
|
33
33
|
const pristinePath = (0, _processors.processPath)(pathProps.path);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Path.tsx"],"names":["onDraw","canvas","paint","start","end","stroke","pathProps","hasStartOffset","hasEndOffset","hasStrokeOptions","undefined","willMutatePath","pristinePath","path","copy","trim","drawPath","Path","props","defaultProps"],"mappings":";;;;;;;AAAA;;AAOA;;AACA;;;;;;AAeA,MAAMA,MAAM,GAAG,0BACb,iBAA6D;AAAA,MAA5D;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA4D;AAAA,MAAzC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,GAAT;AAAcC,IAAAA,MAAd;AAAsB,OAAGC;AAAzB,GAAyC;AAC3D,QAAMC,cAAc,GAAGJ,KAAK,KAAK,CAAjC;AACA,QAAMK,YAAY,
|
1
|
+
{"version":3,"sources":["Path.tsx"],"names":["onDraw","canvas","paint","start","end","stroke","pathProps","hasStartOffset","hasEndOffset","hasStrokeOptions","undefined","willMutatePath","pristinePath","path","copy","trim","drawPath","Path","props","defaultProps"],"mappings":";;;;;;;AAAA;;AAOA;;AACA;;;;;;AAeA,MAAMA,MAAM,GAAG,0BACb,iBAA6D;AAAA,MAA5D;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA4D;AAAA,MAAzC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,GAAT;AAAcC,IAAAA,MAAd;AAAsB,OAAGC;AAAzB,GAAyC;AAC3D,QAAMC,cAAc,GAAGJ,KAAK,KAAK,CAAjC;AACA,QAAMK,YAAY,GAAGJ,GAAG,KAAK,CAA7B;AACA,QAAMK,gBAAgB,GAAGJ,MAAM,KAAKK,SAApC;AACA,QAAMC,cAAc,GAAGJ,cAAc,IAAIC,YAAlB,IAAkCC,gBAAzD;AACA,QAAMG,YAAY,GAAG,6BAAYN,SAAS,CAACO,IAAtB,CAArB;AACA,QAAMA,IAAI,GAAGF,cAAc,GAAGC,YAAY,CAACE,IAAb,EAAH,GAAyBF,YAApD;;AACA,MAAIH,gBAAJ,EAAsB;AACpBI,IAAAA,IAAI,CAACR,MAAL,CAAYA,MAAZ;AACD;;AACD,MAAIE,cAAc,IAAIC,YAAtB,EAAoC;AAClCK,IAAAA,IAAI,CAACE,IAAL,CAAUZ,KAAV,EAAiBC,GAAjB,EAAsB,KAAtB;AACD;;AACDH,EAAAA,MAAM,CAACe,QAAP,CAAgBH,IAAhB,EAAsBX,KAAtB;AACD,CAfY,CAAf;;AAkBO,MAAMe,IAAI,GAAIC,KAAD,IAAqC;AACvD,sBAAO;AAAW,IAAA,MAAM,EAAElB;AAAnB,KAA+BkB,KAA/B,EAAP;AACD,CAFM;;;AAIPD,IAAI,CAACE,YAAL,GAAoB;AAClBhB,EAAAA,KAAK,EAAE,CADW;AAElBC,EAAAA,GAAG,EAAE;AAFa,CAApB","sourcesContent":["import React from \"react\";\n\nimport type {\n CustomPaintProps,\n AnimatedProps,\n PathDef,\n} from \"../../processors\";\nimport { createDrawing } from \"../../nodes\";\nimport { processPath } from \"../../processors\";\n\ninterface StrokeOpts {\n width?: number;\n strokeMiterlimit?: number;\n precision?: number;\n}\n\nexport interface PathProps extends CustomPaintProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n}\n\nconst onDraw = createDrawing<PathProps>(\n ({ canvas, paint }, { start, end, stroke, ...pathProps }) => {\n const hasStartOffset = start !== 0;\n const hasEndOffset = end !== 1;\n const hasStrokeOptions = stroke !== undefined;\n const willMutatePath = hasStartOffset || hasEndOffset || hasStrokeOptions;\n const pristinePath = processPath(pathProps.path);\n const path = willMutatePath ? pristinePath.copy() : pristinePath;\n if (hasStrokeOptions) {\n path.stroke(stroke);\n }\n if (hasStartOffset || hasEndOffset) {\n path.trim(start, end, false);\n }\n canvas.drawPath(path, paint);\n }\n);\n\nexport const Path = (props: AnimatedProps<PathProps>) => {\n return <skDrawing onDraw={onDraw} {...props} />;\n};\n\nPath.defaultProps = {\n start: 0,\n end: 1,\n};\n"]}
|
@@ -48,7 +48,9 @@ class Node {
|
|
48
48
|
visit(ctx, children) {
|
49
49
|
const returnedValues = [];
|
50
50
|
(children !== null && children !== void 0 ? children : this.children).forEach(child => {
|
51
|
-
if (
|
51
|
+
if (child.memoized && child.memoizable) {
|
52
|
+
returnedValues.push(child.memoized);
|
53
|
+
} else {
|
52
54
|
const ret = child.draw(ctx);
|
53
55
|
|
54
56
|
if (ret) {
|
@@ -58,8 +60,6 @@ class Node {
|
|
58
60
|
child.memoized = ret;
|
59
61
|
}
|
60
62
|
}
|
61
|
-
} else {
|
62
|
-
returnedValues.push(child.memoized);
|
63
63
|
}
|
64
64
|
});
|
65
65
|
return returnedValues;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Node.ts"],"names":["NodeType","Node","constructor","depMgr","props","_props","unSubscribeNode","subscribeNode","visit","ctx","children","returnedValues","forEach","child","memoized","
|
1
|
+
{"version":3,"sources":["Node.ts"],"names":["NodeType","Node","constructor","depMgr","props","_props","unSubscribeNode","subscribeNode","visit","ctx","children","returnedValues","forEach","child","memoized","memoizable","push","ret","draw"],"mappings":";;;;;;;;;IAKYA,Q;;;WAAAA,Q;AAAAA,EAAAA,Q;AAAAA,EAAAA,Q;GAAAA,Q,wBAAAA,Q;;AAOL,MAAeC,IAAf,CAAiC;AAQtCC,EAAAA,WAAW,CAACC,MAAD,EAA4BC,KAA5B,EAAqD;AAAA,sCAPpC,EAOoC;;AAAA;;AAAA,wCALnD,KAKmD;;AAAA,sCAJ3B,IAI2B;;AAAA;;AAAA;;AAC9D,SAAKC,MAAL,GAAcD,KAAd;AACA,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKA,MAAL,CAAYG,eAAZ,CAA4B,IAA5B;AACA,SAAKH,MAAL,CAAYI,aAAZ,CAA0B,IAA1B,EAAgCH,KAAhC;AACD;;AAIQ,MAALA,KAAK,CAACA,KAAD,EAA0B;AACjC,SAAKD,MAAL,CAAYG,eAAZ,CAA4B,IAA5B;AACA,SAAKH,MAAL,CAAYI,aAAZ,CAA0B,IAA1B,EAAgCH,KAAhC;AACA,SAAKC,MAAL,GAAcD,KAAd;AACD;;AAEQ,MAALA,KAAK,GAAG;AACV,WAAO,KAAKC,MAAZ;AACD;;AAEDG,EAAAA,KAAK,CAACC,GAAD,EAAsBC,QAAtB,EAAyC;AAC5C,UAAMC,cAAkD,GAAG,EAA3D;AACA,KAACD,QAAD,aAACA,QAAD,cAACA,QAAD,GAAa,KAAKA,QAAlB,EAA4BE,OAA5B,CAAqCC,KAAD,IAAW;AAC7C,UAAIA,KAAK,CAACC,QAAN,IAAkBD,KAAK,CAACE,UAA5B,EAAwC;AACtCJ,QAAAA,cAAc,CAACK,IAAf,CAAoBH,KAAK,CAACC,QAA1B;AACD,OAFD,MAEO;AACL,cAAMG,GAAG,GAAGJ,KAAK,CAACK,IAAN,CAAWT,GAAX,CAAZ;;AACA,YAAIQ,GAAJ,EAAS;AACPN,UAAAA,cAAc,CAACK,IAAf,CAAoBC,GAApB;;AACA,cAAIJ,KAAK,CAACE,UAAV,EAAsB;AACpBF,YAAAA,KAAK,CAACC,QAAN,GAAiBG,GAAjB;AACD;AACF;AACF;AACF,KAZD;AAaA,WAAON,cAAP;AACD;;AA3CqC","sourcesContent":["import type { SkJSIInstance } from \"../../skia/JsiInstance\";\nimport type { DependencyManager } from \"../DependencyManager\";\nimport type { DrawingContext } from \"../DrawingContext\";\nimport type { AnimatedProps } from \"../processors\";\n\nexport enum NodeType {\n Declaration = \"skDeclaration\",\n Drawing = \"skDrawing\",\n}\n\ntype DeclarationResult = SkJSIInstance<string> | null;\n\nexport abstract class Node<P = unknown> {\n readonly children: Node[] = [];\n _props: AnimatedProps<P>;\n memoizable = false;\n memoized: DeclarationResult | null = null;\n parent?: Node;\n depMgr: DependencyManager;\n\n constructor(depMgr: DependencyManager, props: AnimatedProps<P>) {\n this._props = props;\n this.depMgr = depMgr;\n this.depMgr.unSubscribeNode(this);\n this.depMgr.subscribeNode(this, props);\n }\n\n abstract draw(ctx: DrawingContext): void | DeclarationResult;\n\n set props(props: AnimatedProps<P>) {\n this.depMgr.unSubscribeNode(this);\n this.depMgr.subscribeNode(this, props);\n this._props = props;\n }\n\n get props() {\n return this._props;\n }\n\n visit(ctx: DrawingContext, children?: Node[]) {\n const returnedValues: Exclude<DeclarationResult, null>[] = [];\n (children ?? this.children).forEach((child) => {\n if (child.memoized && child.memoizable) {\n returnedValues.push(child.memoized);\n } else {\n const ret = child.draw(ctx);\n if (ret) {\n returnedValues.push(ret);\n if (child.memoizable) {\n child.memoized = ret;\n }\n }\n }\n });\n return returnedValues;\n }\n}\n"]}
|
@@ -3,9 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.rgbaColor = exports.red = exports.processColorAsUnitArray = exports.
|
6
|
+
exports.rgbaColor = exports.red = exports.processColorAsUnitArray = exports.processColor = exports.green = exports.blue = exports.alphaf = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _Skia = require("./Skia");
|
9
9
|
|
10
10
|
const alphaf = c => (c >> 24 & 255) / 255;
|
11
11
|
|
@@ -30,30 +30,8 @@ const rgbaColor = (r, g, b, af) => {
|
|
30
30
|
|
31
31
|
exports.rgbaColor = rgbaColor;
|
32
32
|
|
33
|
-
const processColorAsInt = color => {
|
34
|
-
let processedColor = (0, _reactNative.processColor)(color);
|
35
|
-
|
36
|
-
if (typeof processedColor !== "number") {
|
37
|
-
throw new Error(`Couldn't process color: ${color}`);
|
38
|
-
} // On android we need to move the alpha byte to the start of the structure
|
39
|
-
|
40
|
-
|
41
|
-
if (_reactNative.Platform.OS === "android") {
|
42
|
-
processedColor = processedColor >>> 0;
|
43
|
-
const a = processedColor >> 24 & 0xff;
|
44
|
-
const r = processedColor >> 16 & 0xff;
|
45
|
-
const g = processedColor >> 8 & 0xff;
|
46
|
-
const b = processedColor & 0xff;
|
47
|
-
processedColor = (a << 24 | r << 16 | g << 8 | b) >>> 0;
|
48
|
-
}
|
49
|
-
|
50
|
-
return processedColor;
|
51
|
-
};
|
52
|
-
|
53
|
-
exports.processColorAsInt = processColorAsInt;
|
54
|
-
|
55
33
|
const processColorAsArray = cl => {
|
56
|
-
const icl = typeof cl === "string" ?
|
34
|
+
const icl = typeof cl === "string" ? _Skia.Skia.Color(cl) : cl;
|
57
35
|
const r = red(icl);
|
58
36
|
const g = green(icl);
|
59
37
|
const b = blue(icl);
|