@shopify/react-native-skia 2.6.0 → 2.6.2

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 (118) hide show
  1. package/android/CMakeLists.txt +0 -1
  2. package/android/cpp/jni/JniWebGPUView.cpp +3 -3
  3. package/android/cpp/rnskia-android/OpenGLContext.h +4 -5
  4. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +1 -1
  5. package/apple/MetalContext.h +5 -6
  6. package/apple/MetalWindowContext.mm +3 -4
  7. package/apple/RNSkApplePlatformContext.h +1 -1
  8. package/apple/RNSkApplePlatformContext.mm +4 -3
  9. package/apple/SkiaCVPixelBufferUtils.h +1 -1
  10. package/apple/SkiaCVPixelBufferUtils.mm +31 -30
  11. package/apple/SkiaPlatformContext.mm +2 -2
  12. package/apple/SkiaUIView.mm +1 -1
  13. package/apple/SkiaWebGPUView.mm +8 -4
  14. package/apple/WebGPUMetalView.h +1 -1
  15. package/apple/WebGPUMetalView.mm +1 -1
  16. package/cpp/api/JsiSkColor.h +8 -4
  17. package/cpp/api/JsiSkContourMeasure.h +4 -3
  18. package/cpp/api/JsiSkImage.h +17 -9
  19. package/cpp/api/JsiSkParagraphBuilder.h +14 -1
  20. package/cpp/api/JsiSkPath.h +71 -81
  21. package/cpp/api/JsiSkPathEffectFactory.h +2 -1
  22. package/cpp/api/JsiSkPathFactory.h +48 -52
  23. package/cpp/api/JsiSkShader.h +1 -1
  24. package/cpp/api/JsiSkShaderFactory.h +50 -26
  25. package/cpp/api/JsiSkSurfaceFactory.h +2 -1
  26. package/cpp/api/recorder/Drawings.h +5 -7
  27. package/cpp/api/recorder/Shaders.h +77 -22
  28. package/cpp/jsi2/JSIConverter.h +1 -1
  29. package/cpp/rnskia/RNDawnContext.h +14 -15
  30. package/cpp/rnskia/RNDawnUtils.h +14 -17
  31. package/cpp/rnskia/RNDawnWindowContext.h +1 -1
  32. package/cpp/rnskia/RNSkManager.cpp +5 -4
  33. package/cpp/rnskia/RNSkPlatformContext.h +2 -2
  34. package/cpp/rnwgpu/api/GPU.cpp +21 -0
  35. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +1 -1
  36. package/cpp/rnwgpu/api/GPUCanvasContext.h +2 -2
  37. package/cpp/rnwgpu/api/GPUFeatures.h +0 -9
  38. package/cpp/rnwgpu/api/GPUTexture.h +14 -2
  39. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +3 -4
  40. package/cpp/rnwgpu/api/RNWebGPU.h +1 -1
  41. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -15
  42. package/cpp/skia/include/android/SkImageAndroid.h +7 -2
  43. package/cpp/skia/include/android/vk/AndroidVulkanMemoryAllocator.h +31 -0
  44. package/cpp/skia/include/codec/SkCodec.h +42 -15
  45. package/cpp/skia/include/config/SkUserConfig.h +8 -0
  46. package/cpp/skia/include/core/SkBitmap.h +0 -5
  47. package/cpp/skia/include/core/SkCanvas.h +2 -39
  48. package/cpp/skia/include/core/SkColor.h +12 -0
  49. package/cpp/skia/include/core/SkColorSpace.h +9 -0
  50. package/cpp/skia/include/core/SkContourMeasure.h +1 -5
  51. package/cpp/skia/include/core/SkData.h +8 -0
  52. package/cpp/skia/include/core/SkFont.h +1 -55
  53. package/cpp/skia/include/core/SkFontArguments.h +15 -0
  54. package/cpp/skia/include/core/SkGraphics.h +0 -5
  55. package/cpp/skia/include/core/SkImage.h +0 -4
  56. package/cpp/skia/include/core/SkImageGenerator.h +1 -4
  57. package/cpp/skia/include/core/SkMatrix.h +0 -37
  58. package/cpp/skia/include/core/SkMilestone.h +1 -1
  59. package/cpp/skia/include/core/SkPath.h +11 -911
  60. package/cpp/skia/include/core/SkPathBuilder.h +42 -32
  61. package/cpp/skia/include/core/SkPathEffect.h +0 -9
  62. package/cpp/skia/include/core/SkPathMeasure.h +1 -4
  63. package/cpp/skia/include/core/SkPathUtils.h +0 -10
  64. package/cpp/skia/include/core/SkRect.h +0 -12
  65. package/cpp/skia/include/core/SkRegion.h +1 -6
  66. package/cpp/skia/include/core/SkSerialProcs.h +4 -5
  67. package/cpp/skia/include/core/SkSurfaceProps.h +6 -0
  68. package/cpp/skia/include/core/SkTextBlob.h +0 -22
  69. package/cpp/skia/include/core/SkTypeface.h +14 -32
  70. package/cpp/skia/include/core/SkTypes.h +0 -8
  71. package/cpp/skia/include/docs/SkPDFDocument.h +19 -17
  72. package/cpp/skia/include/effects/SkDashPathEffect.h +0 -6
  73. package/cpp/skia/include/effects/SkGradient.h +206 -0
  74. package/cpp/skia/include/effects/SkHighContrastFilter.h +2 -2
  75. package/cpp/skia/include/gpu/GpuTypes.h +2 -0
  76. package/cpp/skia/include/gpu/ganesh/GrBackendSemaphore.h +5 -35
  77. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +7 -106
  78. package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +0 -11
  79. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +0 -9
  80. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSemaphore.h +20 -0
  81. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DBackendSurface.h +59 -0
  82. package/cpp/skia/include/gpu/ganesh/d3d/GrD3DDirectContext.h +28 -0
  83. package/cpp/skia/include/gpu/ganesh/gl/GrGLFunctions.h +4 -1
  84. package/cpp/skia/include/gpu/graphite/ContextOptions.h +4 -20
  85. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +32 -46
  86. package/cpp/skia/include/gpu/graphite/Recorder.h +1 -1
  87. package/cpp/skia/include/gpu/graphite/Surface.h +31 -0
  88. package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -10
  89. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +3 -3
  90. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -1
  91. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +6 -6
  92. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +5 -3
  93. package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +1 -1
  94. package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
  95. package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +8 -0
  96. package/cpp/skia/include/private/SkEncodedInfo.h +43 -105
  97. package/cpp/skia/include/private/SkHdrMetadata.h +165 -2
  98. package/cpp/skia/include/private/SkPathRef.h +0 -457
  99. package/cpp/skia/include/private/base/SkFeatures.h +4 -0
  100. package/cpp/skia/include/private/base/SkFloatingPoint.h +1 -2
  101. package/cpp/skia/include/private/base/SkLoadUserConfig.h +2 -1
  102. package/cpp/skia/include/private/base/SkLog.h +68 -0
  103. package/cpp/skia/include/private/base/SkLogPriority.h +35 -0
  104. package/cpp/skia/include/private/base/SkMacros.h +9 -0
  105. package/cpp/skia/include/private/base/SkTArray.h +1 -1
  106. package/cpp/skia/include/private/gpu/ganesh/GrD3DTypesMinimal.h +10 -24
  107. package/cpp/skia/include/utils/SkEventTracer.h +5 -7
  108. package/cpp/skia/modules/skottie/include/TextShaper.h +0 -7
  109. package/cpp/skia/modules/skparagraph/include/FontCollection.h +6 -20
  110. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +0 -6
  111. package/cpp/skia/modules/skparagraph/include/ParagraphCache.h +4 -19
  112. package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +2 -3
  113. package/cpp/skia/modules/skunicode/include/SkUnicode_icu.h +18 -0
  114. package/cpp/skia/modules/skunicode/include/SkUnicode_libgrapheme.h +19 -0
  115. package/cpp/skia/src/base/SkMathPriv.h +27 -132
  116. package/package.json +5 -5
  117. package/cpp/skia/include/effects/SkGradientShader.h +0 -359
  118. package/cpp/skia/include/gpu/graphite/LogPriority.h +0 -36
