@shopify/react-native-skia 2.0.0-next.3 → 2.0.0-next.5

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 (148) hide show
  1. package/apple/RNSkApplePlatformContext.h +2 -1
  2. package/apple/RNSkApplePlatformContext.mm +6 -4
  3. package/apple/RNSkAppleView.h +1 -1
  4. package/apple/RNSkAppleView.mm +1 -1
  5. package/apple/SkiaManager.mm +2 -1
  6. package/apple/SkiaUIView.h +1 -1
  7. package/cpp/api/JsiSkCanvas.h +29 -25
  8. package/cpp/api/recorder/Drawings.h +13 -17
  9. package/cpp/api/recorder/Shaders.h +21 -32
  10. package/cpp/skia/include/codec/SkCodec.h +39 -1
  11. package/cpp/skia/include/config/SkUserConfig.h +1 -10
  12. package/cpp/skia/include/core/SkCanvas.h +8 -4
  13. package/cpp/skia/include/core/SkContourMeasure.h +2 -2
  14. package/cpp/skia/include/core/SkMilestone.h +1 -1
  15. package/cpp/skia/include/core/SkPaint.h +8 -5
  16. package/cpp/skia/include/core/SkStream.h +8 -3
  17. package/cpp/skia/include/core/SkTextBlob.h +9 -9
  18. package/cpp/skia/include/core/SkTypeface.h +4 -6
  19. package/cpp/skia/include/core/SkTypes.h +5 -0
  20. package/cpp/skia/include/docs/SkPDFDocument.h +47 -2
  21. package/cpp/skia/include/docs/SkPDFJpegHelpers.h +41 -0
  22. package/cpp/skia/include/effects/SkRuntimeEffect.h +5 -1
  23. package/cpp/skia/include/effects/SkTableMaskFilter.h +4 -0
  24. package/cpp/skia/include/gpu/graphite/BackendTexture.h +0 -2
  25. package/cpp/skia/include/gpu/graphite/ContextOptions.h +17 -0
  26. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +21 -18
  27. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +24 -0
  28. package/cpp/skia/include/gpu/graphite/TextureInfo.h +87 -42
  29. package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +13 -4
  30. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +9 -0
  31. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +166 -0
  32. package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +3 -141
  33. package/cpp/skia/include/gpu/graphite/dawn/DawnUtils.h +2 -21
  34. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +4 -0
  35. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +30 -6
  36. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +4 -42
  37. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h +50 -0
  38. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteUtils.h +2 -20
  39. package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +14 -4
  40. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +14 -6
  41. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +31 -0
  42. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +36 -14
  43. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteUtils.h +3 -21
  44. package/cpp/skia/include/ports/SkTypeface_fontations.h +3 -0
  45. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +7 -0
  46. package/cpp/skia/include/private/base/SkAnySubclass.h +6 -0
  47. package/cpp/skia/include/private/chromium/SkPMColor.h +38 -0
  48. package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -2
  49. package/cpp/skia/modules/skunicode/include/SkUnicode.h +10 -6
  50. package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -3
  51. package/cpp/skia/src/base/SkTInternalLList.h +1 -1
  52. package/cpp/skia/src/core/SkLRUCache.h +6 -3
  53. package/lib/commonjs/external/reanimated/textures.d.ts +2 -4
  54. package/lib/commonjs/external/reanimated/textures.js +8 -15
  55. package/lib/commonjs/external/reanimated/textures.js.map +1 -1
  56. package/lib/commonjs/sksg/HostConfig.js +2 -1
  57. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  58. package/lib/module/external/reanimated/textures.d.ts +2 -4
  59. package/lib/module/external/reanimated/textures.js +7 -12
  60. package/lib/module/external/reanimated/textures.js.map +1 -1
  61. package/lib/module/sksg/HostConfig.js +2 -1
  62. package/lib/module/sksg/HostConfig.js.map +1 -1
  63. package/lib/typescript/lib/commonjs/external/reanimated/textures.d.ts +1 -3
  64. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -1
  65. package/lib/typescript/lib/module/external/reanimated/textures.d.ts +1 -3
  66. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -1
  67. package/lib/typescript/src/external/reanimated/textures.d.ts +2 -4
  68. package/libs/android/arm64-v8a/libskia.a +0 -0
  69. package/libs/android/arm64-v8a/libskottie.a +0 -0
  70. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  71. package/libs/android/arm64-v8a/libsksg.a +0 -0
  72. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  73. package/libs/android/arm64-v8a/libskunicode_icu.a +0 -0
  74. package/libs/android/arm64-v8a/libsvg.a +0 -0
  75. package/libs/android/armeabi-v7a/libskia.a +0 -0
  76. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  77. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  78. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  79. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  80. package/libs/android/armeabi-v7a/libskunicode_icu.a +0 -0
  81. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  82. package/libs/android/x86/libskia.a +0 -0
  83. package/libs/android/x86/libskottie.a +0 -0
  84. package/libs/android/x86/libskparagraph.a +0 -0
  85. package/libs/android/x86/libsksg.a +0 -0
  86. package/libs/android/x86/libskshaper.a +0 -0
  87. package/libs/android/x86/libskunicode_icu.a +0 -0
  88. package/libs/android/x86/libsvg.a +0 -0
  89. package/libs/android/x86_64/libskia.a +0 -0
  90. package/libs/android/x86_64/libskottie.a +0 -0
  91. package/libs/android/x86_64/libskparagraph.a +0 -0
  92. package/libs/android/x86_64/libsksg.a +0 -0
  93. package/libs/android/x86_64/libskshaper.a +0 -0
  94. package/libs/android/x86_64/libskunicode_icu.a +0 -0
  95. package/libs/android/x86_64/libsvg.a +0 -0
  96. package/libs/apple/libskia.xcframework/Info.plist +15 -15
  97. package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  98. package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  99. package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
  100. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
  101. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  102. package/libs/apple/libskottie.xcframework/Info.plist +7 -7
  103. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  104. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  105. package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
  106. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
  107. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  108. package/libs/apple/libskparagraph.xcframework/Info.plist +13 -13
  109. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  110. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  111. package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
  112. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
  113. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  114. package/libs/apple/libsksg.xcframework/Info.plist +13 -13
  115. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  116. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  117. package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
  118. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
  119. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  120. package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
  121. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  122. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  123. package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
  124. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
  125. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  126. package/libs/apple/libskunicode_core.xcframework/Info.plist +12 -12
  127. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
  128. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  129. package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
  130. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
  131. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  132. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +15 -15
  133. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  134. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  135. package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
  136. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  137. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  138. package/libs/apple/libsvg.xcframework/Info.plist +8 -8
  139. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  140. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  141. package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
  142. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
  143. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  144. package/package.json +1 -1
  145. package/src/external/reanimated/textures.tsx +12 -20
  146. package/src/sksg/HostConfig.ts +2 -1
  147. package/cpp/skia/include/core/SkColorPriv.h +0 -165
  148. package/cpp/skia/include/private/SkColorData.h +0 -385
