Skip to content

Commit 8eb0c1e

Browse files
authored
fix(⬆️): Upgrade to Skia m147 (#3800)
1 parent 1048128 commit 8eb0c1e

File tree

26 files changed

+381
-288
lines changed

26 files changed

+381
-288
lines changed

.github/workflows/build-skia.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ jobs:
8181
include:
8282
- target: "apple-ios"
8383
artifact_name: "skia-apple-ios-xcframeworks"
84-
package_root: "./packages/skia/libs/apple/ios"
84+
package_root: "./packages/skia/libs/ios"
8585
- target: "apple-tvos"
8686
artifact_name: "skia-apple-tvos-xcframeworks"
87-
package_root: "./packages/skia/libs/apple/tvos"
87+
package_root: "./packages/skia/libs/tvos"
8888
- target: "apple-macos"
8989
artifact_name: "skia-apple-macos-xcframeworks"
90-
package_root: "./packages/skia/libs/apple/macos"
90+
package_root: "./packages/skia/libs/macos"
9191
- target: "android-arm"
9292
artifact_name: "skia-android-arm"
9393
package_root: "./packages/skia/libs/android/armeabi-v7a"

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[submodule "externals/skia"]
22
path = externals/skia
33
url = https://chromium.googlesource.com/skia/
4-
branch = chrome/m144
4+
branch = chrome/m147
55
[submodule "externals/depot_tools"]
66
path = externals/depot_tools
77
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
20.3 KB
Loading
-251 Bytes
Loading

apps/example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3245,7 +3245,7 @@ SPEC CHECKSUMS:
32453245
React-Mapbuffer: 7b72a669e94662359dad4f42b5af005eb24b4e83
32463246
React-microtasksnativemodule: cdc02da075f2857803ed63f24f5f72fc40e094c0
32473247
react-native-safe-area-context: c00143b4823773bba23f2f19f85663ae89ceb460
3248-
react-native-skia: f6b26c5aca2c9f93fd5ca00a745bad8769330245
3248+
react-native-skia: 03e5c42eb263a22f9228d3cbfaa140fcaad08408
32493249
React-NativeModulesApple: a2c3d2cbec893956a5b3e4060322db2984fff75b
32503250
React-networking: 3f98bd96893a294376e7e03730947a08d474c380
32513251
React-oscompat: 80166b66da22e7af7fad94474e9997bd52d4c8c6

externals/skia

Submodule skia updated from 7911bee to 4502f88

packages/skia/android/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ set_property(TARGET pathops PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libpat
214214
add_library(jsonreader STATIC IMPORTED)
215215
set_property(TARGET jsonreader PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libjsonreader.a")
216216

217-
# Dawn library for Graphite builds (contains dawn::native symbols)
218217
if(SK_GRAPHITE)
219218
add_library(dawn_combined STATIC IMPORTED)
220219
set_property(TARGET dawn_combined PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libdawn_combined.a")

packages/skia/cpp/api/JsiSkContourMeasure.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ class JsiSkContourMeasure
5858
auto start = arguments[0].asNumber();
5959
auto end = arguments[1].asNumber();
6060
auto startWithMoveTo = arguments[2].getBool();
61-
SkPath path;
62-
auto result = getObject()->getSegment(start, end, &path, startWithMoveTo);
61+
SkPathBuilder builder;
62+
auto result =
63+
getObject()->getSegment(start, end, &builder, startWithMoveTo);
6364
if (!result) {
6465
throw jsi::JSError(runtime, "getSegment() failed");
6566
}
66-
return JsiSkPath::toValue(runtime, getContext(), std::move(path));
67+
return JsiSkPath::toValue(runtime, getContext(), builder.snapshot());
6768
}
6869

6970
size_t getMemoryPressure() const override { return 1024; }

packages/skia/cpp/api/JsiSkParagraphBuilder.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919

2020
#include "modules/skparagraph/include/ParagraphBuilder.h"
2121

22+
#ifdef __APPLE__
23+
#include "modules/skunicode/include/SkUnicode_libgrapheme.h"
24+
#else
25+
#include "modules/skunicode/include/SkUnicode_icu.h"
26+
#endif
27+
2228
#pragma clang diagnostic pop
2329

2430
namespace RNSkia {
@@ -125,7 +131,14 @@ class JsiSkParagraphBuilder : public JsiSkHostObject {
125131
_fontCollection->setAssetFontManager(fontManager);
126132
}
127133
_fontCollection->enableFontFallback();
128-
_builder = para::ParagraphBuilder::make(paragraphStyle, _fontCollection);
134+
sk_sp<SkUnicode> unicode;
135+
#ifdef __APPLE__
136+
unicode = SkUnicodes::Libgrapheme::Make();
137+
#else
138+
unicode = SkUnicodes::ICU::Make();
139+
#endif
140+
_builder = para::ParagraphBuilder::make(paragraphStyle, _fontCollection,
141+
unicode);
129142
}
130143

131144
private:

packages/skia/cpp/api/JsiSkPathFactory.h

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,33 @@ class JsiSkPathFactory : public JsiSkHostObject {
5252

5353
JSI_HOST_FUNCTION(MakeFromSVGString) {
5454
auto svgString = arguments[0].asString(runtime).utf8(runtime);
55-
SkPath result;
56-
57-
if (!SkParsePath::FromSVGString(svgString.c_str(), &result)) {
55+
auto result = SkParsePath::FromSVGString(svgString.c_str());
56+
if (!result.has_value()) {
5857
throw jsi::JSError(runtime, "Could not parse Svg path");
5958
return jsi::Value(nullptr);
6059
}
61-
6260
auto hostObjectInstance =
63-
std::make_shared<JsiSkPath>(getContext(), std::move(result));
61+
std::make_shared<JsiSkPath>(getContext(), std::move(result.value()));
6462
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
6563
runtime, hostObjectInstance, getContext());
6664
}
6765

6866
JSI_HOST_FUNCTION(MakeFromOp) {
69-
SkPath one = JsiSkPath::fromValue(runtime, arguments[0])->snapshot();
70-
SkPath two = JsiSkPath::fromValue(runtime, arguments[1])->snapshot();
67+
auto one = JsiSkPath::fromValue(runtime, arguments[0])->snapshot();
68+
auto two = JsiSkPath::fromValue(runtime, arguments[1])->snapshot();
7169
SkPathOp op = (SkPathOp)arguments[2].asNumber();
72-
SkPath result;
73-
bool success = Op(one, two, op, &result);
74-
if (!success) {
70+
auto result = Op(one, two, op);
71+
if (!result.has_value()) {
7572
return jsi::Value(nullptr);
7673
}
7774
auto hostObjectInstance =
78-
std::make_shared<JsiSkPath>(getContext(), std::move(result));
75+
std::make_shared<JsiSkPath>(getContext(), std::move(result.value()));
7976
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
8077
runtime, hostObjectInstance, getContext());
8178
}
8279

8380
JSI_HOST_FUNCTION(MakeFromCmds) {
84-
SkPath path;
81+
SkPathBuilder builder;
8582
auto cmds = arguments[0].asObject(runtime).asArray(runtime);
8683
auto cmdCount = cmds.size(runtime);
8784
for (int i = 0; i < cmdCount; i++) {
@@ -100,7 +97,7 @@ class JsiSkPathFactory : public JsiSkHostObject {
10097
}
10198
auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
10299
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
103-
path.moveTo(x, y);
100+
builder.moveTo(x, y);
104101
break;
105102
}
106103
case LINE: {
@@ -110,7 +107,7 @@ class JsiSkPathFactory : public JsiSkHostObject {
110107
}
111108
auto x = cmd.getValueAtIndex(runtime, 1).asNumber();
112109
auto y = cmd.getValueAtIndex(runtime, 2).asNumber();
113-
path.lineTo(x, y);
110+
builder.lineTo(x, y);
114111
break;
115112
}
116113
case QUAD: {
@@ -122,7 +119,7 @@ class JsiSkPathFactory : public JsiSkHostObject {
122119
auto y1 = cmd.getValueAtIndex(runtime, 2).asNumber();
123120
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
124121
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
125-
path.quadTo(x1, y1, x2, y2);
122+
builder.quadTo(x1, y1, x2, y2);
126123
break;
127124
}
128125
case CONIC: {
@@ -135,7 +132,7 @@ class JsiSkPathFactory : public JsiSkHostObject {
135132
auto x2 = cmd.getValueAtIndex(runtime, 3).asNumber();
136133
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
137134
auto w = cmd.getValueAtIndex(runtime, 5).asNumber();
138-
path.conicTo(x1, y1, x2, y2, w);
135+
builder.conicTo(x1, y1, x2, y2, w);
139136
break;
140137
}
141138
case CUBIC: {
@@ -149,11 +146,11 @@ class JsiSkPathFactory : public JsiSkHostObject {
149146
auto y2 = cmd.getValueAtIndex(runtime, 4).asNumber();
150147
auto x3 = cmd.getValueAtIndex(runtime, 5).asNumber();
151148
auto y3 = cmd.getValueAtIndex(runtime, 6).asNumber();
152-
path.cubicTo(x1, y1, x2, y2, x3, y3);
149+
builder.cubicTo(x1, y1, x2, y2, x3, y3);
153150
break;
154151
}
155152
case CLOSE: {
156-
path.close();
153+
builder.close();
157154
break;
158155
}
159156
default: {
@@ -163,7 +160,7 @@ class JsiSkPathFactory : public JsiSkHostObject {
163160
}
164161
}
165162
auto hostObjectInstance =
166-
std::make_shared<JsiSkPath>(getContext(), std::move(path));
163+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
167164
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
168165
runtime, hostObjectInstance, getContext());
169166
}
@@ -189,10 +186,10 @@ class JsiSkPathFactory : public JsiSkHostObject {
189186
if (count >= 2 && arguments[1].getBool()) {
190187
direction = SkPathDirection::kCCW;
191188
}
192-
SkPath path;
193-
path.addRect(*rect, direction);
189+
SkPathBuilder builder;
190+
builder.addRect(*rect, direction);
194191
auto hostObjectInstance =
195-
std::make_shared<JsiSkPath>(getContext(), std::move(path));
192+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
196193
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
197194
runtime, hostObjectInstance, getContext());
198195
}
@@ -204,10 +201,10 @@ class JsiSkPathFactory : public JsiSkHostObject {
204201
direction = SkPathDirection::kCCW;
205202
}
206203
unsigned startIndex = count < 3 ? 0 : arguments[2].asNumber();
207-
SkPath path;
208-
path.addOval(*rect, direction, startIndex);
204+
SkPathBuilder builder;
205+
builder.addOval(*rect, direction, startIndex);
209206
auto hostObjectInstance =
210-
std::make_shared<JsiSkPath>(getContext(), std::move(path));
207+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
211208
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
212209
runtime, hostObjectInstance, getContext());
213210
}
@@ -216,10 +213,10 @@ class JsiSkPathFactory : public JsiSkHostObject {
216213
auto x = arguments[0].asNumber();
217214
auto y = arguments[1].asNumber();
218215
auto r = arguments[2].asNumber();
219-
SkPath path;
220-
path.addCircle(x, y, r);
216+
SkPathBuilder builder;
217+
builder.addCircle(x, y, r);
221218
auto hostObjectInstance =
222-
std::make_shared<JsiSkPath>(getContext(), std::move(path));
219+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
223220
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
224221
runtime, hostObjectInstance, getContext());
225222
}
@@ -230,10 +227,10 @@ class JsiSkPathFactory : public JsiSkHostObject {
230227
if (count >= 2 && arguments[1].getBool()) {
231228
direction = SkPathDirection::kCCW;
232229
}
233-
SkPath path;
234-
path.addRRect(*rrect, direction);
230+
SkPathBuilder builder;
231+
builder.addRRect(*rrect, direction);
235232
auto hostObjectInstance =
236-
std::make_shared<JsiSkPath>(getContext(), std::move(path));
233+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
237234
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
238235
runtime, hostObjectInstance, getContext());
239236
}
@@ -243,11 +240,11 @@ class JsiSkPathFactory : public JsiSkHostObject {
243240
runtime, arguments[0].asObject(runtime));
244241
auto p2 = JsiSkPoint::fromValue(
245242
runtime, arguments[1].asObject(runtime));
246-
SkPath path;
247-
path.moveTo(*p1);
248-
path.lineTo(*p2);
243+
SkPathBuilder builder;
244+
builder.moveTo(*p1);
245+
builder.lineTo(*p2);
249246
auto hostObjectInstance =
250-
std::make_shared<JsiSkPath>(getContext(), std::move(path));
247+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
251248
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
252249
runtime, hostObjectInstance, getContext());
253250
}
@@ -263,11 +260,10 @@ class JsiSkPathFactory : public JsiSkHostObject {
263260
runtime, jsiPoints.getValueAtIndex(runtime, i).asObject(runtime));
264261
points.push_back(*point.get());
265262
}
266-
SkPath path;
267-
auto p = SkSpan(points.data(), points.size());
268-
path.addPoly(p, close);
263+
SkPathBuilder builder;
264+
builder.addPolygon(SkSpan(points), close);
269265
auto hostObjectInstance =
270-
std::make_shared<JsiSkPath>(getContext(), std::move(path));
266+
std::make_shared<JsiSkPath>(getContext(), builder.snapshot());
271267
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
272268
runtime, hostObjectInstance, getContext());
273269
}
@@ -308,22 +304,23 @@ class JsiSkPathFactory : public JsiSkHostObject {
308304

309305
auto jsiPrecision = opts.getProperty(runtime, "precision");
310306
auto precision = jsiPrecision.isUndefined() ? 1 : jsiPrecision.asNumber();
311-
SkPath result;
307+
SkPathBuilder resultBuilder;
308+
auto ctm = SkMatrix::Scale(precision, precision);
312309
auto success =
313-
skpathutils::FillPathWithPaint(path, p, &result, nullptr, precision);
310+
skpathutils::FillPathWithPaint(path, p, &resultBuilder, nullptr, ctm);
314311
if (success) {
315312
auto hostObjectInstance =
316-
std::make_shared<JsiSkPath>(getContext(), std::move(result));
313+
std::make_shared<JsiSkPath>(getContext(), resultBuilder.snapshot());
317314
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
318315
runtime, hostObjectInstance, getContext());
319316
}
320317
} else {
321-
SkPath result;
318+
SkPathBuilder resultBuilder;
322319
auto success =
323-
skpathutils::FillPathWithPaint(path, p, &result, nullptr, 1);
320+
skpathutils::FillPathWithPaint(path, p, &resultBuilder);
324321
if (success) {
325322
auto hostObjectInstance =
326-
std::make_shared<JsiSkPath>(getContext(), std::move(result));
323+
std::make_shared<JsiSkPath>(getContext(), resultBuilder.snapshot());
327324
return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
328325
runtime, hostObjectInstance, getContext());
329326
}

0 commit comments

Comments
 (0)