@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
@@ -8,95 +8,550 @@
8
8
  #ifndef SkPathBuilder_DEFINED
9
9
  #define SkPathBuilder_DEFINED
10
10
 
11
+ #include "include/core/SkMatrix.h"
11
12
  #include "include/core/SkPath.h"
12
13
  #include "include/core/SkPathTypes.h"
13
14
  #include "include/core/SkPoint.h"
14
15
  #include "include/core/SkRect.h"
15
16
  #include "include/core/SkRefCnt.h"
16
17
  #include "include/core/SkScalar.h"
18
+ #include "include/core/SkSpan.h"
17
19
  #include "include/core/SkTypes.h"
18
20
  #include "include/private/SkPathRef.h"
19
- #include "include/private/base/SkTo.h"
21
+ #include "include/private/base/SkTArray.h"
20
22
 
21
- #include <initializer_list>
23
+ #include <cstdint>
24
+ #include <optional>
25
+ #include <tuple>
22
26
 
23
27
  class SkRRect;
24
28
 
25
29
  class SK_API SkPathBuilder {
26
30
  public:
31
+ /** Constructs an empty SkPathBuilder. By default, SkPathBuilder has no verbs, no SkPoint, and
32
+ no weights. FillType is set to kWinding.
33
+
34
+ @return empty SkPathBuilder
35
+ */
27
36
  SkPathBuilder();
28
- SkPathBuilder(SkPathFillType);
29
- SkPathBuilder(const SkPath&);
37
+
38
+ /** Constructs an empty SkPathBuilder with the given FillType. By default, SkPathBuilder has no
39
+ verbs, no SkPoint, and no weights.
40
+
41
+ @param fillType SkPathFillType to set on the SkPathBuilder.
42
+ @return empty SkPathBuilder
43
+ */
44
+ SkPathBuilder(SkPathFillType fillType);
45
+
46
+ /** Constructs an SkPathBuilder that is a copy of an existing SkPath.
47
+ Copies the FillType and replays all of the verbs from the SkPath into the SkPathBuilder.
48
+
49
+ @param path SkPath to copy
50
+ @return SkPathBuilder
51
+ */
52
+ SkPathBuilder(const SkPath& path);
53
+
30
54
  SkPathBuilder(const SkPathBuilder&) = default;
31
55
  ~SkPathBuilder();
32
56
 
57
+ /** Sets an SkPathBuilder to be a copy of an existing SkPath.
58
+ Copies the FillType and replays all of the verbs from the SkPath into the SkPathBuilder.
59
+
60
+ @param path SkPath to copy
61
+ @return SkPathBuilder
62
+ */
33
63
  SkPathBuilder& operator=(const SkPath&);
64
+
34
65
  SkPathBuilder& operator=(const SkPathBuilder&) = default;
35
66
 
67
+ /** Returns SkPathFillType, the rule used to fill SkPath.
68
+
69
+ @return current SkPathFillType setting
70
+ */
36
71
  SkPathFillType fillType() const { return fFillType; }
72
+
73
+ /** Returns minimum and maximum axes values of SkPoint array.
74
+ Returns (0, 0, 0, 0) if SkPathBuilder contains no points. Returned bounds width and height
75
+ may be larger or smaller than area affected when SkPath is drawn.
76
+
77
+ SkRect returned includes all SkPoint added to SkPathBuilder, including SkPoint associated
78
+ with kMove_Verb that define empty contours.
79
+
80
+ @return bounds of all SkPoint in SkPoint array
81
+ */
37
82
  SkRect computeBounds() const;
38
83
 
39
- SkPath snapshot() const; // the builder is unchanged after returning this path
40
- SkPath detach(); // the builder is reset to empty after returning this path
84
+ /** Returns an SkPath representing the current state of the SkPathBuilder. The builder is
85
+ unchanged after returning the path.
86
+
87
+ @return SkPath representing the current state of the builder.
88
+ */
89
+ SkPath snapshot() const;
90
+
91
+ /** Returns an SkPath representing the current state of the SkPathBuilder. The builder is
92
+ reset to empty after returning the path.
93
+
94
+ @return SkPath representing the current state of the builder.
95
+ */
96
+ SkPath detach();
41
97
 
98
+ /** Sets SkPathFillType, the rule used to fill SkPath. While there is no
99
+ check that ft is legal, values outside of SkPathFillType are not supported.
100
+
101
+ @param ft SkPathFillType to be used by SKPaths generated from this builder.
102
+ @return reference to SkPathBuilder
103
+ */
42
104
  SkPathBuilder& setFillType(SkPathFillType ft) { fFillType = ft; return *this; }
105
+
106
+ /** Specifies whether SkPath is volatile; whether it will be altered or discarded
107
+ by the caller after it is drawn. SkPath by default have volatile set false, allowing
108
+ Skia to attach a cache of data which speeds repeated drawing.
109
+
110
+ Mark temporary paths, discarded or modified after use, as volatile
111
+ to inform Skia that the path need not be cached.
112
+
113
+ Mark animating SkPath volatile to improve performance.
114
+ Mark unchanging SkPath non-volatile to improve repeated rendering.
115
+
116
+ raster surface SkPath draws are affected by volatile for some shadows.
117
+ GPU surface SkPath draws are affected by volatile for some shadows and concave geometries.
118
+
119
+ @param isVolatile true if caller will alter SkPath after drawing
120
+ @return reference to SkPathBuilder
121
+ */
43
122
  SkPathBuilder& setIsVolatile(bool isVolatile) { fIsVolatile = isVolatile; return *this; }
44
123
 
124
+ /** Sets SkPathBuilder to its initial state.
125
+ Removes verb array, SkPoint array, and weights, and sets FillType to kWinding.
126
+ Internal storage associated with SkPathBuilder is released.
127
+
128
+ @return reference to SkPathBuilder
129
+ */
45
130
  SkPathBuilder& reset();
46
131
 
132
+ /** Adds beginning of contour at SkPoint p.
133
+
134
+ @param p contour start
135
+ @return reference to SkPathBuilder
136
+ */
47
137
  SkPathBuilder& moveTo(SkPoint pt);
138
+
139
+ /** Adds beginning of contour at SkPoint (x, y).
140
+
141
+ @param x x-axis value of contour start
142
+ @param y y-axis value of contour start
143
+ @return reference to SkPathBuilder
144
+ */
48
145
  SkPathBuilder& moveTo(SkScalar x, SkScalar y) { return this->moveTo(SkPoint::Make(x, y)); }
49
146
 
147
+ /** Adds line from last point to SkPoint p. If SkPathBuilder is empty, or last SkPath::Verb is
148
+ kClose_Verb, last point is set to (0, 0) before adding line.
149
+
150
+ lineTo() first appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
151
+ lineTo() then appends kLine_Verb to verb array and SkPoint p to SkPoint array.
152
+
153
+ @param p end SkPoint of added line
154
+ @return reference to SkPathBuilder
155
+ */
50
156
  SkPathBuilder& lineTo(SkPoint pt);
157
+
158
+ /** Adds line from last point to (x, y). If SkPathBuilder is empty, or last SkPath::Verb is
159
+ kClose_Verb, last point is set to (0, 0) before adding line.
160
+
161
+ lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
162
+ lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.
163
+
164
+ @param x end of added line on x-axis
165
+ @param y end of added line on y-axis
166
+ @return reference to SkPathBuilder
167
+ */
51
168
  SkPathBuilder& lineTo(SkScalar x, SkScalar y) { return this->lineTo(SkPoint::Make(x, y)); }
52
169
 
170
+ /** Adds quad from last point towards SkPoint p1, to SkPoint p2.
171
+ If SkPathBuilder is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
172
+ before adding quad.
173
+
174
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
175
+ then appends kQuad_Verb to verb array; and SkPoint p1, p2
176
+ to SkPoint array.
177
+
178
+ @param p1 control SkPoint of added quad
179
+ @param p2 end SkPoint of added quad
180
+ @return reference to SkPathBuilder
181
+ */
53
182
  SkPathBuilder& quadTo(SkPoint pt1, SkPoint pt2);
183
+
184
+ /** Adds quad from last point towards (x1, y1), to (x2, y2).
185
+ If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
186
+ before adding quad.
187
+
188
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
189
+ then appends kQuad_Verb to verb array; and (x1, y1), (x2, y2)
190
+ to SkPoint array.
191
+
192
+ @param x1 control SkPoint of quad on x-axis
193
+ @param y1 control SkPoint of quad on y-axis
194
+ @param x2 end SkPoint of quad on x-axis
195
+ @param y2 end SkPoint of quad on y-axis
196
+ @return reference to SkPath
197
+
198
+ example: https://fiddle.skia.org/c/@Path_quadTo
199
+ */
54
200
  SkPathBuilder& quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) {
55
201
  return this->quadTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2));