@@ -463,8 +463,6 @@ inline void convertJSUnionToEnum(const std::string &inUnion,
463
463
  *outEnum = wgpu::FeatureName::PixelLocalStorageNonCoherent;
464
464
  } else if (inUnion == "unorm16-texture-formats") {
465
465
  *outEnum = wgpu::FeatureName::Unorm16TextureFormats;
466
- } else if (inUnion == "snorm16-texture-formats") {
467
- *outEnum = wgpu::FeatureName::Snorm16TextureFormats;
468
466
  } else if (inUnion == "multi-planar-format-extended-usages") {
469
467
  *outEnum = wgpu::FeatureName::MultiPlanarFormatExtendedUsages;
470
468
  } else if (inUnion == "multi-planar-format-p010") {
@@ -485,12 +483,8 @@ inline void convertJSUnionToEnum(const std::string &inUnion,
485
483
  *outEnum = wgpu::FeatureName::AdapterPropertiesD3D;
486
484
  } else if (inUnion == "adapter-properties-vk") {
487
485
  *outEnum = wgpu::FeatureName::AdapterPropertiesVk;
488
- } else if (inUnion == "r8unorm-storage") {
489
- *outEnum = wgpu::FeatureName::R8UnormStorage;
490
486
  } else if (inUnion == "format-capabilities") {
491
487
  *outEnum = wgpu::FeatureName::DawnFormatCapabilities;
492
- } else if (inUnion == "norm16-texture-formats") {
493
- *outEnum = wgpu::FeatureName::Norm16TextureFormats;
494
488
  } else if (inUnion == "multi-planar-format-nv16") {
495
489
  *outEnum = wgpu::FeatureName::MultiPlanarFormatNv16;
496
490
  } else if (inUnion == "multi-planar-format-nv24") {
@@ -629,9 +623,6 @@ inline void convertEnumToJSUnion(wgpu::FeatureName inEnum,
629
623
  case wgpu::FeatureName::Unorm16TextureFormats:
630
624
  *outUnion = "unorm16-texture-formats";
631
625
  break;
632
- case wgpu::FeatureName::Snorm16TextureFormats:
633
- *outUnion = "snorm16-texture-formats";
634
- break;
635
626
  case wgpu::FeatureName::MultiPlanarFormatExtendedUsages:
636
627
  *outUnion = "multi-planar-format-extended-usages";
637
628
  break;
@@ -662,12 +653,6 @@ inline void convertEnumToJSUnion(wgpu::FeatureName inEnum,
662
653
  case wgpu::FeatureName::AdapterPropertiesVk:
663
654
  *outUnion = "adapter-properties-vk";
664
655
  break;
665
- case wgpu::FeatureName::R8UnormStorage:
666
- *outUnion = "r8unorm-storage";
667
- break;
668
- case wgpu::FeatureName::Norm16TextureFormats:
669
- *outUnion = "norm16-texture-formats";
670
- break;
671
656
  case wgpu::FeatureName::MultiPlanarFormatNv16:
672
657
  *outUnion = "multi-planar-format-nv16";
673
658
  break;
@@ -52,11 +52,16 @@ SK_API sk_sp<SkImage> TextureFromAHardwareBufferWithData(
52
52
  GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
53
53
 
54
54
  /**
55
- * Like SkImagePriv::SkMakeImageFromRasterBitmap, except this can be pinned using
56
- * skgpu::ganesh::PinAsTexture and CopyPixelMode is never.
55
+ * Like SkImage::MakeFromBitmap, except this can be pinned using
56
+ * skgpu::ganesh::PinAsTexture and Skia will *not* copy the bitmap.
57
57
  */
58
58
  SK_API sk_sp<SkImage> PinnableRasterFromBitmap(const SkBitmap&);
59
59
 
60
+ /**
61
+ * Like SkImage::MakeFromBitmap, except and Skia will *not* copy the bitmap.
62
+ */
63
+ SK_API sk_sp<SkImage> RasterFromBitmapNoCopy(const SkBitmap&);
64
+
60
65
  } // namespace SkImages
61
66
 
62
67
  namespace skgpu::ganesh {
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Use of this source code is governed by a BSD-style license that can be
5
+ * found in the LICENSE file.
6
+ */
7
+
8
+ #ifndef AndroidVulkanMemoryAllocator_DEFINED
9
+ #define AndroidVulkanMemoryAllocator_DEFINED
10
+
11
+ #include "include/core/SkRefCnt.h"
12
+ #include "include/private/base/SkAPI.h"
13
+
14
+ namespace skgpu {
15
+ struct VulkanBackendContext;
16
+ class VulkanMemoryAllocator;
17
+ }
18
+
19
+ namespace SkiaVMA {
20
+
21
+ struct Options {
22
+ bool fThreadSafe = true;
23
+ };
24
+
25
+ // Returns a concrete implementation of a memory allocator using some hard-coded settings.
26
+ // If Android Framework ever wants to make their own, they can stop using this.
27
+ sk_sp<skgpu::VulkanMemoryAllocator> Make(const skgpu::VulkanBackendContext&, Options);
28
+
29
+ } // namespace SkiaVMA
30
+
31
+ #endif
@@ -122,6 +122,10 @@ public:
122
122
  * FIXME: Perhaps this should be kUnsupported?
123
123
  */
124
124
  kUnimplemented,
125
+ /**
126
+ * If the memory allocation exceeded the provided budget.
127
+ */
128
+ kOutOfMemory,
125
129
  };
126
130
 
127
131
  /**
@@ -308,12 +312,6 @@ public:
308
312
  */
309
313
  SkEncodedImageFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
310
314
 
311
- /**
312
- * Return the underlying encoded data stream. This may be nullptr if the original
313
- * stream could not be duplicated.
314
- */
315
- virtual std::unique_ptr<SkStream> getEncodedData() const;
316
-
317
315
  /**
318
316
  * Whether or not the memory passed to getPixels is zero initialized.
319
317
  */
@@ -337,13 +335,13 @@ public:
337
335
  */
338
336
  struct Options {
339
337
  Options()
340
- : fZeroInitialized(kNo_ZeroInitialized)
341
- , fSubset(nullptr)
342
- , fFrameIndex(0)
343
- , fPriorFrame(kNoFrame)
344
- {}
338
+ : fZeroInitialized(kNo_ZeroInitialized)
339
+ , fSubset(nullptr)
340
+ , fFrameIndex(0)
341
+ , fPriorFrame(kNoFrame)
342
+ , fMaxDecodeMemory(0) {}
345
343
 
346
- ZeroInitialized fZeroInitialized;
344
+ ZeroInitialized fZeroInitialized;
347
345
  /**
348
346
  * If not NULL, represents a subset of the original image to decode.
349
347
  * Must be within the bounds returned by getInfo().
@@ -361,14 +359,14 @@ public:
361
359
  * subset left and subset width to decode partial scanlines on calls
362
360
  * to getScanlines().
363
361
  */
364
- const SkIRect* fSubset;
362
+ const SkIRect* fSubset;
365
363
 
366
364
  /**
367
365
  * The frame to decode.
368
366
  *
369
367
  * Only meaningful for multi-frame images.
370
368
  */
371
- int fFrameIndex;
369
+ int fFrameIndex;
372
370
 
373
371
  /**
374
372
  * If not kNoFrame, the dst already contains the prior frame at this index.
@@ -383,7 +381,12 @@ public:
383
381
  *
384
382
  * If set to kNoFrame, the codec will decode any necessary required frame(s) first.
385
383
  */
386
- int fPriorFrame;
384
+ int fPriorFrame;
385
+
386
+ /**
387
+ * If non-zero, image decoding will fail if cumulative allocations exceed this many bytes.
388
+ */
389
+ size_t fMaxDecodeMemory;
387
390
  };
388
391
 
389
392
  /**
@@ -985,6 +988,9 @@ protected:
985
988
  return IsAnimated::kNo;
986
989
  }
987
990
 
991
+ // Returns true if the requested amount keeps the current total under Options::fMaxDecodeMemory.
992
+ bool allocateFromBudget(size_t numBytes);
993
+
988
994
  private:
989
995
  const SkEncodedInfo fEncodedInfo;
990
996
  XformFormat fSrcXformFormat;
@@ -1013,6 +1019,9 @@ private:
1013
1019
  // Only meaningful during scanline decodes.
1014
1020
  int fCurrScanline = -1;
1015
1021
 
1022
+ // How many bytes we are allowed to use when decoding.
1023
+ size_t fDecodeBudget = 0;
1024
+
1016
1025
  bool fStartedIncrementalDecode = false;
1017
1026
 
1018
1027
  // Allows SkAndroidCodec to call handleFrameIndex (potentially decoding a prior frame and
@@ -1034,6 +1043,11 @@ private:
1034
1043
  return dim == this->dimensions() || this->onDimensionsSupported(dim);
1035
1044
  }
1036
1045
 
1046
+ Result getPixelsBudgeted(const SkImageInfo& info,
1047
+ void* pixels,
1048
+ size_t rowBytes,
1049
+ const Options*);
1050
+
1037
1051
  /**
1038
1052
  * For multi-framed images, return the object with information about the frames.
1039
1053
  */
@@ -1065,6 +1079,13 @@ private:
1065
1079
  return kUnimplemented;
1066
1080
  }
1067
1081
 
1082
+ /**
1083
+ * Checks whether the implementation supports incremental decoding for the given info.
1084
+ *
1085
+ * Note that onStartIncrementalDecode can stil fail regardless of this result.
1086
+ */
1087
+ virtual bool onSupportsIncrementalDecode(const SkImageInfo&) { return false; }
1088
+
1068
1089
  virtual Result onStartIncrementalDecode(const SkImageInfo& /*dstInfo*/, void*, size_t,
1069
1090
  const Options&) {
1070
1091
  return kUnimplemented;
@@ -1106,6 +1127,12 @@ private:
1106
1127
  */
1107
1128
  virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
1108
1129
 
1130
+ /**
1131
+ * Return the underlying encoded data. This may be nullptr if the original
1132
+ * stream could not be duplicated/read.
1133
+ */
1134
+ virtual sk_sp<const SkData> getEncodedData() const;
1135
+
1109
1136
  friend class DM::CodecSrc; // for fillIncompleteImage
1110
1137
  friend class PNGCodecGM; // for fillIncompleteImage
1111
1138
  friend class SkSampledCodec;
@@ -130,4 +130,12 @@
130
130
  */
131
131
  // #define SK_DNG_VERSION 0x01040000
132
132
 
133
+ /*
134
+ * By default, Skia uses SIMD operations for many internal calculations, especially
135
+ * for the CPU backend. These defines can be set to disable SIMD in SkVx and
136
+ * SkRasterPipeline, respectively.
137
+ */
138
+ // #define SKVX_DISABLE_SIMD
139
+ // #define SKRP_CPU_SCALAR
140
+
133
141
  #endif
@@ -33,7 +33,6 @@ class SkPixelRef;
33
33
  class SkShader;
34
34
  enum SkColorType : int;
35
35
  enum class SkTileMode;
36
- struct SkMaskBuilder;
37
36
 
38
37
  /** \class SkBitmap
39
38
  SkBitmap describes a two-dimensional raster pixel array. SkBitmap is built on
@@ -645,10 +644,6 @@ public:
645
644
  */
646
645
  bool installPixels(const SkPixmap& pixmap);
647
646
 
648
- /** Deprecated.
649
- */
650
- bool installMaskPixels(SkMaskBuilder& mask);
651
-
652
647
  /** Replaces SkPixelRef with pixels, preserving SkImageInfo and rowBytes().
653
648
  Sets SkPixelRef origin to (0, 0).
654
649
 
@@ -1328,11 +1328,6 @@ public:
1328
1328
  example: https://fiddle.skia.org/c/@Canvas_drawPoints
1329
1329
  */
1330
1330
  void drawPoints(PointMode mode, SkSpan<const SkPoint>, const SkPaint& paint);
1331
- #ifdef SK_SUPPORT_UNSPANNED_APIS
1332
- void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint) {
1333
- this->drawPoints(mode, {pts, count}, paint);
1334
- }
1335
- #endif
1336
1331
 
1337
1332
  /** Draws point at (x, y) using clip, SkMatrix and SkPaint paint.
1338
1333
 
@@ -1915,17 +1910,6 @@ public:
1915
1910
  void drawGlyphs(SkSpan<const SkGlyphID> glyphs, SkSpan<const SkPoint> positions,
1916
1911
  SkSpan<const uint32_t> clusters, SkSpan<const char> utf8text,
1917
1912
  SkPoint origin, const SkFont& font, const SkPaint& paint);
1918
- #ifdef SK_SUPPORT_UNSPANNED_APIS
1919
- void drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[],
1920
- const uint32_t clusters[], int textByteCount, const char utf8text[],
1921
- SkPoint origin, const SkFont& font, const SkPaint& paint) {
1922
- this->drawGlyphs({glyphs, count},
1923
- {positions, count},
1924
- {clusters, count},
1925
- {utf8text, textByteCount},
1926
- origin, font, paint);
1927
- }
1928
- #endif
1929
1913
 
1930
1914
  /** Draws count glyphs, at positions relative to origin styled with font and paint.
1931
1915
 
@@ -1947,12 +1931,6 @@ public:
1947
1931
  */
1948
1932
  void drawGlyphs(SkSpan<const SkGlyphID> glyphs, SkSpan<const SkPoint> positions,
1949
1933
  SkPoint origin, const SkFont& font, const SkPaint& paint);
1950
- #ifdef SK_SUPPORT_UNSPANNED_APIS
1951
- void drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[],
1952
- SkPoint origin, const SkFont& font, const SkPaint& paint) {
1953
- this->drawGlyphs({glyphs, count}, {positions, count}, origin, font, paint);
1954
- }
1955
- #endif
1956
1934
 
1957
1935
  /** Draws count glyphs, at positions relative to origin styled with font and paint.
1958
1936
 
@@ -1975,12 +1953,6 @@ public:
1975
1953
  */
1976
1954
  void drawGlyphsRSXform(SkSpan<const SkGlyphID> glyphs, SkSpan<const SkRSXform> xforms,
1977
1955
  SkPoint origin, const SkFont& font, const SkPaint& paint);
1978
- #ifdef SK_SUPPORT_UNSPANNED_APIS
1979
- void drawGlyphs(int count, const SkGlyphID glyphs[], const SkRSXform xforms[],
1980
- SkPoint origin, const SkFont& font, const SkPaint& paint) {
1981
- this->drawGlyphsRSXform({glyphs, count}, {xforms, count}, origin, font, paint);
1982
- }
1983
- #endif
1984
1956
 
1985
1957
  /** Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
1986
1958
 
@@ -2209,17 +2181,6 @@ public:
2209
2181
  void drawAtlas(const SkImage* atlas, SkSpan<const SkRSXform> xform,
2210
2182
  SkSpan<const SkRect> tex, SkSpan<const SkColor> colors, SkBlendMode mode,
2211
2183
  const SkSamplingOptions& sampling, const SkRect* cullRect, const SkPaint* paint);
2212
- #ifdef SK_SUPPORT_UNSPANNED_APIS
2213
- void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
2214
- const SkColor colors[], int count, SkBlendMode mode,
2215
- const SkSamplingOptions& samp, const SkRect* cullRect, const SkPaint* paint) {
2216
- this->drawAtlas(atlas,
2217
- {xform, count},
2218
- {tex, tex ? count : 0},
2219
- {colors, colors ? count : 0},
2220
- mode, samp, cullRect, paint);
2221
- }
2222
- #endif
2223
2184
 
2224
2185
  /** Draws SkDrawable drawable using clip and SkMatrix, concatenated with
2225
2186
  optional matrix.
@@ -2648,6 +2609,8 @@ private:
2648
2609
 
2649
2610
  void init(sk_sp<SkDevice>);
2650
2611
 
2612
+ bool nothingToDraw(const SkPaint& paint) const;
2613
+
2651
2614
  // All base onDrawX() functions should call this and skip drawing if it returns true.
2652
2615
  // If 'matrix' is non-null, it maps the paint's fast bounds before checking for quick rejection
2653
2616
  bool internalQuickReject(const SkRect& bounds, const SkPaint& paint,
@@ -425,6 +425,18 @@ struct SkRGBA4f {
425
425
  SkRGBA4f pinAlpha() const {
426
426
  return { fR, fG, fB, SkTPin(fA, 0.f, 1.f) };
427
427
  }
428
+
429
+ /** Returns this color, having replaced its alpha value.
430
+ */
431
+ SkRGBA4f withAlpha(float a) const {
432
+ return { fR, fG, fB, a };
433
+ }
434
+
435
+ /** Returns this color, having replaced its alpha value specified as a byte.
436
+ */
437
+ SkRGBA4f withAlphaByte(uint8_t a) const {
438
+ return { fR, fG, fB, a/255.f };
439
+ }
428
440
  };
429
441
 
430
442
  /** \struct SkColor4f
@@ -37,8 +37,17 @@ struct SK_API SkColorSpacePrimaries {
37
37
  * representation of SkColorSpace.
38
38
  */
39
39
  bool toXYZD50(skcms_Matrix3x3* toXYZD50) const;
40
+
41
+ bool operator==(const SkColorSpacePrimaries& other) const {
42
+ return fRX == other.fRX && fRY == other.fRY && fGX == other.fGX && fGY == other.fGY &&
43
+ fBX == other.fBX && fBY == other.fBY && fWX == other.fWX && fWY == other.fWY;
44
+ }
40
45
  };
