@shopify/react-native-skia 2.0.5 → 2.0.7

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 (180) hide show
  1. package/android/CMakeLists.txt +10 -0
  2. package/android/build.gradle +2 -1
  3. package/apple/SkiaCVPixelBufferUtils.mm +8 -4
  4. package/cpp/api/JsiSkCanvas.h +10 -8
  5. package/cpp/api/JsiSkFont.h +14 -18
  6. package/cpp/api/JsiSkPath.h +6 -3
  7. package/cpp/api/JsiSkPathEffectFactory.h +2 -2
  8. package/cpp/api/JsiSkPathFactory.h +1 -1
  9. package/cpp/api/JsiSkTextBlobFactory.h +5 -3
  10. package/cpp/api/JsiSkTypeface.h +5 -4
  11. package/cpp/api/recorder/Drawings.h +26 -20
  12. package/cpp/api/recorder/PathEffects.h +3 -2
  13. package/cpp/skia/include/android/SkAndroidFrameworkUtils.h +1 -1
  14. package/cpp/skia/include/android/SkImageAndroid.h +1 -8
  15. package/cpp/skia/include/config/SkUserConfig.h +9 -0
  16. package/cpp/skia/include/core/SkCPUContext.h +31 -0
  17. package/cpp/skia/include/core/SkCPURecorder.h +69 -0
  18. package/cpp/skia/include/core/SkCanvas.h +57 -13
  19. package/cpp/skia/include/core/SkContourMeasure.h +1 -1
  20. package/cpp/skia/include/core/SkData.h +63 -37
  21. package/cpp/skia/include/core/SkFont.h +94 -65
  22. package/cpp/skia/include/core/SkImage.h +10 -9
  23. package/cpp/skia/include/core/SkImageGenerator.h +3 -0
  24. package/cpp/skia/include/core/SkMatrix.h +102 -116
  25. package/cpp/skia/include/core/SkMilestone.h +1 -1
  26. package/cpp/skia/include/core/SkPath.h +163 -60
  27. package/cpp/skia/include/core/SkPathBuilder.h +713 -30
  28. package/cpp/skia/include/core/SkPathTypes.h +5 -1
  29. package/cpp/skia/include/core/SkPictureRecorder.h +6 -6
  30. package/cpp/skia/include/core/SkRecorder.h +35 -0
  31. package/cpp/skia/include/core/SkRect.h +57 -27
  32. package/cpp/skia/include/core/SkRegion.h +1 -1
  33. package/cpp/skia/include/core/SkSurface.h +8 -1
  34. package/cpp/skia/include/core/SkTextBlob.h +50 -6
  35. package/cpp/skia/include/core/SkTraceMemoryDump.h +7 -0
  36. package/cpp/skia/include/core/SkTypeface.h +53 -26
  37. package/cpp/skia/include/core/SkTypes.h +6 -0
  38. package/cpp/skia/include/effects/SkDashPathEffect.h +9 -3
  39. package/cpp/skia/include/effects/SkRuntimeEffect.h +1 -1
  40. package/cpp/skia/include/encode/SkEncoder.h +1 -1
  41. package/cpp/skia/include/encode/SkICC.h +1 -1
  42. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +23 -0
  43. package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +12 -0
  44. package/cpp/skia/include/gpu/graphite/Context.h +32 -8
  45. package/cpp/skia/include/gpu/graphite/ContextOptions.h +22 -4
  46. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +21 -4
  47. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +16 -2
  48. package/cpp/skia/include/gpu/graphite/Recorder.h +30 -10
  49. package/cpp/skia/include/gpu/graphite/Recording.h +7 -3
  50. package/cpp/skia/include/gpu/graphite/TextureInfo.h +3 -3
  51. package/cpp/skia/include/gpu/graphite/precompile/PaintOptions.h +15 -0
  52. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +89 -13
  53. package/cpp/skia/include/gpu/graphite/vk/precompile/VulkanPrecompileShader.h +39 -0
  54. package/cpp/skia/include/gpu/vk/VulkanBackendContext.h +1 -1
  55. package/cpp/skia/include/gpu/vk/VulkanPreferredFeatures.h +214 -0
  56. package/cpp/skia/include/ports/SkFontMgr_fontconfig.h +3 -0
  57. package/cpp/skia/include/private/SkGainmapShader.h +10 -4
  58. package/cpp/skia/include/private/SkPathRef.h +6 -2
  59. package/cpp/skia/include/private/base/SkAlign.h +11 -0
  60. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
  61. package/cpp/skia/include/third_party/vulkan/vulkan/vk_icd.h +255 -0
  62. package/cpp/skia/include/third_party/vulkan/vulkan/vk_layer.h +203 -0
  63. package/cpp/skia/include/third_party/vulkan/vulkan/vk_platform.h +1 -2
  64. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std.h +390 -0
  65. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_decode.h +106 -0
  66. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_av1std_encode.h +140 -0
  67. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +1 -1
  68. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +1 -1
  69. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_encode.h +144 -0
  70. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +1 -1
  71. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +1 -1
  72. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_encode.h +158 -0
  73. package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +1 -1
  74. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +1 -1
  75. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +1 -1
  76. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_beta.h +242 -0
  77. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +10094 -5707
  78. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_directfb.h +55 -0
  79. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_fuchsia.h +288 -0
  80. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ggp.h +59 -0
  81. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +1 -1
  82. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +1 -1
  83. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_metal.h +238 -0
  84. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_screen.h +110 -0
  85. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_vi.h +47 -0
  86. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_wayland.h +55 -0
  87. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +1 -1
  88. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +1 -1
  89. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib.h +60 -0
  90. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xlib_xrandr.h +46 -0
  91. package/cpp/skia/modules/skcms/src/skcms_internals.h +10 -2
  92. package/cpp/skia/modules/skcms/src/skcms_public.h +39 -10
  93. package/libs/android/arm64-v8a/libpathops.a +0 -0
  94. package/libs/android/arm64-v8a/libskia.a +0 -0
  95. package/libs/android/arm64-v8a/libskottie.a +0 -0
  96. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  97. package/libs/android/arm64-v8a/libsksg.a +0 -0
  98. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  99. package/libs/android/arm64-v8a/libskunicode_icu.a +0 -0
  100. package/libs/android/arm64-v8a/libsvg.a +0 -0
  101. package/libs/android/armeabi-v7a/libpathops.a +0 -0
  102. package/libs/android/armeabi-v7a/libskia.a +0 -0
  103. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  104. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  105. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  106. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  107. package/libs/android/armeabi-v7a/libskunicode_icu.a +0 -0
  108. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  109. package/libs/android/x86/libpathops.a +0 -0
  110. package/libs/android/x86/libskia.a +0 -0
  111. package/libs/android/x86/libskottie.a +0 -0
  112. package/libs/android/x86/libskparagraph.a +0 -0
  113. package/libs/android/x86/libsksg.a +0 -0
  114. package/libs/android/x86/libskshaper.a +0 -0
  115. package/libs/android/x86/libskunicode_icu.a +0 -0
  116. package/libs/android/x86/libsvg.a +0 -0
  117. package/libs/android/x86_64/libpathops.a +0 -0
  118. package/libs/android/x86_64/libskia.a +0 -0
  119. package/libs/android/x86_64/libskottie.a +0 -0
  120. package/libs/android/x86_64/libskparagraph.a +0 -0
  121. package/libs/android/x86_64/libsksg.a +0 -0
  122. package/libs/android/x86_64/libskshaper.a +0 -0
  123. package/libs/android/x86_64/libskunicode_icu.a +0 -0
  124. package/libs/android/x86_64/libsvg.a +0 -0
  125. package/libs/apple/libpathops.xcframework/Info.plist +94 -0
  126. package/libs/apple/libpathops.xcframework/ios-arm64_arm64e/libpathops.a +0 -0
  127. package/libs/apple/libpathops.xcframework/ios-arm64_arm64e_x86_64-simulator/libpathops.a +0 -0
  128. package/libs/apple/libpathops.xcframework/macos-arm64_x86_64/libpathops.a +0 -0
  129. package/libs/apple/libpathops.xcframework/tvos-arm64_arm64e/libpathops.a +0 -0
  130. package/libs/apple/libpathops.xcframework/tvos-arm64_arm64e_x86_64-simulator/libpathops.a +0 -0
  131. package/libs/apple/libskia.xcframework/Info.plist +14 -14
  132. package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  133. package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  134. package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
  135. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
  136. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  137. package/libs/apple/libskottie.xcframework/Info.plist +8 -8
  138. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  139. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  140. package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
  141. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
  142. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  143. package/libs/apple/libskparagraph.xcframework/Info.plist +14 -14
  144. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  145. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  146. package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
  147. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
  148. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  149. package/libs/apple/libsksg.xcframework/Info.plist +8 -8
  150. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  151. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  152. package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
  153. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
  154. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  155. package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
  156. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  157. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  158. package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
  159. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
  160. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  161. package/libs/apple/libskunicode_core.xcframework/Info.plist +12 -12
  162. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  163. package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
  164. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  165. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +13 -13
  166. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  167. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  168. package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
  169. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  170. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  171. package/libs/apple/libsvg.xcframework/Info.plist +12 -12
  172. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  173. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  174. package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
  175. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
  176. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  177. package/package.json +1 -1
  178. package/react-native-skia.podspec +2 -1
  179. package/src/renderer/__tests__/e2e/BackdropFilters.spec.tsx +23 -0
  180. /package/cpp/skia/{include/pathops → modules/pathops/include}/SkPathOps.h +0 -0