56
202
  }
203
+
204
+ /** Adds quad from last point towards the first SkPoint in pts, to the second.
205
+ If SkPathBuilder is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
206
+ before adding quad.
207
+
208
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
209
+ then appends kQuad_Verb to verb array; and the SkPoints to SkPoint array.
210
+
211
+ @param pts control point and endpoint of added quad.
212
+ @return reference to SkPathBuilder
213
+ */
57
214
  SkPathBuilder& quadTo(const SkPoint pts[2]) { return this->quadTo(pts[0], pts[1]); }
58
215
 
216
+ /** Adds conic from last point towards pt1, to pt2, weighted by w.
217
+ If SkPathBuilder is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
218
+ before adding conic.
219
+
220
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
221
+
222
+ If w is finite and not one, appends kConic_Verb to verb array;
223
+ and pt1, pt2 to SkPoint array; and w to conic weights.
224
+
225
+ If w is one, appends kQuad_Verb to verb array, and
226
+ pt1, pt2 to SkPoint array.
227
+
228
+ If w is not finite, appends kLine_Verb twice to verb array, and
229
+ pt1, pt2 to SkPoint array.
230
+
231
+ @param pt1 control SkPoint of conic
232
+ @param pt2 end SkPoint of conic
233
+ @param w weight of added conic
234
+ @return reference to SkPathBuilder
235
+ */
59
236
  SkPathBuilder& conicTo(SkPoint pt1, SkPoint pt2, SkScalar w);