41
46
 
47
+ // TODO(https://issuetracker.google.com/issues/40044808): Remove this when no longer needed by
48
+ // Chromium.
49
+ #define SKIA_COLOR_SPACE_PRIMARIES_OPERATOR_EQUAL
50
+
42
51
  namespace SkNamedPrimaries {
43
52
 
44
53
  ////////////////////////////////////////////////////////////////////////////////
@@ -48,7 +48,7 @@ public:
48
48
  [[nodiscard]] bool getMatrix(SkScalar distance, SkMatrix* matrix,
49
49
  MatrixFlags flags = kGetPosAndTan_MatrixFlag) const;
50
50
 
51
- /** Given a start and stop distance, return in dst the intervening segment(s).
51
+ /** Given a start and stop distance, append to dst the intervening segment(s).
52
52
  If the segment is zero-length, return false, else return true.
53
53
  startD and stopD are pinned to legal values (0..getLength()). If startD > stopD
54
54
  then return false (and leave dst untouched).
@@ -56,10 +56,6 @@ public:
56
56
  */
57
57
  [[nodiscard]] bool getSegment(SkScalar startD, SkScalar stopD, SkPathBuilder* dst,
58
58
  bool startWithMoveTo) const;
59
- #ifdef SK_SUPPORT_MUTABLE_PATHEFFECT
60
- [[nodiscard]] bool getSegment(SkScalar startD, SkScalar stopD, SkPath* dst,
61
- bool startWithMoveTo) const;
62
- #endif
63
59
 
64
60
  /** Return true if the contour is closed()
65
61
  */
@@ -39,6 +39,14 @@ public:
39
39
  return (other != nullptr) && *this == *other;
40
40
  }