@@ -33,6 +33,7 @@ class SkMipmap;
33
33
  class SkPaint;
34
34
  class SkPicture;
35
35
  class SkPixmap;
36
+ class SkRecorder;
36
37
  class SkShader;
37
38
  class SkSurfaceProps;
38
39
  enum SkColorType : int;
@@ -447,6 +448,7 @@ public:
447
448
  example: https://fiddle.skia.org/c/@Image_isValid
448
449
  */
449
450
  virtual bool isValid(GrRecordingContext* context) const = 0;
451
+ virtual bool isValid(SkRecorder*) const = 0;
450
452
 
451
453
  /** \enum SkImage::CachingHint
452
454
  CachingHint selects whether Skia may internally cache SkBitmap generated by
@@ -720,17 +722,16 @@ public:
720
722
  * The Recorder parameter is required if the original image was created on a graphite Recorder,
721
723
  * but must be nullptr if it was create in some other way (e.g. GrContext, raster, deferred).
722
724
  *
723
- * return nullptr if the requested ColorInfo is not supported, its dimesions are out of range,
725
+ * return nullptr if the requested ColorInfo is not supported, its dimesions are out of range,
724
726
  * or if the recorder is null on a graphite Image.
725
727
  */
726
- sk_sp<SkImage> makeScaled(skgpu::graphite::Recorder*,
728
+ sk_sp<SkImage> makeScaled(SkRecorder*, const SkImageInfo&, const SkSamplingOptions&) const;
729
+ sk_sp<SkImage> makeScaled(SkRecorder*,
727
730
  const SkImageInfo&,
728
- const SkSamplingOptions&) const;
731
+ const SkSamplingOptions&,
732
+ const SkSurfaceProps&) const;
729
733
 