237
+
238
+ /** Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.
239
+ If SkPathBuilder is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
240
+ before adding conic.
241
+
242
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
243
+
244
+ If w is finite and not one, appends kConic_Verb to verb array;
245
+ and (x1, y1), (x2, y2) to SkPoint array; and w to conic weights.
246
+
247
+ If w is one, appends kQuad_Verb to verb array, and
248
+ (x1, y1), (x2, y2) to SkPoint array.
249
+
250
+ If w is not finite, appends kLine_Verb twice to verb array, and
251
+ (x1, y1), (x2, y2) to SkPoint array.
252
+
253
+ @param x1 control SkPoint of conic on x-axis
254
+ @param y1 control SkPoint of conic on y-axis
255
+ @param x2 end SkPoint of conic on x-axis
256
+ @param y2 end SkPoint of conic on y-axis
257
+ @param w weight of added conic
258
+ @return reference to SkPathBuilder
259
+ */
60
260
  SkPathBuilder& conicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w) {
61
261
  return this->conicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), w);
62
262
  }
263
+
264
+ /** Adds conic from last point towards SkPoint p1, to SkPoint p2, weighted by w.
265
+ If SkPathBuilder is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0)
266
+ before adding conic.
267
+
268
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.
269
+
270
+ If w is finite and not one, appends kConic_Verb to verb array;
271
+ and SkPoint p1, p2 to SkPoint array; and w to conic weights.
272
+
273
+ If w is one, appends kQuad_Verb to verb array, and SkPoint p1, p2
274
+ to SkPoint array.
275
+
276
+ If w is not finite, appends kLine_Verb twice to verb array, and
277
+ SkPoint p1, p2 to SkPoint array.
278
+
279
+ @param p1 control SkPoint of added conic
280
+ @param p2 end SkPoint of added conic
281
+ @param w weight of added conic
282
+ @return reference to SkPathBuilder
283
+ */
63
284
  SkPathBuilder& conicTo(const SkPoint pts[2], SkScalar w) {
64
285
  return this->conicTo(pts[0], pts[1], w);
65
286
  }
66
287
 
288
+ /** Adds cubic from last point towards SkPoint p1, then towards SkPoint p2, ending at
289
+ SkPoint p3. If SkPathBuilder is empty, or last SkPath::Verb is kClose_Verb, last point is
290
+ set to (0, 0) before adding cubic.
291
+
292
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
293
+ then appends kCubic_Verb to verb array; and SkPoint p1, p2, p3
294
+ to SkPoint array.
295
+
296
+ @param p1 first control SkPoint of cubic
297
+ @param p2 second control SkPoint of cubic
298
+ @param p3 end SkPoint of cubic
299
+ @return reference to SkPathBuilder
300
+ */
67
301
  SkPathBuilder& cubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3);
302
+
303
+ /** Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at
304
+ (x3, y3). If SkPathBuilder is empty, or last SkPath::Verb is kClose_Verb, last point is set
305
+ to (0, 0) before adding cubic.
306
+
307
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
308
+ then appends kCubic_Verb to verb array; and (x1, y1), (x2, y2), (x3, y3)
309
+ to SkPoint array.
310
+
311
+ @param x1 first control SkPoint of cubic on x-axis
312
+ @param y1 first control SkPoint of cubic on y-axis
313
+ @param x2 second control SkPoint of cubic on x-axis
314
+ @param y2 second control SkPoint of cubic on y-axis
315
+ @param x3 end SkPoint of cubic on x-axis
316
+ @param y3 end SkPoint of cubic on y-axis
317
+ @return reference to SkPathBuilder
318
+ */
68
319
  SkPathBuilder& cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3) {
69
320
  return this->cubicTo(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), SkPoint::Make(x3, y3));
70
321
  }
322
+
323
+ /** Adds cubic from last point towards the first SkPoint, then towards the second, ending at
324
+ the third. If SkPathBuilder is empty, or last SkPath::Verb is kClose_Verb, last point is
325
+ set to (0, 0) before adding cubic.
326
+
327
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
328
+ then appends kCubic_Verb to verb array; and SkPoint p1, p2, p3
329
+ to SkPoint array.
330
+
331
+ @param pts first and second control SkPoints of cubic, and end SkPoint.
332
+ @return reference to SkPathBuilder
333
+ */
71
334
  SkPathBuilder& cubicTo(const SkPoint pts[3]) {
72
335
  return this->cubicTo(pts[0], pts[1], pts[2]);
73
336
  }
74
337
 
338
+ /** Appends kClose_Verb to SkPathBuilder. A closed contour connects the first and last SkPoint
339
+ with line, forming a continuous loop. Open and closed contour draw the same
340
+ with SkPaint::kFill_Style. With SkPaint::kStroke_Style, open contour draws
341
+ SkPaint::Cap at contour start and end; closed contour draws
342
+ SkPaint::Join at contour start and end.
343
+
344
+ close() has no effect if SkPathBuilder is empty or last SkPath SkPath::Verb is kClose_Verb.
345
+
346
+ @return reference to SkPathBuilder
347
+ */
75
348
  SkPathBuilder& close();
76
349
 