41
41
 
42
+ /**
43
+ * Return true if both arguments are the same size and contain the same bytes, or if both
44
+ * arguments are null.
45
+ */
46
+ static bool Equals(const SkData* a, const SkData* b) {
47
+ return (a == nullptr) ? (b == nullptr) : a->equals(b);
48
+ }
49
+
42
50
  /**
43
51
  * Returns the number of bytes stored.
44
52
  */
@@ -8,7 +8,7 @@
8
8
  #ifndef SkFont_DEFINED
9
9
  #define SkFont_DEFINED
10
10
 
11
- #include "include/core/SkPath.h" // IWYU pragma: keep (for SK_HIDE_PATH_EDIT_METHODS)
11
+ #include "include/core/SkPath.h"
12
12
  #include "include/core/SkPoint.h" // IWYU pragma: keep (for unspanned apis)
13
13
  #include "include/core/SkRect.h"
14
14
  #include "include/core/SkRefCnt.h"
@@ -442,10 +442,6 @@ public:
442
442
  */
443
443
  std::optional<SkPath> getPath(SkGlyphID glyphID) const;
444
444
 
445
- #ifndef SK_HIDE_PATH_EDIT_METHODS
446
- bool getPath(SkGlyphID glyphID, SkPath* path) const;
447
- #endif
448
-
449
445
  /** Returns path corresponding to glyph array.
450
446
 
451
447
  @param glyphIDs array of glyph indices
@@ -486,56 +482,6 @@ public:
486
482
 
487
483
  using sk_is_trivially_relocatable = std::true_type;
488
484
 
489
- #ifdef SK_SUPPORT_UNSPANNED_APIS
490
- int textToGlyphs(const void* text, size_t byteLength, SkTextEncoding encoding,
491
- SkGlyphID glyphs[], int maxGlyphCount) const {
492
- return (int)this->textToGlyphs(text, byteLength, encoding, {glyphs, maxGlyphCount});
493
- }
494
- void unicharsToGlyphs(const SkUnichar uni[], int count, SkGlyphID glyphs[]) const {
495
- this->unicharsToGlyphs({uni, count}, {glyphs, count});
496
- }
497
-
498
- void getPos(const SkGlyphID glyphs[], int count, SkPoint pos[], SkPoint origin = {0, 0}) const {
499
- this->getPos({glyphs, count}, {pos, count}, origin);
500
- }
501
- void getXPos(const SkGlyphID glyphs[], int count, SkScalar xpos[], SkScalar origin = 0) const {
502
- this->getXPos({glyphs, count}, {xpos, count}, origin);
503
- }
504
- void getPaths(const SkGlyphID glyphIDs[], int count,
505
- void (*glyphPathProc)(const SkPath* pathOrNull, const SkMatrix& mx, void* ctx),
506
- void* ctx) const {
507
- this->getPaths({glyphIDs, count}, glyphPathProc, ctx);
508
- }
509
- void getWidthsBounds(const SkGlyphID glyphs[], int count, SkScalar widths[], SkRect bounds[],
510
- const SkPaint* paint) const {
511
- const auto nw = widths ? count : 0;
512
- const auto nb = bounds ? count : 0;
513
- this->getWidthsBounds({glyphs, count}, {widths, nw}, {bounds, nb}, paint);
514
- }
515
- void getWidths(const SkGlyphID glyphs[], int count, SkScalar widths[], SkRect bounds[]) const {
516
- const auto nw = widths ? count : 0;
517
- const auto nb = bounds ? count : 0;
518
- this->getWidthsBounds({glyphs, count}, {widths, nw}, {bounds, nb}, nullptr);
519
- }
520
- void getWidths(const SkGlyphID glyphs[], int count, SkScalar widths[], std::nullptr_t) const {
521
- this->getWidthsBounds({glyphs, count}, {widths, count}, {}, nullptr);
522
- }
523
- void getWidths(const SkGlyphID glyphs[], int count, SkScalar widths[]) const {
524
- this->getWidthsBounds({glyphs, count}, {widths, count}, {}, nullptr);
525
- }
526
- void getBounds(const SkGlyphID glyphs[], int count, SkRect bounds[],
527
- const SkPaint* paint) const {
528
- this->getWidthsBounds({glyphs, count}, {}, {bounds, count}, paint);
529
- }
530
-
531
- std::vector<SkScalar> getIntercepts(const SkGlyphID glyphs[], int count, const SkPoint pos[],
532
- SkScalar top, SkScalar bottom,
533
- const SkPaint* paint = nullptr) const {
534
- return this->getIntercepts({glyphs, count}, {pos, count}, top, bottom, paint);
535
- }
536
- #endif
537
-
538
-
539
485
  private:
540
486
  enum PrivFlags {
541
487
  kForceAutoHinting_PrivFlag = 1 << 0,
@@ -13,6 +13,7 @@
13
13
  #include "include/core/SkTypes.h"
14
14
 
15
15
  #include <cstdint>
16
+ #include <optional>
16
17
 
17
18
  /** Represents a set of actual arguments for a font. */