@@ -26,7 +26,8 @@ public:
26
26
  #if !TARGET_OS_OSX
27
27
  : RNSkPlatformContext(jsCallInvoker, [[UIScreen mainScreen] scale]) {
28
28
  #else
29
- : RNSkPlatformContext(jsCallInvoker, [[NSScreen mainScreen] backingScaleFactor]) {
29
+ : RNSkPlatformContext(jsCallInvoker,
30
+ [[NSScreen mainScreen] backingScaleFactor]) {
30
31
  #endif // !TARGET_OS_OSX
31
32
 
32
33
  // Create screenshot manager
@@ -173,7 +173,8 @@ const TextureInfo RNSkApplePlatformContext::getTexture(sk_sp<SkImage> image) {
173
173
  return result;
174
174
  }
175
175
 
176
- const TextureInfo RNSkApplePlatformContext::getTexture(sk_sp<SkSurface> surface) {
176
+ const TextureInfo
177
+ RNSkApplePlatformContext::getTexture(sk_sp<SkSurface> surface) {
177
178
  GrBackendTexture texture = SkSurfaces::GetBackendTexture(
178
179
  surface.get(), SkSurfaces::BackendHandleAccess::kFlushRead);
179
180
  TextureInfo result;
@@ -195,7 +196,7 @@ RNSkApplePlatformContext::createVideo(const std::string &url) {
195
196
 
196
197
  std::shared_ptr<WindowContext>
197
198
  RNSkApplePlatformContext::makeContextFromNativeSurface(void *surface, int width,
198
- int height) {
199
+ int height) {
199
200
  #if defined(SK_GRAPHITE)
200
201
  return DawnContext::getInstance().MakeWindow(surface, width, height);
201
202
  #else
@@ -209,7 +210,7 @@ void RNSkApplePlatformContext::raiseError(const std::exception &err) {
209
210
  }
210
211
 
211
212
  sk_sp<SkSurface> RNSkApplePlatformContext::makeOffscreenSurface(int width,
212
- int height) {
213
+ int height) {
213
214
  #if defined(SK_GRAPHITE)
214
215
  return DawnContext::getInstance().MakeOffscreen(width, height);
215
216
  #else
@@ -217,7 +218,8 @@ sk_sp<SkSurface> RNSkApplePlatformContext::makeOffscreenSurface(int width,
217
218
  #endif
218
219
  }
219
220
 
220
- sk_sp<SkImage> RNSkApplePlatformContext::makeImageFromNativeBuffer(void *buffer) {
221
+ sk_sp<SkImage>
222
+ RNSkApplePlatformContext::makeImageFromNativeBuffer(void *buffer) {
221
223
  #if defined(SK_GRAPHITE)
222
224
  return DawnContext::getInstance().MakeImageFromBuffer(buffer);
223
225
  #else
@@ -2,9 +2,9 @@
2
2
 
3
3
  #import <memory>
4
4
 
5
+ #import "RNSkApplePlatformContext.h"
5
6
  #import "RNSkMetalCanvasProvider.h"
6
7
  #import "RNSkView.h"
7
- #import "RNSkApplePlatformContext.h"
8
8
 
9
9
  class RNSkBaseAppleView {
10
10
  public:
@@ -1,8 +1,8 @@
1
1
  #import <memory>
2
2
 
3
+ #import "RNSkApplePlatformContext.h"
3
4
  #import "RNSkMetalCanvasProvider.h"
4
5
  #import "RNSkView.h"
5
- #import "RNSkApplePlatformContext.h"
6
6
 
7
7
  class RNSkBaseAppleView {
8
8
  public:
@@ -41,7 +41,8 @@ static __weak SkiaManager *sharedInstance = nil;
41
41
  // Create the RNSkiaManager (cross platform)
42
42
  _skManager = std::make_shared<RNSkia::RNSkManager>(
43
43
  jsRuntime, jsInvoker,
44
- std::make_shared<RNSkia::RNSkApplePlatformContext>(bridge, jsInvoker));
44
+ std::make_shared<RNSkia::RNSkApplePlatformContext>(bridge,
45
+ jsInvoker));
45
46
  }
46
47
  }
47
48
  return self;
@@ -10,8 +10,8 @@
10
10
  #import <React/RCTUIKit.h>
11
11
  #endif // !TARGET_OS_OSX
12
12
 
13
- #import "RNSkManager.h"
14
13
  #import "RNSkAppleView.h"
14
+ #import "RNSkManager.h"
15
15
  #import "SkiaManager.h"
16
16
 
17
17
  #if RCT_NEW_ARCH_ENABLED
@@ -243,12 +243,12 @@ public:
243
243
 
244
244
  auto jsiPoints = arguments[1].asObject(runtime).asArray(runtime);
245
245
  auto pointsSize = jsiPoints.size(runtime);
246
-
246
+
247
247
  // Check if we have at least one point
248
248
  if (pointsSize == 0) {
249
249
  throw std::invalid_argument("Points array must not be empty");
250
250
  }
251
-
251
+
252
252
  points.reserve(pointsSize);
253
253
 
254
254
  for (int i = 0; i < pointsSize; i++) {
@@ -280,12 +280,13 @@ public:
280
280
 
281
281
  auto jsiCubics = arguments[0].asObject(runtime).asArray(runtime);
282
282
  auto cubicsSize = jsiCubics.size(runtime);
283
-
283
+
284
284
  // Validate cubic points - must be exactly 12 points
285
285
  if (cubicsSize != 12) {
286
- throw std::invalid_argument("Cubic points array must contain exactly 12 points");
286
+ throw std::invalid_argument(
287
+ "Cubic points array must contain exactly 12 points");
287
288
  }
288
-
289
+
289
290
  cubics.reserve(cubicsSize);
290
291
  for (int i = 0; i < cubicsSize; i++) {
291
292
  std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
@@ -296,12 +297,13 @@ public:
296
297
  if (count >= 2 && !arguments[1].isNull() && !arguments[1].isUndefined()) {
297
298
  auto jsiColors = arguments[1].asObject(runtime).asArray(runtime);
298
299
  auto colorsSize = jsiColors.size(runtime);
299
-
300
+
300
301
  // Validate colors array - must be exactly 4 colors
301
302
  if (colorsSize != 4) {
302
- throw std::invalid_argument("Colors array must contain exactly 4 colors");
303
+ throw std::invalid_argument(
304
+ "Colors array must contain exactly 4 colors");
303
305
  }
304
-
306
+
305
307
  colors.reserve(colorsSize);
306
308
  for (int i = 0; i < colorsSize; i++) {
307
309
  SkColor color = JsiSkColor::fromValue(
@@ -313,12 +315,13 @@ public:
313
315
  if (count >= 3 && !arguments[2].isNull() && !arguments[2].isUndefined()) {
314
316
  auto jsiTexs = arguments[2].asObject(runtime).asArray(runtime);
315
317
  auto texsSize = jsiTexs.size(runtime);
316
-
318
+
317
319
  // Validate textures array - must be exactly 4 points
318
320
  if (texsSize != 4) {
319
- throw std::invalid_argument("Texture coordinates array must contain exactly 4 points");
321
+ throw std::invalid_argument(
322
+ "Texture coordinates array must contain exactly 4 points");
320
323
  }
321
-
324
+
322
325
  texs.reserve(texsSize);
323
326
  for (int i = 0; i < texsSize; i++) {
324
327
  auto point = JsiSkPoint::fromValue(
@@ -330,9 +333,8 @@ public:
330
333
  auto paint =
331
334
  count >= 4 ? JsiSkPaint::fromValue(runtime, arguments[4]) : nullptr;
332
335
  auto blendMode = static_cast<SkBlendMode>(arguments[3].asNumber());
333
- _canvas->drawPatch(cubics.data(), colors.empty() ? nullptr : colors.data(),
334
- texs.empty() ? nullptr : texs.data(), blendMode,
335
- *paint);
336
+ _canvas->drawPatch(cubics.data(), colors.empty() ? nullptr : colors.data(),
337
+ texs.empty() ? nullptr : texs.data(), blendMode, *paint);
336
338
  return jsi::Value::undefined();
337
339
  }
338
340
 
@@ -389,12 +391,13 @@ public:
389
391
 
390
392
  std::vector<SkGlyphID> glyphs;
391
393
  int glyphsSize = static_cast<int>(jsiGlyphs.size(runtime));
392
-
394
+
393
395
  // Validate that glyphs and positions arrays have the same size
394
396
  if (glyphsSize != pointsSize) {
395
- throw std::invalid_argument("Glyphs and positions arrays must have the same length");
397
+ throw std::invalid_argument(
398
+ "Glyphs and positions arrays must have the same length");
396
399
  }
397
-
400
+
398
401
  glyphs.reserve(glyphsSize);
399
402
  for (int i = 0; i < glyphsSize; i++) {
400
403
  glyphs.push_back(jsiGlyphs.getValueAtIndex(runtime, i).asNumber());
@@ -553,22 +556,24 @@ public:
553
556
  runtime, rects.getValueAtIndex(runtime, i).asObject(runtime));
554
557
  skRects.push_back(*rect.get());
555
558
  }
556
-
559
+
557
560
  // Validate transforms and rects have the same size
558
561
  if (xformsSize != rectsSize) {
559
- throw std::invalid_argument("Transforms and rects arrays must have the same length");
562
+ throw std::invalid_argument(
563
+ "Transforms and rects arrays must have the same length");
560
564
  }
561
565
 
562
566
  std::vector<SkColor> colors;
563
567
  if (count > 5 && !arguments[5].isUndefined()) {
564
568
  auto colorsArray = arguments[5].asObject(runtime).asArray(runtime);
565
569
  int colorsSize = static_cast<int>(colorsArray.size(runtime));
566
-
570
+
567
571
  // Validate colors array matches the size of sprites and transforms
568
572
  if (colorsSize != rectsSize) {
569
- throw std::invalid_argument("Colors array must have the same length as rects/transforms");
573
+ throw std::invalid_argument(
574
+ "Colors array must have the same length as rects/transforms");
570
575
  }
571
-
576
+
572
577
  colors.reserve(colorsSize);
573
578
  for (int i = 0; i < colorsSize; i++) {
574
579
  // Convert from [r,g,b,a] in [0,1] to SkColor
@@ -593,9 +598,8 @@ public:
593
598
  sampling = SamplingOptionsFromValue(runtime, arguments[6]);
594
599
  }
595
600
  _canvas->drawAtlas(atlas.get(), xforms.data(), skRects.data(),
596
- colors.empty() ? nullptr : colors.data(),
597
- skRects.size(), blendMode, sampling,
598
- nullptr, paint.get());
601
+ colors.empty() ? nullptr : colors.data(), skRects.size(),
602
+ blendMode, sampling, nullptr, paint.get());
599
603
 
600
604
  return jsi::Value::undefined();
601
605
  }
@@ -639,12 +639,14 @@ public:
639
639
  void draw(DrawingCtx *ctx) {
640
640
  // Validate colors array has exactly 4 colors if provided
641
641
  if (props.colors.has_value() && props.colors.value().size() != 4) {
642
- throw std::invalid_argument("Colors array for patch must have exactly 4 colors");
642
+ throw std::invalid_argument(
643
+ "Colors array for patch must have exactly 4 colors");
643
644
  }
644
-
645
+
645
646
  // Validate texture array has exactly 4 points if provided
646
647
  if (props.texture.has_value() && props.texture.value().size() != 4) {
647
- throw std::invalid_argument("Texture coordinates array for patch must have exactly 4 points");
648
+ throw std::invalid_argument(
649
+ "Texture coordinates array for patch must have exactly 4 points");
648
650
  }
649
651
 
650
652
  // Determine default blend mode based on presence of colors
@@ -686,15 +688,6 @@ public:
686
688
  }
687
689
 
688
690
  void draw(DrawingCtx *ctx) {
689
- // Validate array sizes
690
- if (props.colors.has_value() && props.colors.value().size() != props.vertices.size()) {
691
- throw std::invalid_argument("Colors array must have the same size as vertices array");
692
- }
693
-
694
- if (props.textures.has_value() && props.textures.value().size() != props.vertices.size()) {
695
- throw std::invalid_argument("Textures array must have the same size as vertices array");
696
- }
697
-
698
691
  // Create vertices using MakeCopy
699
692
  auto vertices = SkVertices::MakeCopy(
700
693
  props.mode, static_cast<int>(props.vertices.size()),
@@ -930,14 +923,17 @@ public:
930
923
  if (props.image) {
931
924
  // Validate transforms and sprites have the same size
932
925
  if (props.transforms.size() != props.sprites.size()) {
933
- throw std::invalid_argument("transforms and sprites arrays must have the same length");
926
+ throw std::invalid_argument(
927
+ "transforms and sprites arrays must have the same length");
934
928
  }
935
-
929
+
936
930
  // Validate colors array matches if provided
937
- if (props.colors.has_value() && props.colors.value().size() != props.transforms.size()) {
938
- throw std::invalid_argument("colors array must have the same length as transforms/sprites");
931
+ if (props.colors.has_value() &&
932
+ props.colors.value().size() != props.transforms.size()) {
933
+ throw std::invalid_argument(
934
+ "colors array must have the same length as transforms/sprites");
939
935
  }
940
-
936
+
941
937
  auto colors =
942
938
  props.colors.has_value() ? props.colors.value().data() : nullptr;
943
939
  auto blendMode = props.blendMode.value_or(SkBlendMode::kDstOver);
@@ -239,16 +239,13 @@ public:
239
239
  }
240
240
 
241
241
  void pushShader(DrawingCtx *ctx) {
242
- // Validate colors array has at least 2 colors
243
- if (props.colors.size() < 2) {
244
- throw std::invalid_argument("Colors array must have at least 2 colors");
245
- }
246
-
247
242
  // Validate positions array matches colors array in size
248
- if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
249
- throw std::invalid_argument("Positions array must have the same size as colors array");
243
+ if (props.positions.has_value() &&
244
+ props.positions.value().size() != props.colors.size()) {
245
+ throw std::invalid_argument(
246
+ "Positions array must have the same size as colors array");
250
247
  }
251
-
248
+
252
249
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
253
250
  const SkPoint pts[2] = {props.start, props.end};
254
251
  auto shader = SkGradientShader::MakeLinear(
@@ -286,16 +283,13 @@ public:
286
283
  }
287
284
 
288
285
  void pushShader(DrawingCtx *ctx) {
289
- // Validate colors array has at least 2 colors
290
- if (props.colors.size() < 2) {
291
- throw std::invalid_argument("Colors array must have at least 2 colors");
292
- }
293
-
294
286
  // Validate positions array matches colors array in size
295
- if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
296
- throw std::invalid_argument("Positions array must have the same size as colors array");
287
+ if (props.positions.has_value() &&
288
+ props.positions.value().size() != props.colors.size()) {
289
+ throw std::invalid_argument(
290
+ "Positions array must have the same size as colors array");
297
291
  }
298
-
292
+
299
293
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
300
294
  auto shader = SkGradientShader::MakeRadial(
301
295
  props.center, props.radius, props.colors.data(),
@@ -334,16 +328,13 @@ public:
334
328
  }
335
329
 
336
330
  void pushShader(DrawingCtx *ctx) {
337
- // Validate colors array has at least 2 colors
338
- if (props.colors.size() < 2) {
339
- throw std::invalid_argument("Colors array must have at least 2 colors");
340
- }
341
-
342
331
  // Validate positions array matches colors array in size
343
- if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
344
- throw std::invalid_argument("Positions array must have the same size as colors array");
332
+ if (props.positions.has_value() &&
333
+ props.positions.value().size() != props.colors.size()) {
334
+ throw std::invalid_argument(
335
+ "Positions array must have the same size as colors array");
345
336
  }
346
-
337
+
347
338
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
348
339
  auto shader = SkGradientShader::MakeSweep(
349
340
  props.center.x(), props.center.y(), props.colors.data(),
@@ -385,16 +376,14 @@ public:
385
376
  }
386
377
 
387
378
  void pushShader(DrawingCtx *ctx) {
388
- // Validate colors array has at least 2 colors
389
- if (props.colors.size() < 2) {
390
- throw std::invalid_argument("Colors array must have at least 2 colors");
391
- }
392
-
379
+
393
380
  // Validate positions array matches colors array in size
394
- if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
395
- throw std::invalid_argument("Positions array must have the same size as colors array");
381
+ if (props.positions.has_value() &&
382
+ props.positions.value().size() != props.colors.size()) {
383
+ throw std::invalid_argument(
384
+ "Positions array must have the same size as colors array");
396
385
  }
397
-
386
+
398
387
  SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
399
388
  auto shader = SkGradientShader::MakeTwoPointConical(
400
389
  props.start, props.startRadius, props.end, props.endRadius,
@@ -784,12 +784,46 @@ public:
784
784
  *
785
785
  * As such, future decoding calls may require a rewind.
786
786
  *
787
- * For still (non-animated) image codecs, this will return 0.
787
+ * `getRepetitionCount` will return `0` in two cases:
788
+ * 1. Still (non-animated) images.
789
+ * 2. Animated images that only play the animation once (i.e. that don't
790
+ * repeat the animation)
791
+ * `isAnimated` can be used to disambiguate between these two cases.
788
792
  */
789
793
  int getRepetitionCount() {
790
794
  return this->onGetRepetitionCount();
791
795
  }
792
796
 
797
+ /**
798
+ * `isAnimated` returns whether the full input is expected to contain an
799
+ * animated image (i.e. more than 1 image frame). This can be used to
800
+ * disambiguate the meaning of `getRepetitionCount` returning `0` (see
801
+ * `getRepetitionCount`'s doc comment for more details).
802
+ *
803
+ * Note that in some codecs `getFrameCount()` only returns the number of
804
+ * frames for which all the metadata has been already successfully decoded.
805
+ * Therefore for a partial input `isAnimated()` may return "yes", even
806
+ * though `getFrameCount()` may temporarily return `1` until more of the
807
+ * input is available.
808
+ *
809
+ * When handling partial input, some codecs may not know until later (e.g.
810
+ * until encountering additional image frames) whether the given image has
811
+ * more than one frame. Such codecs may initially return
812
+ * `IsAnimated::kUnknown` and only later give a definitive "yes" or "no"
813
+ * answer. GIF format is one example where this may happen.
814
+ *
815
+ * Other codecs may be able to decode the information from the metadata
816
+ * present before the first image frame. Such codecs should be able to give
817
+ * a definitive "yes" or "no" answer as soon as they are constructed. PNG
818
+ * format is one example where this happens.
819
+ */
820
+ enum class IsAnimated {
821
+ kYes,
822
+ kNo,
823
+ kUnknown,
824
+ };
825
+ IsAnimated isAnimated() { return this->onIsAnimated(); }
826
+
793
827
  // Register a decoder at runtime by passing two function pointers:
794
828
  // - peek() to return true if the span of bytes appears to be your encoded format;
795
829
  // - make() to attempt to create an SkCodec from the given stream.
@@ -937,6 +971,10 @@ protected:
937
971
  return 0;
938
972
  }
939
973
 
974
+ virtual IsAnimated onIsAnimated() {
975
+ return IsAnimated::kNo;
976
+ }
977
+
940
978
  private:
941
979
  const SkEncodedInfo fEncodedInfo;
942
980
  XformFormat fSrcXformFormat;
@@ -80,16 +80,6 @@
80
80
  */
81
81
  //#define SK_CANVAS_SAVE_RESTORE_PREALLOC_COUNT 32
82
82
 
83
- /* Determines whether to build code that supports the Ganesh GPU backend. Some classes
84
- that are not GPU-specific, such as SkShader subclasses, have optional code
85
- that is used allows them to interact with this GPU backend. If you'd like to
86
- include this code, include -DSK_GANESH in your cflags or uncomment below.
87
- Defaults to not set (No Ganesh GPU backend).
88
- This define affects the ABI of Skia, so make sure it matches the client which uses
89
- the compiled version of Skia.
90
- */
91
- //#define SK_GANESH
92
-
93
83
  /* Skia makes use of histogram logging macros to trace the frequency of
94
84
  events. By default, Skia provides no-op versions of these macros.
95
85
  Skia consumers can provide their own definitions of these macros to
@@ -99,6 +89,7 @@
99
89
  //#define SK_HISTOGRAM_ENUMERATION(name, sampleEnum, enumSize)
100
90
  //#define SK_HISTOGRAM_EXACT_LINEAR(name, sample, valueMax)
101
91
  //#define SK_HISTOGRAM_MEMORY_KB(name, sample)
92
+ //#define SK_HISTOGRAM_CUSTOM_COUNTS(name, sample, countMin, countMax, bucketCount)
102
93
  //#define SK_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(name, sampleUSec, minUSec, maxUSec, bucketCount)
103
94
 
104
95
  /*
@@ -54,6 +54,7 @@ class GrRecordingContext;
54
54
 
55
55
  class SkBitmap;
56
56
  class SkBlender;
57
+ class SkBlurMaskFilterImpl;
57
58
  class SkColorSpace;
58
59
  class SkData;
59
60
  class SkDevice;
@@ -2679,11 +2680,14 @@ private:
2679
2680
  // into the canvas' global space.
2680
2681
  SkRect computeDeviceClipBounds(bool outsetForAA=true) const;
2681
2682
 
2682
- // Attempt to draw a rrect with an analytic blur. If the paint does not contain a blur, or the
2683
- // geometry can't be drawn with an analytic blur by the device, a layer is returned for a
2684
- // regular draw. If the draw succeeds or predrawNotify fails, nullopt is returned indicating
2685
- // that nothing further should be drawn.
2683
+ // Returns the paint's mask filter if it can be used to draw an rrect with an analytic blur, and
2684
+ // returns null otherwise.
2685
+ const SkBlurMaskFilterImpl* canAttemptBlurredRRectDraw(const SkPaint&) const;
2686
+
2687
+ // Attempt to draw a rrect with an analytic blur. If the draw succeeds or predrawNotify fails,
2688
+ // nullopt is returned indicating that nothing further should be drawn.
2686
2689
  std::optional<AutoLayerForImageFilter> attemptBlurredRRectDraw(const SkRRect&,
2690
+ const SkBlurMaskFilterImpl*,
2687
2691
  const SkPaint&,
2688
2692
  SkEnumBitMask<PredrawFlags>);
2689
2693
 
@@ -91,13 +91,13 @@ public:
91
91
  return *this;
92
92
  }
93
93
 
94
- bool operator==(const ForwardVerbIterator& other) {
94
+ bool operator==(const ForwardVerbIterator& other) const {
95
95
  SkASSERT(fSegments.data() != other.fSegments.data() ||
96
96
  fSegments.size() == other.fSegments.size());
97
97
  return fSegments.data() == other.fSegments.data();
98
98
  }
99
99
 
100
- bool operator!=(const ForwardVerbIterator& other) {
100
+ bool operator!=(const ForwardVerbIterator& other) const {
101
101
  return !((*this) == other);
102
102
  }
103
103
 
@@ -5,5 +5,5 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
  #ifndef SK_MILESTONE
8
- #define SK_MILESTONE 134
8
+ #define SK_MILESTONE 136
9
9
  #endif
@@ -317,15 +317,18 @@ public:
317
317
  */
318
318
  SkScalar getStrokeMiter() const { return fMiterLimit; }
319
319
 
320
- /** Sets the limit at which a sharp corner is drawn beveled.
321
- Valid values are zero and greater.
322
- Has no effect if miter is less than zero.
320
+ /** When stroking a small joinAngle with miter, the miterLength may be very long.
321
+ When miterLength > maxMiterLength (or joinAngle < minJoinAngle) the join will become bevel.
322
+ miterLimit = maxMiterLength / strokeWidth or miterLimit = 1 / sin(minJoinAngle / 2).
323
323
 
324
- @param miter zero and greater miter limit
324
+ This call has no effect if the miterLimit passed is less than zero.
325
+ Values less than one will be treated as bevel.
326
+
327
+ @param miterLimit zero and greater miter limit
325
328
 
326
329
  example: https://fiddle.skia.org/c/@Paint_setStrokeMiter
327
330
  */
328
- void setStrokeMiter(SkScalar miter);
331
+ void setStrokeMiter(SkScalar miterLimit);
329
332
 
330
333
  /** \enum SkPaint::Cap
331
334
  Cap draws at the beginning and end of an open path contour.
@@ -79,10 +79,12 @@ public:
79
79
  [[nodiscard]] bool readS8(int8_t*);
80
80
  [[nodiscard]] bool readS16(int16_t*);
81
81
  [[nodiscard]] bool readS32(int32_t*);
82
+ [[nodiscard]] bool readS64(int64_t*);
82
83
 
83
- [[nodiscard]] bool readU8(uint8_t* i) { return this->readS8((int8_t*)i); }
84
+ [[nodiscard]] bool readU8(uint8_t* i) { return this->readS8((int8_t*)i); }
84
85
  [[nodiscard]] bool readU16(uint16_t* i) { return this->readS16((int16_t*)i); }
85
86
  [[nodiscard]] bool readU32(uint32_t* i) { return this->readS32((int32_t*)i); }
87
+ [[nodiscard]] bool readU64(uint64_t* i) { return this->readS64((int64_t*)i); }
86
88
 
87
89
  [[nodiscard]] bool readBool(bool* b) {
88
90
  uint8_t i;
@@ -240,8 +242,11 @@ public:
240
242
  uint16_t v = SkToU16(value);
241
243
  return this->write(&v, 2);
242
244
  }
243
- bool write32(uint32_t v) {
244
- return this->write(&v, 4);
245
+ bool write32(uint32_t value) {
246
+ return this->write(&value, 4);
247
+ }
248
+ bool write64(uint64_t value) {
249
+ return this->write(&value, 8);
245
250
  }
246
251
 
247
252
  bool writeText(const char text[]) {
@@ -209,13 +209,13 @@ public:
209
209
  class SK_API Iter {
210
210
  public:
211
211
  struct Run {
212
- SkTypeface* fTypeface;
213
- int fGlyphCount;
214
- const uint16_t* fGlyphIndices;
212
+ SkTypeface* fTypeface;
213
+ int fGlyphCount;
214
+ const SkGlyphID* fGlyphIndices;
215
215
  #ifdef SK_UNTIL_CRBUG_1187654_IS_FIXED
216
216
  const uint32_t* fClusterIndex_forTest;
217
- int fUtf8Size_forTest;
218
- const char* fUtf8_forTest;
217
+ int fUtf8Size_forTest;
218
+ const char* fUtf8_forTest;
219
219
  #endif
220
220
  };
221
221
 
@@ -229,10 +229,10 @@ public:
229
229
 
230
230
  // Experimental, DO NO USE, will change/go-away
231
231
  struct ExperimentalRun {
232
- SkFont font;
233
- int count;
234
- const uint16_t* glyphs;
235
- const SkPoint* positions;
232
+ SkFont font;
233
+ int count;
234
+ const SkGlyphID* glyphs;
235
+ const SkPoint* positions;
236
236
  };
237
237
  bool experimentalNext(ExperimentalRun*);
238
238
 
@@ -366,12 +366,10 @@ protected:
366
366
  virtual bool onGetFixedPitch() const; // TODO: = 0;
367
367
 
368
368
  // Must return a valid scaler context. It can not return nullptr.
369
- virtual std::unique_ptr<SkScalerContext> onCreateScalerContext(const SkScalerContextEffects&,
370
- const SkDescriptor*) const = 0;
369
+ virtual std::unique_ptr<SkScalerContext> onCreateScalerContext(
370
+ const SkScalerContextEffects&, const SkDescriptor*) const = 0;
371
371
  virtual std::unique_ptr<SkScalerContext> onCreateScalerContextAsProxyTypeface
372
- (const SkScalerContextEffects&,
373
- const SkDescriptor*,
374
- sk_sp<SkTypeface>) const;
372
+ (const SkScalerContextEffects&, const SkDescriptor*, SkTypeface* proxyTypeface) const;
375
373
  virtual void onFilterRec(SkScalerContextRec*) const = 0;
376
374
  friend class SkScalerContext; // onFilterRec
377
375
 
@@ -442,8 +440,8 @@ private:
442
440
  friend class SkRandomTypeface; // getAdvancedMetrics
443
441
  friend class SkPDFFont; // getAdvancedMetrics
444
442
  friend class SkTypeface_proxy;
445
-
446
443
  friend class SkFontPriv; // getGlyphToUnicodeMap
444
+ friend void TestSkTypefaceGlyphToUnicodeMap(SkTypeface&, SkUnichar*);
447
445
 
448
446
  private:
449
447
  SkTypefaceID fUniqueID;
@@ -97,6 +97,7 @@
97
97
  defined(SK_HISTOGRAM_BOOLEAN) || \
98
98
  defined(SK_HISTOGRAM_EXACT_LINEAR) || \
99
99
  defined(SK_HISTOGRAM_MEMORY_KB) || \
100
+ defined(SK_HISTOGRAM_CUSTOM_COUNTS)|| \
100
101
  defined(SK_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES)
101
102
  # define SK_HISTOGRAMS_ENABLED 1
102
103
  #else
@@ -119,6 +120,10 @@
119
120
  # define SK_HISTOGRAM_MEMORY_KB(name, sample)
120
121
  #endif
121
122
 
123
+ #ifndef SK_HISTOGRAM_CUSTOM_COUNTS
124
+ # define SK_HISTOGRAM_CUSTOM_COUNTS(name, sample, countMin, countMax, bucketCount)
125
+ #endif
126
+
122
127
  #ifndef SK_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES
123
128
  # define SK_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(name, sampleUSec, minUSec, maxUSec, bucketCount)
124
129
  #endif