77
- // Append a series of lineTo(...)
78
- SkPathBuilder& polylineTo(const SkPoint pts[], int count);
79
- SkPathBuilder& polylineTo(const std::initializer_list<SkPoint>& list) {
80
- return this->polylineTo(list.begin(), SkToInt(list.size()));
81
- }
350
+ /** Append a series of lineTo(...)
351
+
352
+ @param pts span of SkPoint
353
+ @return reference to SkPathBuilder.
354
+ */
355
+ SkPathBuilder& polylineTo(SkSpan<const SkPoint> pts);
82
356
 
83
357
  // Relative versions of segments, relative to the previous position.
84
358
 
359
+ /** Adds line from last point to vector given by pt. If SkPathBuilder is empty, or last
360
+ SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding line.
361
+
362
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
363
+ then appends kLine_Verb to verb array and line end to SkPoint array.
364
+ Line end is last point plus vector given by pt.
365
+ Function name stands for "relative line to".
366
+
367
+ @param pt vector offset from last point to line end
368
+ @return reference to SkPathBuilder
369
+ */
85
370
  SkPathBuilder& rLineTo(SkPoint pt);
371
+
372
+ /** Adds line from last point to vector (dx, dy). If SkPathBuilder is empty, or last
373
+ SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding line.
374
+
375
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed;
376
+ then appends kLine_Verb to verb array and line end to SkPoint array.
377
+ Line end is last point plus vector (dx, dy).
378
+ Function name stands for "relative line to".
379
+
380
+ @param dx offset from last point to line end on x-axis
381
+ @param dy offset from last point to line end on y-axis
382
+ @return reference to SkPathBuilder
383
+ */
86
384
  SkPathBuilder& rLineTo(SkScalar x, SkScalar y) { return this->rLineTo({x, y}); }
385
+
386
+ /** Adds quad from last point towards vector pt1, to vector pt2.
387
+ If SkPathBuilder is empty, or last SkPath::Verb
388
+ is kClose_Verb, last point is set to (0, 0) before adding quad.
389
+
390
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
391
+ if needed; then appends kQuad_Verb to verb array; and appends quad
392
+ control and quad end to SkPoint array.
393
+ Quad control is last point plus vector pt1.
394
+ Quad end is last point plus vector pt2.
395
+ Function name stands for "relative quad to".
396
+
397
+ @param pt1 offset vector from last point to quad control
398
+ @param pt2 offset vector from last point to quad end
399
+ @return reference to SkPathBuilder
400
+ */
87
401
  SkPathBuilder& rQuadTo(SkPoint pt1, SkPoint pt2);
402
+
403
+ /** Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2).
404
+ If SkPathBuilder is empty, or last SkPath::Verb
405
+ is kClose_Verb, last point is set to (0, 0) before adding quad.
406
+
407
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
408
+ if needed; then appends kQuad_Verb to verb array; and appends quad
409
+ control and quad end to SkPoint array.
410
+ Quad control is last point plus vector (dx1, dy1).
411
+ Quad end is last point plus vector (dx2, dy2).
412
+ Function name stands for "relative quad to".
413
+
414
+ @param dx1 offset from last point to quad control on x-axis
415
+ @param dy1 offset from last point to quad control on y-axis
416
+ @param dx2 offset from last point to quad end on x-axis
417
+ @param dy2 offset from last point to quad end on y-axis
418
+ @return reference to SkPathBuilder
419
+ */
88
420
  SkPathBuilder& rQuadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) {
89
421
  return this->rQuadTo({x1, y1}, {x2, y2});
90
422
  }
423
+
424
+ /** Adds conic from last point towards vector p1, to vector p2,
425
+ weighted by w. If SkPathBuilder is empty, or last SkPath::Verb
426
+ is kClose_Verb, last point is set to (0, 0) before adding conic.
427
+
428
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
429
+ if needed.
430
+
431
+ If w is finite and not one, next appends kConic_Verb to verb array,
432
+ and w is recorded as conic weight; otherwise, if w is one, appends
433
+ kQuad_Verb to verb array; or if w is not finite, appends kLine_Verb
434
+ twice to verb array.
435
+
436
+ In all cases appends SkPoint control and end to SkPoint array.
437
+ control is last point plus vector p1.
438
+ end is last point plus vector p2.
439
+
440
+ Function name stands for "relative conic to".
441
+
442
+ @param p1 offset vector from last point to conic control
443
+ @param p2 offset vector from last point to conic end
444
+ @param w weight of added conic
445
+ @return reference to SkPathBuilder
446
+ */
91
447
  SkPathBuilder& rConicTo(SkPoint p1, SkPoint p2, SkScalar w);
448
+
449
+ /** Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2),
450
+ weighted by w. If SkPathBuilder is empty, or last SkPath::Verb
451
+ is kClose_Verb, last point is set to (0, 0) before adding conic.
452
+
453
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
454
+ if needed.
455
+
456
+ If w is finite and not one, next appends kConic_Verb to verb array,
457
+ and w is recorded as conic weight; otherwise, if w is one, appends
458
+ kQuad_Verb to verb array; or if w is not finite, appends kLine_Verb
459
+ twice to verb array.
460
+
461
+ In all cases appends SkPoint control and end to SkPoint array.
462
+ control is last point plus vector (dx1, dy1).
463
+ end is last point plus vector (dx2, dy2).
464
+
465
+ Function name stands for "relative conic to".
466
+
467
+ @param dx1 offset from last point to conic control on x-axis
468
+ @param dy1 offset from last point to conic control on y-axis
469
+ @param dx2 offset from last point to conic end on x-axis
470
+ @param dy2 offset from last point to conic end on y-axis
471
+ @param w weight of added conic
472
+ @return reference to SkPathBuilder
473
+ */
92
474
  SkPathBuilder& rConicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar w) {
93
475
  return this->rConicTo({x1, y1}, {x2, y2}, w);
94
476
  }