18
19
  struct SkFontArguments {
@@ -87,10 +88,24 @@ struct SkFontArguments {
87
88
 
88
89
  Palette getPalette() const { return fPalette; }
89
90
 
91
+ SkFontArguments& setSyntheticBold(std::optional<bool> bold) {
92
+ fSyntheticBold = bold;
93
+ return *this;
94
+ }
95
+ std::optional<bool> getSyntheticBold() const { return fSyntheticBold; }
96
+
97
+ SkFontArguments& setSyntheticOblique(std::optional<bool> oblique) {
98
+ fSyntheticOblique = oblique;
99
+ return *this;
100
+ }
101
+ std::optional<bool> getSyntheticOblique() const { return fSyntheticOblique; }
102
+
90
103
  private:
91
104
  int fCollectionIndex;
92
105
  VariationPosition fVariationDesignPosition;
93
106
  Palette fPalette;
107
+ std::optional<bool> fSyntheticBold;
108
+ std::optional<bool> fSyntheticOblique;
94
109
  };
95
110
 
96
111
  #endif
@@ -140,13 +140,8 @@ public:
140
140
  */
141
141
  static void PurgeAllCaches();
142
142
 
143
- #if defined(SK_DISABLE_LEGACY_NONCONST_ENCODED_IMAGE_DATA)
144
143
  using ImageGeneratorFromEncodedDataFactory =
145
144
  std::unique_ptr<SkImageGenerator> (*)(sk_sp<const SkData>);
146
- #else
147
- using ImageGeneratorFromEncodedDataFactory =
148
- std::unique_ptr<SkImageGenerator> (*)(sk_sp<SkData>);
149
- #endif
150
145
 
151
146
  /**
152
147
  * To instantiate images from encoded data, first looks at this runtime function-ptr. If it
@@ -739,11 +739,7 @@ public:
739
739
 
740
740
  example: https://fiddle.skia.org/c/@Image_refEncodedData
741
741
  */
742
- #if defined(SK_DISABLE_LEGACY_NONCONST_ENCODED_IMAGE_DATA)
743
742
  sk_sp<const SkData> refEncodedData() const;
744
- #else
745
- sk_sp<SkData> refEncodedData() const;
746
- #endif
747
743
 
748
744
  struct RequiredProperties {
749
745
  bool fMipmapped = false;
@@ -116,11 +116,8 @@ protected:
116
116
 
117
117
  SkImageGenerator(const SkImageInfo& info, uint32_t uniqueId = kNeedNewImageUniqueID);
118
118
 
119
- #if defined(SK_DISABLE_LEGACY_NONCONST_ENCODED_IMAGE_DATA)
120
119
  virtual sk_sp<const SkData> onRefEncodedData() { return nullptr; }
121
- #else
122
- virtual sk_sp<SkData> onRefEncodedData() { return nullptr; }
123
- #endif
120
+
124
121
  struct Options {};
125
122
  virtual bool onGetPixels(const SkImageInfo&, void*, size_t, const Options&) { return false; }
126
123
  virtual bool onIsValid(SkRecorder*) const { return true; }
@@ -1740,43 +1740,6 @@ public:
1740
1740
  */
1741
1741
  bool isFinite() const { return SkIsFinite(fMat, 9); }
1742
1742
 
1743
- #ifdef SK_SUPPORT_UNSPANNED_APIS
1744
- bool setPolyToPoly(const SkPoint src[], const SkPoint dst[], int count) {
1745
- return this->setPolyToPoly({src, count}, {dst, count});
1746
- }
1747
-
1748
- void mapPoints(SkPoint dst[], const SkPoint src[], int count) const {
1749
- this->mapPoints({dst, count}, {src, count});
1750
- }
1751
- void mapPoints(SkPoint pts[], int count) const {
1752
- this->mapPoints(pts, pts, count);
1753
- }
1754
-
1755
- void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint3 src[], int count) const {
1756
- this->mapHomogeneousPoints({dst, count}, {src, count});
1757
- }
1758
- void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint src[], int count) const {
1759
- this->mapPointsToHomogeneous({dst, count}, {src, count});
1760
- }
1761
-
1762
- void mapVectors(SkVector dst[], const SkVector src[], int count) const {
1763
- this->mapVectors({dst, count}, {src, count});
1764
- }
1765
- void mapVectors(SkVector vecs[], int count) const {
1766
- this->mapVectors({vecs, count});
1767
- }
1768
- void mapXY(SkScalar x, SkScalar y, SkPoint* result) const {
1769
- *result = this->mapPoint({x, y});
1770
- }
1771
- SkPoint mapXY(SkScalar x, SkScalar y) const {
1772
- return this->mapPoint({x, y});
1773
- }
1774
- void mapVector(SkScalar dx, SkScalar dy, SkVector* result) const {
1775
- SkVector vec = { dx, dy };
1776
- this->mapVectors({result, 1}, {&vec, 1});
1777
- }
1778
- #endif
1779
-
1780
1743
  private:
1781
1744
  /** Set if the matrix will map a rectangle to another rectangle. This
1782
1745
  can be true if the matrix is scale-only, or rotates a multiple of
@@ -5,5 +5,5 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
  #ifndef SK_MILESTONE
8
- #define SK_MILESTONE 144
8
+ #define SK_MILESTONE 147
9
9
  #endif