730
- sk_sp<SkImage> makeScaled(const SkImageInfo& info,
731
- const SkSamplingOptions& sampling) const {
732
- return this->makeScaled(nullptr, info, sampling);
733
- }
734
+ sk_sp<SkImage> makeScaled(const SkImageInfo& info, const SkSamplingOptions& sampling) const;
734
735
 
735
736
  /** Returns encoded SkImage pixels as SkData, if SkImage was created from supported
736
737
  encoded stream format. Platform support for formats vary and may require building
@@ -913,7 +914,7 @@ public:
913
914
  @param RequiredProperties properties the returned SkImage must possess (e.g. mipmaps)
914
915
  @return created SkImage in target SkColorSpace
915
916
  */
916
- virtual sk_sp<SkImage> makeColorSpace(skgpu::graphite::Recorder*,
917
+ virtual sk_sp<SkImage> makeColorSpace(SkRecorder*,
917
918
  sk_sp<SkColorSpace> targetColorSpace,
918
919
  RequiredProperties) const = 0;
919
920
 
@@ -949,7 +950,7 @@ public:
949
950
  @param RequiredProperties properties the returned SkImage must possess (e.g. mipmaps)
950
951
  @return created SkImage in target SkColorType and SkColorSpace
951
952
  */
952
- virtual sk_sp<SkImage> makeColorTypeAndColorSpace(skgpu::graphite::Recorder*,
953
+ virtual sk_sp<SkImage> makeColorTypeAndColorSpace(SkRecorder*,
953
954
  SkColorType targetColorType,
954
955
  sk_sp<SkColorSpace> targetColorSpace,
955
956
  RequiredProperties) const = 0;
@@ -19,6 +19,7 @@
19
19
  #include <cstdint>
20
20
 
21
21
  class GrRecordingContext;
22
+ class SkRecorder;
22
23
 
23
24
  class SK_API SkImageGenerator {
24
25
  public:
@@ -53,6 +54,7 @@ public:
53
54
  bool isValid(GrRecordingContext* context) const {
54
55
  return this->onIsValid(context);
55
56
  }
57
+ bool isValid(SkRecorder* recorder) const { return this->onIsValid(recorder); }
56
58
 
57
59
  /**
58
60
  * Will this generator produce protected content
@@ -124,6 +126,7 @@ protected:
124
126
  struct Options {};
125
127
  virtual bool onGetPixels(const SkImageInfo&, void*, size_t, const Options&) { return false; }
126
128
  virtual bool onIsValid(GrRecordingContext*) const { return true; }
129
+ virtual bool onIsValid(SkRecorder*) const { return true; }
127
130
  virtual bool onIsProtected() const { return false; }
128
131
  virtual bool onQueryYUVAInfo(const SkYUVAPixmapInfo::SupportedDataTypes&,
129
132
  SkYUVAPixmapInfo*) const { return false; }
@@ -9,8 +9,10 @@
9
9
  #define SkMatrix_DEFINED
10
10
 
11
11
  #include "include/core/SkPoint.h"
12
+ #include "include/core/SkPoint3.h"
12
13
  #include "include/core/SkRect.h"
13
14
  #include "include/core/SkScalar.h"
15
+ #include "include/core/SkSpan.h"
14
16
  #include "include/core/SkTypes.h"
15
17
  #include "include/private/base/SkFloatingPoint.h"
16
18
  #include "include/private/base/SkMacros.h"
@@ -19,7 +21,6 @@
19
21
  #include <cstdint>
20
22
  #include <cstring>
21
23
 
22
- struct SkPoint3;
23
24
  struct SkRSXform;
24
25
  struct SkSize;
25
26
 
@@ -529,14 +530,14 @@ public:
529
530
  */
530
531
  SkMatrix& setTranslateY(SkScalar v) { return this->set(kMTransY, v); }
531
532
 
532
- /** Sets input x-axis perspective factor, which causes mapXY() to vary input x-axis values
533
+ /** Sets input x-axis perspective factor, which causes mapPoints() to vary input x-axis values
533
534
  inversely proportional to input y-axis values.
534
535
 
535
536
  @param v perspective factor
536
537
  */
537
538
  SkMatrix& setPerspX(SkScalar v) { return this->set(kMPersp0, v); }
538
539
 
539
- /** Sets input y-axis perspective factor, which causes mapXY() to vary input y-axis values
540
+ /** Sets input y-axis perspective factor, which causes mapPoints() to vary input y-axis values
540
541
  inversely proportional to input x-axis values.
541
542
 
542
543
  @param v perspective factor
@@ -1295,13 +1296,14 @@ public:
1295
1296
 
1296
1297
  src and dst may point to the same storage.
1297
1298
 
1298
- @param dst storage for mapped SkPoint
1299
- @param src SkPoint to transform
1300
- @param count number of SkPoint to transform
1299
+ @param dst span where the transformed points are written
1300
+ @param src spen where the points are read from
1301
+
1302
+ Note: min(dst.size(), src.size()) is the number of points that will be written to dst.
1301
1303
 
1302
1304
  example: https://fiddle.skia.org/c/@Matrix_mapPoints
1303
1305
  */
1304
- void mapPoints(SkPoint dst[], const SkPoint src[], int count) const;
1306
+ void mapPoints(SkSpan<SkPoint> dst, SkSpan<const SkPoint> src) const;
1305
1307
 
1306
1308
  /** Maps pts SkPoint array of length count in place. SkPoint are mapped by multiplying
1307
1309
  each SkPoint by SkMatrix. Given:
@@ -1323,11 +1325,10 @@ public:
1323
1325
  Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , -------
1324
1326
  |G H I| |1| Gx+Hy+I Gx+Hy+I
1325
1327
 
1326
- @param pts storage for mapped SkPoint
1327
- @param count number of SkPoint to transform
1328
+ @param pts span of points to be transformed in-place
1328
1329
  */
1329
- void mapPoints(SkPoint pts[], int count) const {
1330
- this->mapPoints(pts, pts, count);
1330
+ void mapPoints(SkSpan<SkPoint> pts) const {
1331
+ this->mapPoints(pts, pts);
1331
1332
  }
1332
1333
 
1333
1334
  /** Maps src SkPoint3 array of length count to dst SkPoint3 array, which must of length count or
@@ -1343,18 +1344,34 @@ public:
1343
1344
  Matrix * src = |D E F| |y| = |Ax+By+Cz Dx+Ey+Fz Gx+Hy+Iz|
1344
1345
  |G H I| |z|
1345
1346
 
1346
- @param dst storage for mapped SkPoint3 array
1347
- @param src SkPoint3 array to transform
1348
- @param count items in SkPoint3 array to transform
1347
+ @param dst span where the transformed points are written
1348
+ @param src spen where the points are read from
1349
+
1350
+ Note: min(dst.size(), src.size()) is the number of points that will be written to dst.
1349
1351
 
1350
1352
  example: https://fiddle.skia.org/c/@Matrix_mapHomogeneousPoints
1351
1353
  */
1352
- void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint3 src[], int count) const;
1354
+ void mapHomogeneousPoints(SkSpan<SkPoint3> dst, SkSpan<const SkPoint3> src) const;
1355
+
1356
+ SkPoint3 mapHomogeneousPoint(SkPoint3 src) const {
1357
+ SkPoint3 dst;
1358
+ this->mapHomogeneousPoints({&dst, 1}, {&src, 1});
1359
+ return dst;
1360
+ }
1353
1361
 
1354
1362
  /**
1355
1363
  * Returns homogeneous points, starting with 2D src points (with implied w = 1).
1364
+ *
1365
+ * Note: min(dst.size(), src.size()) is the number of points that will be written to dst.
1366
+
1356
1367
  */
1357
- void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint src[], int count) const;
1368
+ void mapPointsToHomogeneous(SkSpan<SkPoint3> dst, SkSpan<const SkPoint> src) const;
1369
+
1370
+ SkPoint3 mapPointToHomogeneous(SkPoint src) const {
1371
+ SkPoint3 dst;
1372
+ this->mapPointsToHomogeneous({&dst, 1}, {&src, 1});
1373
+ return dst;
1374
+ }
1358
1375
 
1359
1376
  /** Returns SkPoint pt multiplied by SkMatrix. Given:
1360
1377
 
@@ -1369,57 +1386,28 @@ public:
1369
1386
  |G H I| |1| Gx+Hy+I Gx+Hy+I
1370
1387
 
1371
1388
  @param p SkPoint to map
1372
- @return mapped SkPoint
1389
+ @return mapped SkPoint
1373
1390
  */
1374
- SkPoint mapPoint(SkPoint pt) const {
1375
- SkPoint result;
1376
- this->mapXY(pt.x(), pt.y(), &result);
1377
- return result;
1391
+ SkPoint mapPoint(SkPoint p) const {
1392
+ if (this->hasPerspective()) {
1393
+ return this->mapPointPerspective(p);
1394
+ } else {
1395
+ return this->mapPointAffine(p);
1396
+ }
1378
1397
  }
1379
1398
 
1380
- /** Maps SkPoint (x, y) to result. SkPoint is mapped by multiplying by SkMatrix. Given:
1381
-
1382
- | A B C | | x |
1383
- Matrix = | D E F |, pt = | y |
1384
- | G H I | | 1 |
1385
-
1386
- result is computed as:
1387
-
1388
- |A B C| |x| Ax+By+C Dx+Ey+F
1389
- Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , -------
1390
- |G H I| |1| Gx+Hy+I Gx+Hy+I
1391
-
1392
- @param x x-axis value of SkPoint to map
1393
- @param y y-axis value of SkPoint to map
1394
- @param result storage for mapped SkPoint
1395
-
1396
- example: https://fiddle.skia.org/c/@Matrix_mapXY
1397
- */
1398
- void mapXY(SkScalar x, SkScalar y, SkPoint* result) const;
1399
-
1400
- /** Returns SkPoint (x, y) multiplied by SkMatrix. Given:
1401
-
1402
- | A B C | | x |
1403
- Matrix = | D E F |, pt = | y |
1404
- | G H I | | 1 |
1405
-
1406
- result is computed as:
1407
-
1408
- |A B C| |x| Ax+By+C Dx+Ey+F
1409
- Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , -------
1410
- |G H I| |1| Gx+Hy+I Gx+Hy+I
1411
-
1412
- @param x x-axis value of SkPoint to map
1413
- @param y y-axis value of SkPoint to map
1414
- @return mapped SkPoint
1415
- */
1416
- SkPoint mapXY(SkScalar x, SkScalar y) const {
1417
- SkPoint result;
1418
- this->mapXY(x,y, &result);
1419
- return result;
1399
+ /*
1400
+ * If the caller knows the matrix has no perspective, this will inline the
1401
+ * math, making it more efficient than calling mapPoint().
1402
+ */
1403
+ SkPoint mapPointAffine(SkPoint p) const {
1404
+ SkASSERT(!this->hasPerspective());
1405
+ return {
1406
+ (p.fX * fMat[0] + p.fY * fMat[1]) + fMat[2],
1407
+ (p.fX * fMat[3] + p.fY * fMat[4]) + fMat[5],
1408
+ };
1420
1409
  }
1421
1410
 
1422
-
1423
1411
  /** Returns (0, 0) multiplied by SkMatrix. Given:
1424
1412
 
1425
1413
  | A B C | | 0 |
@@ -1469,13 +1457,14 @@ public:
1469
1457
 
1470
1458
  src and dst may point to the same storage.
1471
1459
 
1472
- @param dst storage for mapped vectors
1473
- @param src vectors to transform
1474
- @param count number of vectors to transform
1460
+ @param dst span where the transformed vectors are written
1461
+ @param src spen where the vectors are read from
1462
+
1463
+ Note: min(dst.size(), src.size()) is the number of points that will be written to dst.
1475
1464
 
1476
1465
  example: https://fiddle.skia.org/c/@Matrix_mapVectors
1477
1466
  */
1478
- void mapVectors(SkVector dst[], const SkVector src[], int count) const;
1467
+ void mapVectors(SkSpan<SkVector> dst, SkSpan<const SkVector> src) const;
1479
1468
 
1480
1469
  /** Maps vecs vector array of length count in place, multiplying each vector by
1481
1470
  SkMatrix, treating SkMatrix translation as zero. Given:
@@ -1498,32 +1487,9 @@ public:
1498
1487
  |G H I| |1| Gx+Hy+I Gx+Hy+I
1499
1488
 
1500
1489
  @param vecs vectors to transform, and storage for mapped vectors
1501
- @param count number of vectors to transform
1502
1490
  */
1503
- void mapVectors(SkVector vecs[], int count) const {
1504
- this->mapVectors(vecs, vecs, count);
1505
- }
1506
-
1507
- /** Maps vector (dx, dy) to result. Vector is mapped by multiplying by SkMatrix,
1508
- treating SkMatrix translation as zero. Given:
1509
-
1510
- | A B 0 | | dx |
1511
- Matrix = | D E 0 |, vec = | dy |
1512
- | G H I | | 1 |
1513
-
1514
- each result vector is computed as:
1515
-
1516
- |A B 0| |dx| A*dx+B*dy D*dx+E*dy
1517
- Matrix * vec = |D E 0| |dy| = |A*dx+B*dy D*dx+E*dy G*dx+H*dy+I| = ----------- , -----------
1518
- |G H I| | 1| G*dx+H*dy+I G*dx+*dHy+I
1519
-
1520
- @param dx x-axis value of vector to map
1521
- @param dy y-axis value of vector to map
1522
- @param result storage for mapped vector
1523
- */
1524
- void mapVector(SkScalar dx, SkScalar dy, SkVector* result) const {
1525
- SkVector vec = { dx, dy };
1526
- this->mapVectors(result, &vec, 1);
1491
+ void mapVectors(SkSpan<SkVector> vecs) const {
1492
+ this->mapVectors(vecs, vecs);
1527
1493
  }
1528
1494
 
1529
1495
  /** Returns vector (dx, dy) multiplied by SkMatrix, treating SkMatrix translation as zero.
@@ -1543,11 +1509,13 @@ public:
1543
1509
  @param dy y-axis value of vector to map
1544
1510
  @return mapped vector
1545
1511
  */
1546
- SkVector mapVector(SkScalar dx, SkScalar dy) const {
1547
- SkVector vec = { dx, dy };
1548
- this->mapVectors(&vec, &vec, 1);
1512
+ SkVector mapVector(SkVector vec) const {
1513
+ this->mapVectors({&vec, 1});
1549
1514
  return vec;
1550
1515
  }
1516
+ SkVector mapVector(SkScalar dx, SkScalar dy) const {
1517
+ return this->mapVector({dx, dy});
1518
+ }
1551
1519
 
1552
1520
  /** Sets dst to bounds of src corners mapped by SkMatrix.
1553
1521
  Returns true if mapped corners are dst corners.
@@ -1620,7 +1588,7 @@ public:
1620
1588
  void mapRectToQuad(SkPoint dst[4], const SkRect& rect) const {
1621
1589
  // This could potentially be faster if we only transformed each x and y of the rect once.
1622
1590
  rect.toQuad(dst);
1623
- this->mapPoints(dst, 4);
1591
+ this->mapPoints({dst, 4});
1624
1592
  }
1625
1593
 
1626
1594
  /** Sets dst to bounds of src corners mapped by SkMatrix. If matrix contains
@@ -1833,6 +1801,39 @@ public:
1833
1801
  */
1834
1802
  bool isFinite() const { return SkIsFinite(fMat, 9); }
1835
1803
 
1804
+ #ifdef SK_SUPPORT_UNSPANNED_APIS
1805
+ void mapPoints(SkPoint dst[], const SkPoint src[], int count) const {
1806
+ this->mapPoints({dst, count}, {src, count});
1807
+ }
1808
+ void mapPoints(SkPoint pts[], int count) const {
1809
+ this->mapPoints(pts, pts, count);
1810
+ }
1811
+
1812
+ void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint3 src[], int count) const {
1813
+ this->mapHomogeneousPoints({dst, count}, {src, count});
1814
+ }
1815
+ void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint src[], int count) const {
1816
+ this->mapPointsToHomogeneous({dst, count}, {src, count});
1817
+ }
1818
+
1819
+ void mapVectors(SkVector dst[], const SkVector src[], int count) const {
1820
+ this->mapVectors({dst, count}, {src, count});
1821
+ }
1822
+ void mapVectors(SkVector vecs[], int count) const {
1823
+ this->mapVectors({vecs, count});
1824
+ }
1825
+ void mapXY(SkScalar x, SkScalar y, SkPoint* result) const {
1826
+ *result = this->mapPoint({x, y});
1827
+ }
1828
+ SkPoint mapXY(SkScalar x, SkScalar y) const {
1829
+ return this->mapPoint({x, y});
1830
+ }
1831
+ void mapVector(SkScalar dx, SkScalar dy, SkVector* result) const {
1832
+ SkVector vec = { dx, dy };
1833
+ this->mapVectors({result, 1}, {&vec, 1});
1834
+ }
1835
+ #endif
1836
+
1836
1837
  private:
1837
1838
  /** Set if the matrix will map a rectangle to another rectangle. This
1838
1839
  can be true if the matrix is scale-only, or rotates a multiple of
@@ -1921,17 +1922,12 @@ private:
1921
1922
  }
1922
1923
  }
1923
1924
 
1924
- typedef void (*MapXYProc)(const SkMatrix& mat, SkScalar x, SkScalar y,
1925
- SkPoint* result);
1926
-
1927
- static MapXYProc GetMapXYProc(TypeMask mask) {
1928
- SkASSERT((mask & ~kAllMasks) == 0);
1929
- return gMapXYProcs[mask & kAllMasks];
1930
- }
1931
-
1932
- MapXYProc getMapXYProc() const {
1933
- return GetMapXYProc(this->getType());
1934
- }
1925
+ /*
1926
+ * If the caller knows the matrix perspective, this dos the extra work to
1927
+ * correctly compute the mapping. mapPoint() calls this, but only after
1928
+ * checking if the matrix includes perspective.
1929
+ */
1930
+ SkPoint mapPointPerspective(SkPoint pt) const;
1935
1931
 
1936
1932
  typedef void (*MapPtsProc)(const SkMatrix& mat, SkPoint dst[],
1937
1933
  const SkPoint src[], int count);
@@ -1951,16 +1947,6 @@ private:
1951
1947
  static bool Poly3Proc(const SkPoint[], SkMatrix*);
1952
1948
  static bool Poly4Proc(const SkPoint[], SkMatrix*);
1953
1949
 
1954
- static void Identity_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1955
- static void Trans_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1956
- static void Scale_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1957
- static void ScaleTrans_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1958
- static void Rot_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1959
- static void RotTrans_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1960
- static void Persp_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1961
-
1962
- static const MapXYProc gMapXYProcs[];
1963
-
1964
1950
  static void Identity_pts(const SkMatrix&, SkPoint[], const SkPoint[], int);
1965
1951
  static void Trans_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int);
1966
1952
  static void Scale_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int);
@@ -5,5 +5,5 @@
5
5
  * found in the LICENSE file.
6
6
  */
7
7
  #ifndef SK_MILESTONE
8
- #define SK_MILESTONE 136
8
+ #define SK_MILESTONE 139
9
9
  #endif