477
+
478
+ /** Adds cubic from last point towards vector pt1, then towards
479
+ vector pt2, to vector pt3.
480
+ If SkPathBuilder is empty, or last SkPath::Verb
481
+ is kClose_Verb, last point is set to (0, 0) before adding cubic.
482
+
483
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
484
+ if needed; then appends kCubic_Verb to verb array; and appends cubic
485
+ control and cubic end to SkPoint array.
486
+ Cubic control is last point plus vector (dx1, dy1).
487
+ Cubic end is last point plus vector (dx2, dy2).
488
+ Function name stands for "relative cubic to".
489
+
490
+ @param pt1 offset vector from last point to first cubic control
491
+ @param pt2 offset vector from last point to second cubic control
492
+ @param pt3 offset vector from last point to cubic end
493
+ @return reference to SkPathBuilder
494
+ */
95
495
  SkPathBuilder& rCubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3);
496
+
497
+ /** Adds cubic from last point towards vector (dx1, dy1), then towards
498
+ vector (dx2, dy2), to vector (dx3, dy3).
499
+ If SkPathBuilder is empty, or last SkPath::Verb
500
+ is kClose_Verb, last point is set to (0, 0) before adding cubic.
501
+
502
+ Appends kMove_Verb to verb array and (0, 0) to SkPoint array,
503
+ if needed; then appends kCubic_Verb to verb array; and appends cubic
504
+ control and cubic end to SkPoint array.
505
+ Cubic control is last point plus vector (dx1, dy1).
506
+ Cubic end is last point plus vector (dx2, dy2).
507
+ Function name stands for "relative cubic to".
508
+
509
+ @param dx1 offset from last point to first cubic control on x-axis
510
+ @param dy1 offset from last point to first cubic control on y-axis
511
+ @param dx2 offset from last point to second cubic control on x-axis
512
+ @param dy2 offset from last point to second cubic control on y-axis
513
+ @param dx3 offset from last point to cubic end on x-axis
514
+ @param dy3 offset from last point to cubic end on y-axis
515
+ @return reference to SkPathBuilder
516
+ */
96
517
  SkPathBuilder& rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3) {
97
518
  return this->rCubicTo({x1, y1}, {x2, y2}, {x3, y3});
98
519
  }
99
520
 
521
+ enum ArcSize {
522
+ kSmall_ArcSize, //!< smaller of arc pair
523
+ kLarge_ArcSize, //!< larger of arc pair
524
+ };
525
+
526
+ /** Appends arc to SkPathBuilder, relative to last SkPath SkPoint. Arc is implemented by one or
527
+ more conic, weighted to describe part of oval with radii (rx, ry) rotated by
528
+ xAxisRotate degrees. Arc curves from last SkPathBuilder SkPoint to relative end SkPoint:
529
+ (dx, dy), choosing one of four possible routes: clockwise or
530
+ counterclockwise, and smaller or larger. If SkPathBuilder is empty, the start arc SkPoint
531
+ is (0, 0).
532
+
533
+ Arc sweep is always less than 360 degrees. arcTo() appends line to end SkPoint
534
+ if either radii are zero, or if last SkPath SkPoint equals end SkPoint.
535
+ arcTo() scales radii (rx, ry) to fit last SkPath SkPoint and end SkPoint if both are
536
+ greater than zero but too small to describe an arc.
537
+
538
+ arcTo() appends up to four conic curves.
539
+ arcTo() implements the functionality of svg arc, although SVG "sweep-flag" value is
540
+ opposite the integer value of sweep; SVG "sweep-flag" uses 1 for clockwise, while
541
+ kCW_Direction cast to int is zero.
542
+
543
+ @param rx radius before x-axis rotation
544
+ @param ry radius before x-axis rotation
545
+ @param xAxisRotate x-axis rotation in degrees; positive values are clockwise
546
+ @param largeArc chooses smaller or larger arc
547
+ @param sweep chooses clockwise or counterclockwise arc
548
+ @param dx x-axis offset end of arc from last SkPath SkPoint
549
+ @param dy y-axis offset end of arc from last SkPath SkPoint
550
+ @return reference to SkPath
551
+ */
552
+ SkPathBuilder& rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
553
+ SkPathDirection sweep, SkScalar dx, SkScalar dy);
554
+
100
555
  // Arcs
101
556
 
102
557
  /** Appends arc to the builder. Arc added is part of ellipse
@@ -138,11 +593,6 @@ public:
138
593
  */
139
594
  SkPathBuilder& arcTo(SkPoint p1, SkPoint p2, SkScalar radius);
140
595
 
141
- enum ArcSize {
142
- kSmall_ArcSize, //!< smaller of arc pair
143
- kLarge_ArcSize, //!< larger of arc pair
144
- };
145
-
146
596
  /** Appends arc to SkPath. Arc is implemented by one or more conic weighted to describe
147
597
  part of oval with radii (r.fX, r.fY) rotated by xAxisRotate degrees. Arc curves
148
598
  from last SkPath SkPoint to (xy.fX, xy.fY), choosing one of four possible routes:
@@ -185,48 +635,278 @@ public:
185
635
  */
186
636
  SkPathBuilder& addArc(const SkRect& oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg);
187
637
 
188
- // Add a new contour
638
+ /** Adds a new contour to the SkPathBuilder, defined by the rect, and wound in the
639
+ specified direction. The verbs added to the path will be:
640
+
641
+ kMove, kLine, kLine, kLine, kClose
642
+
643
+ start specifies which corner to begin the contour:
644
+ 0: upper-left corner
645
+ 1: upper-right corner
646
+ 2: lower-right corner
647
+ 3: lower-left corner
189
648
 
649
+ This start point also acts as the implied beginning of the subsequent,
650
+ contour, if it does not have an explicit moveTo(). e.g.
651
+
652
+ path.addRect(...)
653
+ // if we don't say moveTo() here, we will use the rect's start point
654
+ path.lineTo(...)
655
+
656
+ @param rect SkRect to add as a closed contour
657
+ @param dir SkPath::Direction to orient the new contour
658
+ @param start initial corner of SkRect to add
659
+ @return reference to SkPathBuilder
660
+ */
190
661
  SkPathBuilder& addRect(const SkRect&, SkPathDirection, unsigned startIndex);
191
- SkPathBuilder& addOval(const SkRect&, SkPathDirection, unsigned startIndex);
192
- SkPathBuilder& addRRect(const SkRRect&, SkPathDirection, unsigned startIndex);
193
662
 
663
+ /** Adds a new contour to the SkPathBuilder, defined by the rect, and wound in the
664
+ specified direction. The verbs added to the path will be:
665
+
666
+ kMove, kLine, kLine, kLine, kClose
667
+
668
+ The contour starts at the upper-left corner of the rect, which also acts as the implied
669
+ beginning of the subsequent contour, if it does not have an explicit moveTo(). e.g.
670
+
671
+ path.addRect(...)
672
+ // if we don't say moveTo() here, we will use the rect's upper-left corner
673
+ path.lineTo(...)
674
+
675
+ @param rect SkRect to add as a closed contour
676
+ @param dir SkPath::Direction to orient the new contour
677
+ @return reference to SkPathBuilder
678
+ */
194
679
  SkPathBuilder& addRect(const SkRect& rect, SkPathDirection dir = SkPathDirection::kCW) {
195
680
  return this->addRect(rect, dir, 0);
196
681
  }
197
- SkPathBuilder& addOval(const SkRect& rect, SkPathDirection dir = SkPathDirection::kCW) {
198
- // legacy start index: 1
199
- return this->addOval(rect, dir, 1);
200
- }
682
+
683
+ /** Adds oval to SkPathBuilder, appending kMove_Verb, four kConic_Verb, and kClose_Verb.
684
+ Oval is upright ellipse bounded by SkRect oval with radii equal to half oval width
685
+ and half oval height. Oval begins at (oval.fRight, oval.centerY()) and continues
686
+ clockwise if dir is kCW_Direction, counterclockwise if dir is kCCW_Direction.
687
+
688
+ @param oval bounds of ellipse added
689
+ @param dir SkPath::Direction to wind ellipse
690
+ @return reference to SkPathBuilder
691
+ */
692
+ SkPathBuilder& addOval(const SkRect&, SkPathDirection, unsigned startIndex);
693
+
694
+ /** Appends SkRRect to SkPathBuilder, creating a new closed contour. If dir is kCW_Direction,
695
+ SkRRect winds clockwise. If dir is kCCW_Direction, SkRRect winds counterclockwise.
696
+
697
+ After appending, SkPathBuilder may be empty, or may contain: SkRect, oval, or SkRRect.
698
+
699
+ @param rrect SkRRect to add
700
+ @param dir SkPath::Direction to wind SkRRect
701
+ @param start index of initial point of SkRRect
702
+ @return reference to SkPathBuilder
703
+ */
704
+ SkPathBuilder& addRRect(const SkRRect& rrect, SkPathDirection, unsigned start);
705
+
706
+ /** Appends SkRRect to SkPathBuilder, creating a new closed contour. If dir is kCW_Direction,
707
+ SkRRect starts at top-left of the lower-left corner and winds clockwise. If dir is
708
+ kCCW_Direction, SkRRect starts at the bottom-left of the upper-left corner and winds
709
+ counterclockwise.
710
+
711
+ After appending, SkPathBuilder may be empty, or may contain: SkRect, oval, or SkRRect.
712
+
713
+ @param rrect SkRRect to add
714
+ @param dir SkPath::Direction to wind SkRRect
715
+ @return reference to SkPathBuilder
716
+ */
201
717
  SkPathBuilder& addRRect(const SkRRect& rrect, SkPathDirection dir = SkPathDirection::kCW) {
202
718
  // legacy start indices: 6 (CW) and 7 (CCW)
203
719
  return this->addRRect(rrect, dir, dir == SkPathDirection::kCW ? 6 : 7);
204
720
  }
205
721
 
206
- SkPathBuilder& addCircle(SkScalar center_x, SkScalar center_y, SkScalar radius,
722
+ /** Adds oval to SkPathBuilder, appending kMove_Verb, four kConic_Verb, and kClose_Verb.
723
+ Oval is upright ellipse bounded by SkRect oval with radii equal to half oval width
724
+ and half oval height. Oval begins at start and continues
725
+ clockwise if dir is kCW_Direction, counterclockwise if dir is kCCW_Direction.
726
+
727
+ @param oval bounds of ellipse added
728
+ @param dir SkPath::Direction to wind ellipse
729
+ @return reference to SkPath
730
+
731
+ example: https://fiddle.skia.org/c/@Path_addOval_2
732
+ */
733
+ SkPathBuilder& addOval(const SkRect& oval, SkPathDirection dir = SkPathDirection::kCW) {
734
+ // legacy start index: 1
735
+ return this->addOval(oval, dir, 1);
736
+ }
737
+
738
+ /** Adds circle centered at (x, y) of size radius to SkPathBuilder, appending kMove_Verb,
739
+ four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing
740
+ clockwise if dir is kCW_Direction, and counterclockwise if dir is kCCW_Direction.
741
+
742
+ Has no effect if radius is zero or negative.
743
+
744
+ @param x center of circle
745
+ @param y center of circle
746
+ @param radius distance from center to edge
747
+ @param dir SkPath::Direction to wind circle
748
+ @return reference to SkPathBuilder
749
+ */
750
+ SkPathBuilder& addCircle(SkScalar x, SkScalar y, SkScalar radius,
207
751
  SkPathDirection dir = SkPathDirection::kCW);
208
752
 
209
- SkPathBuilder& addPolygon(const SkPoint pts[], int count, bool isClosed);
210
- SkPathBuilder& addPolygon(const std::initializer_list<SkPoint>& list, bool isClosed) {
211
- return this->addPolygon(list.begin(), SkToInt(list.size()), isClosed);
753
+ /** Adds contour created from line array, adding (pts.size() - 1) line segments.
754
+ Contour added starts at pts[0], then adds a line for every additional SkPoint
755
+ in pts array. If close is true, appends kClose_Verb to SkPath, connecting
756
+ pts[count - 1] and pts[0].
757
+
758
+ @param pts array of line sharing end and start SkPoint
759
+ @param close true to add line connecting contour end and start
760
+ @return reference to SkPath
761
+ */
762
+ SkPathBuilder& addPolygon(SkSpan<const SkPoint> pts, bool close);
763
+
764
+ /** Appends src to SkPathBuilder, offset by (dx, dy).
765
+
766
+ If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are
767
+ added unaltered. If mode is kExtend_AddPathMode, add line before appending
768
+ verbs, SkPoint, and conic weights.
769
+
770
+ @param src SkPath verbs, SkPoint, and conic weights to add
771
+ @param dx offset added to src SkPoint array x-axis coordinates
772
+ @param dy offset added to src SkPoint array y-axis coordinates
773
+ @param mode kAppend_AddPathMode or kExtend_AddPathMode
774
+ @return reference to SkPathBuilder
775
+ */
776
+ SkPathBuilder& addPath(const SkPath& src, SkScalar dx, SkScalar dy,
777
+ SkPath::AddPathMode mode = SkPath::kAppend_AddPathMode);
778
+
779
+ /** Appends src to SkPathBuilder.
780
+
781
+ If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are
782
+ added unaltered. If mode is kExtend_AddPathMode, add line before appending
783
+ verbs, SkPoint, and conic weights.
784
+
785
+ @param src SkPath verbs, SkPoint, and conic weights to add
786
+ @param mode kAppend_AddPathMode or kExtend_AddPathMode
787
+ @return reference to SkPathBuilder
788
+ */
789
+ SkPathBuilder& addPath(const SkPath& src,
790
+ SkPath::AddPathMode mode = SkPath::kAppend_AddPathMode) {
791
+ SkMatrix m;
792
+ m.reset();
793
+ return this->addPath(src, m, mode);
212
794
  }
213
795
 
214
- SkPathBuilder& addPath(const SkPath&);
796
+ /** Appends src to SkPathBuilder, transformed by matrix. Transformed curves may have different
797
+ verbs, SkPoint, and conic weights.
798
+
799
+ If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic weights are
800
+ added unaltered. If mode is kExtend_AddPathMode, add line before appending
801
+ verbs, SkPoint, and conic weights.
802
+
803
+ @param src SkPath verbs, SkPoint, and conic weights to add
804
+ @param matrix transform applied to src
805
+ @param mode kAppend_AddPathMode or kExtend_AddPathMode
806
+ @return reference to SkPathBuilder
807
+ */
808
+ SkPathBuilder& addPath(const SkPath& src, const SkMatrix& matrix,
809
+ SkPath::AddPathMode mode = SkPath::AddPathMode::kAppend_AddPathMode);
215
810
 
216
811
  // Performance hint, to reserve extra storage for subsequent calls to lineTo, quadTo, etc.
217
812
 
813
+ /** Grows SkPathBuilder verb array and SkPoint array to contain additional space.
814
+ May improve performance and use less memory by
815
+ reducing the number and size of allocations when creating SkPathBuilder.
816
+
817
+ @param extraPtCount number of additional SkPoint to allocate
818
+ @param extraVerbCount number of additional verbs
819
+ */
218
820
  void incReserve(int extraPtCount, int extraVerbCount);
821
+
822
+ /** Grows SkPathBuilder verb array and SkPoint array to contain additional space.
823
+ May improve performance and use less memory by
824
+ reducing the number and size of allocations when creating SkPathBuilder.
825
+
826
+ @param extraPtCount number of additional SkPoints and verbs to allocate
827
+ */
219
828
  void incReserve(int extraPtCount) {
220
829
  this->incReserve(extraPtCount, extraPtCount);
221
830
  }
222
831
 
832
+ /** Offsets SkPoint array by (dx, dy).
833
+
834
+ @param dx offset added to SkPoint array x-axis coordinates
835
+ @param dy offset added to SkPoint array y-axis coordinates
836
+ */
223
837
  SkPathBuilder& offset(SkScalar dx, SkScalar dy);
224
838
 
839
+ /** Transforms verb array, SkPoint array, and weight by matrix.
840
+ transform may change verbs and increase their number.
841
+
842
+ @param matrix SkMatrix to apply to SkPath
843
+ @param pc whether to apply perspective clipping
844
+ */
845
+ SkPathBuilder& transform(const SkMatrix& matrix,
846
+ SkApplyPerspectiveClip pc = SkApplyPerspectiveClip::kYes);
847
+
848
+ /** Replaces SkPathFillType with its inverse. The inverse of SkPathFillType describes the area
849
+ unmodified by the original SkPathFillType.
850
+ */
225
851
  SkPathBuilder& toggleInverseFillType() {
226
852
  fFillType = (SkPathFillType)((unsigned)fFillType ^ 2);
227
853
  return *this;
228
854
  }
229
855
 
856
+ /** Returns if SkPath is empty.
857
+ Empty SkPathBuilder may have FillType but has no SkPoint, SkPath::Verb, or conic weight.
858
+ SkPathBuilder() constructs empty SkPathBuilder; reset() and rewind() make SkPath empty.
859
+
860
+ @return true if the path contains no SkPath::Verb array
861
+ */
862
+ bool isEmpty() const { return fVerbs.empty(); }
863
+
864
+ /** Returns last point on SkPathBuilder. Returns nullopt if SkPoint array is empty.
865
+
866
+ @return last SkPoint if SkPoint array contains one or more SkPoint, otherwise nullopt
867
+
868
+ example: https://fiddle.skia.org/c/@Path_getLastPt
869
+ */
870
+ std::optional<SkPoint> getLastPt() const;
871
+
872
+ /** Sets the last point on the path. If SkPoint array is empty, append kMove_Verb to
873
+ verb array and append p to SkPoint array.
874
+
875
+ @param x x-value of last point
876
+ @param y y-value of last point
877
+ */
878
+ void setLastPt(SkScalar x, SkScalar y);
879
+
880
+ /** Returns the number of points in SkPathBuilder.
881
+ SkPoint count is initially zero.
882
+
883
+ @return SkPathBuilder SkPoint array length
884
+ */
885
+ int countPoints() const { return fPts.size(); }
886
+
887
+ /** Returns if SkPathFillType describes area outside SkPath geometry. The inverse fill area
888
+ extends indefinitely.
889
+
890
+ @return true if FillType is kInverseWinding or kInverseEvenOdd
891
+ */
892
+ bool isInverseFillType() const { return SkPathFillType_IsInverse(fFillType); }
893
+
894
+ #ifdef SK_SUPPORT_UNSPANNED_APIS
895
+ SkPathBuilder& addPolygon(const SkPoint pts[], int count, bool close) {
896
+ return this->addPolygon({pts, count}, close);
897
+ }
898
+ SkPathBuilder& polylineTo(const SkPoint pts[], int count) {
899
+ return this->polylineTo({pts, count});
900
+ }
901
+ #endif
902
+
903
+ SkSpan<const SkPoint> points() const {
904
+ return fPts;
905
+ }
906
+ SkSpan<const uint8_t> verbs() const {
907
+ return fVerbs;
908
+ }
909
+
230
910
  private:
231
911
  SkPathRef::PointsArray fPts;
232
912
  SkPathRef::VerbsArray fVerbs;
@@ -250,8 +930,6 @@ private:
250
930
  int fIsAStart = -1; // tracks direction iff fIsA is not unknown
251
931
  bool fIsACCW = false; // tracks direction iff fIsA is not unknown
252
932
 
253
- int countVerbs() const { return fVerbs.size(); }
254
-
255
933
  // called right before we add a (non-move) verb
256
934
  void ensureMove() {
257
935
  fIsA = kIsA_MoreThanMoves;
@@ -262,7 +940,12 @@ private:
262
940
 
263
941
  SkPath make(sk_sp<SkPathRef>) const;
264
942
 
943
+ bool isZeroLengthSincePoint(int startPtIndex) const;
944
+
265
945
  SkPathBuilder& privateReverseAddPath(const SkPath&);
946
+ SkPathBuilder& privateReversePathTo(const SkPath&);
947
+
948
+ std::tuple<SkPoint*, SkScalar*> growForVerbsInPath(const SkPathRef& path);
266
949
 
267
950
  friend class SkPathPriv;
268
951
  };