@shopify/react-native-skia 0.1.197 → 0.1.199

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. package/android/CMakeLists.txt +32 -31
  2. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +4 -2
  3. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +3 -0
  4. package/cpp/api/JsiSkShaderFactory.h +4 -4
  5. package/cpp/api/JsiSkSurfaceFactory.h +2 -1
  6. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +2 -2
  7. package/cpp/skia/include/android/SkCanvasAndroid.h +20 -0
  8. package/cpp/skia/include/android/SkHeifDecoder.h +43 -0
  9. package/cpp/skia/include/android/SkSurfaceAndroid.h +50 -0
  10. package/cpp/skia/include/codec/SkAvifDecoder.h +43 -0
  11. package/cpp/skia/include/codec/SkBmpDecoder.h +43 -0
  12. package/cpp/skia/include/codec/SkCodec.h +25 -1
  13. package/cpp/skia/include/codec/SkGifDecoder.h +43 -0
  14. package/cpp/skia/include/codec/SkIcoDecoder.h +43 -0
  15. package/cpp/skia/include/codec/SkJpegDecoder.h +43 -0
  16. package/cpp/skia/include/codec/SkJpegxlDecoder.h +43 -0
  17. package/cpp/skia/include/codec/SkPngDecoder.h +43 -0
  18. package/cpp/skia/include/codec/SkRawDecoder.h +49 -0
  19. package/cpp/skia/include/codec/SkWbmpDecoder.h +43 -0
  20. package/cpp/skia/include/codec/SkWebpDecoder.h +43 -0
  21. package/cpp/skia/include/core/SkBBHFactory.h +5 -1
  22. package/cpp/skia/include/core/SkBlender.h +0 -2
  23. package/cpp/skia/include/core/SkCanvas.h +4 -23
  24. package/cpp/skia/include/core/SkColorFilter.h +14 -1
  25. package/cpp/skia/include/core/SkColorTable.h +59 -0
  26. package/cpp/skia/include/core/SkContourMeasure.h +3 -0
  27. package/cpp/skia/include/core/SkDeferredDisplayList.h +8 -104
  28. package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +8 -91
  29. package/cpp/skia/include/core/SkDrawable.h +5 -2
  30. package/cpp/skia/include/core/SkGraphics.h +7 -19
  31. package/cpp/skia/include/core/SkImage.h +157 -249
  32. package/cpp/skia/include/core/SkImageGenerator.h +0 -31
  33. package/cpp/skia/include/core/SkMilestone.h +1 -1
  34. package/cpp/skia/include/core/SkPathMeasure.h +3 -3
  35. package/cpp/skia/include/core/SkPictureRecorder.h +1 -1
  36. package/cpp/skia/include/core/SkPoint.h +5 -563
  37. package/cpp/skia/include/core/SkPoint3.h +1 -0
  38. package/cpp/skia/include/core/SkPromiseImageTexture.h +4 -30
  39. package/cpp/skia/include/core/SkRect.h +8 -8
  40. package/cpp/skia/include/core/SkSamplingOptions.h +4 -2
  41. package/cpp/skia/include/core/SkScalar.h +1 -1
  42. package/cpp/skia/include/core/SkSerialProcs.h +5 -1
  43. package/cpp/skia/include/core/SkShader.h +14 -21
  44. package/cpp/skia/include/core/SkString.h +2 -0
  45. package/cpp/skia/include/core/SkSurface.h +169 -701
  46. package/cpp/skia/include/core/SkSurfaceCharacterization.h +8 -256
  47. package/cpp/skia/include/core/SkTiledImageUtils.h +97 -0
  48. package/cpp/skia/include/core/SkTypes.h +4 -2
  49. package/cpp/skia/include/core/SkYUVAPixmaps.h +0 -5
  50. package/cpp/skia/include/effects/SkGradientShader.h +10 -1
  51. package/cpp/skia/include/effects/SkImageFilters.h +62 -37
  52. package/cpp/skia/include/effects/SkPerlinNoiseShader.h +28 -29
  53. package/cpp/skia/include/effects/SkRuntimeEffect.h +17 -12
  54. package/cpp/skia/include/gpu/GrBackendSurface.h +12 -39
  55. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +6 -0
  56. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +3 -3
  57. package/cpp/skia/include/gpu/GrDirectContext.h +103 -3
  58. package/cpp/skia/include/gpu/GrRecordingContext.h +10 -19
  59. package/cpp/skia/include/gpu/MutableTextureState.h +4 -0
  60. package/cpp/skia/include/gpu/ganesh/GrExternalTextureGenerator.h +54 -0
  61. package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +20 -76
  62. package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +217 -0
  63. package/cpp/skia/include/gpu/ganesh/mtl/SkSurfaceMetal.h +73 -0
  64. package/cpp/skia/include/gpu/gl/GrGLTypes.h +13 -2
  65. package/cpp/skia/include/gpu/graphite/BackendSemaphore.h +78 -0
  66. package/cpp/skia/include/gpu/graphite/BackendTexture.h +1 -0
  67. package/cpp/skia/include/gpu/graphite/Image.h +277 -0
  68. package/cpp/skia/include/gpu/graphite/ImageProvider.h +1 -1
  69. package/cpp/skia/include/gpu/graphite/Recording.h +1 -4
  70. package/cpp/skia/include/gpu/graphite/Surface.h +81 -0
  71. package/cpp/skia/include/gpu/graphite/TextureInfo.h +5 -7
  72. package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +2 -2
  73. package/cpp/skia/include/gpu/mock/GrMockTypes.h +23 -8
  74. package/cpp/skia/include/ports/SkTypeface_fontations.h +21 -0
  75. package/cpp/skia/include/private/SkGainmapInfo.h +2 -0
  76. package/cpp/skia/include/private/SkGainmapShader.h +1 -0
  77. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +19 -1
  78. package/cpp/skia/include/private/SkPathRef.h +13 -15
  79. package/cpp/skia/include/private/SkXmp.h +53 -0
  80. package/cpp/skia/include/private/base/SkFeatures.h +0 -4
  81. package/cpp/skia/include/private/base/SkFloatingPoint.h +11 -5
  82. package/cpp/skia/include/private/base/SkPoint_impl.h +569 -0
  83. package/cpp/skia/include/private/base/SkSpan_impl.h +3 -7
  84. package/cpp/skia/include/private/base/SkTArray.h +11 -11
  85. package/cpp/skia/include/private/chromium/GrDeferredDisplayList.h +120 -0
  86. package/cpp/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +98 -0
  87. package/cpp/skia/include/private/chromium/GrPromiseImageTexture.h +43 -0
  88. package/cpp/skia/include/private/chromium/GrSurfaceCharacterization.h +215 -0
  89. package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +6 -6
  90. package/cpp/skia/include/private/chromium/SkImageChromium.h +104 -0
  91. package/cpp/skia/include/private/chromium/Slug.h +7 -3
  92. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +7 -3
  93. package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +2 -0
  94. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +3 -2
  95. package/cpp/skia/include/private/gpu/ganesh/GrMtlTypesPriv.h +10 -2
  96. package/cpp/skia/include/{gpu → private/gpu}/ganesh/GrTextureGenerator.h +2 -13
  97. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
  98. package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +7 -0
  99. package/cpp/skia/include/private/gpu/graphite/MtlGraphiteTypesPriv.h +19 -6
  100. package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +13 -0
  101. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +0 -1
  102. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +14 -1
  103. package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +999 -79
  104. package/cpp/skia/modules/skcms/src/Transform_inl.h +36 -236
  105. package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -0
  106. package/cpp/skia/modules/skparagraph/include/ParagraphBuilder.h +16 -0
  107. package/cpp/skia/modules/skparagraph/include/TextStyle.h +6 -2
  108. package/cpp/skia/modules/skresources/include/SkResources.h +1 -1
  109. package/cpp/skia/modules/svg/include/SkSVGCircle.h +1 -1
  110. package/cpp/skia/modules/svg/include/SkSVGClipPath.h +1 -1
  111. package/cpp/skia/modules/svg/include/SkSVGContainer.h +1 -1
  112. package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -1
  113. package/cpp/skia/modules/svg/include/SkSVGDefs.h +1 -1
  114. package/cpp/skia/modules/svg/include/SkSVGEllipse.h +1 -1
  115. package/cpp/skia/modules/svg/include/SkSVGFe.h +1 -1
  116. package/cpp/skia/modules/svg/include/SkSVGFeBlend.h +1 -1
  117. package/cpp/skia/modules/svg/include/SkSVGFeColorMatrix.h +1 -1
  118. package/cpp/skia/modules/svg/include/SkSVGFeComposite.h +1 -1
  119. package/cpp/skia/modules/svg/include/SkSVGFeDisplacementMap.h +1 -1
  120. package/cpp/skia/modules/svg/include/SkSVGFeFlood.h +1 -1
  121. package/cpp/skia/modules/svg/include/SkSVGFeGaussianBlur.h +1 -1
  122. package/cpp/skia/modules/svg/include/SkSVGFeImage.h +1 -1
  123. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  124. package/cpp/skia/modules/svg/include/SkSVGFeLighting.h +1 -1
  125. package/cpp/skia/modules/svg/include/SkSVGFeOffset.h +1 -1
  126. package/cpp/skia/modules/svg/include/SkSVGFeTurbulence.h +1 -1
  127. package/cpp/skia/modules/svg/include/SkSVGFilter.h +1 -1
  128. package/cpp/skia/modules/svg/include/SkSVGG.h +1 -1
  129. package/cpp/skia/modules/svg/include/SkSVGGradient.h +1 -1
  130. package/cpp/skia/modules/svg/include/SkSVGHiddenContainer.h +1 -1
  131. package/cpp/skia/modules/svg/include/SkSVGImage.h +1 -1
  132. package/cpp/skia/modules/svg/include/SkSVGLine.h +1 -1
  133. package/cpp/skia/modules/svg/include/SkSVGLinearGradient.h +1 -1
  134. package/cpp/skia/modules/svg/include/SkSVGMask.h +1 -1
  135. package/cpp/skia/modules/svg/include/SkSVGNode.h +1 -1
  136. package/cpp/skia/modules/svg/include/SkSVGPath.h +1 -1
  137. package/cpp/skia/modules/svg/include/SkSVGPattern.h +1 -1
  138. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  139. package/cpp/skia/modules/svg/include/SkSVGRadialGradient.h +1 -1
  140. package/cpp/skia/modules/svg/include/SkSVGRect.h +1 -1
  141. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
  142. package/cpp/skia/modules/svg/include/SkSVGSVG.h +1 -1
  143. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -1
  144. package/cpp/skia/modules/svg/include/SkSVGStop.h +1 -1
  145. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  146. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +1 -1
  147. package/cpp/skia/modules/svg/include/SkSVGTypes.h +21 -21
  148. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  149. package/cpp/skia/modules/svg/include/SkSVGValue.h +2 -2
  150. package/cpp/skia/{include/private → src/core}/SkChecksum.h +32 -17
  151. package/cpp/skia/src/core/SkTHash.h +1 -1
  152. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +3 -1
  153. package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +3 -1
  154. package/libs/android/arm64-v8a/libskia.a +0 -0
  155. package/libs/android/arm64-v8a/libskottie.a +0 -0
  156. package/libs/android/arm64-v8a/libsksg.a +0 -0
  157. package/libs/android/arm64-v8a/libsvg.a +0 -0
  158. package/libs/android/armeabi-v7a/libskia.a +0 -0
  159. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  160. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  161. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  162. package/libs/android/x86/libskia.a +0 -0
  163. package/libs/android/x86/libskottie.a +0 -0
  164. package/libs/android/x86/libsksg.a +0 -0
  165. package/libs/android/x86/libsvg.a +0 -0
  166. package/libs/android/x86_64/libskia.a +0 -0
  167. package/libs/android/x86_64/libskottie.a +0 -0
  168. package/libs/android/x86_64/libsksg.a +0 -0
  169. package/libs/android/x86_64/libsvg.a +0 -0
  170. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  171. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  172. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  173. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  174. package/libs/ios/libsksg.xcframework/Info.plist +5 -5
  175. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  176. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  177. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  178. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  179. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  180. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  181. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  182. package/package.json +3 -4
  183. package/cpp/skia/include/effects/SkTableColorFilter.h +0 -29
  184. package/cpp/skia/include/private/SkOpts_spi.h +0 -23
  185. package/cpp/skia/include/private/SkSpinlock.h +0 -57
  186. package/cpp/skia/include/private/chromium/GrSlug.h +0 -16
  187. package/scripts/install-npm.js +0 -33
@@ -1,568 +1,10 @@
1
1
  /*
2
- * Copyright 2006 The Android Open Source Project
2
+ * Copyright 2023 Google LLC
3
3
  *
4
- * Use of this source code is governed by a BSD-style license that can be
5
- * found in the LICENSE file.
4
+ * Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
6
5
  */
7
6
 
8
- #ifndef SkPoint_DEFINED
9
- #define SkPoint_DEFINED
7
+ // SkPoint is part of the public API, but is also required by code in base. The following include
8
+ // forwarding allows SkPoint to participate in the API and for use by code in base.
10
9
 
11
- #include "include/core/SkScalar.h"
12
- #include "include/core/SkTypes.h"
13
- #include "include/private/base/SkSafe32.h"
14
-
15
- #include <cstdint>
16
-
17
- struct SkIPoint;
18
-
19
- /** SkIVector provides an alternative name for SkIPoint. SkIVector and SkIPoint
20
- can be used interchangeably for all purposes.
21
- */
22
- typedef SkIPoint SkIVector;
23
-
24
- /** \struct SkIPoint
25
- SkIPoint holds two 32-bit integer coordinates.
26
- */
27
- struct SkIPoint {
28
- int32_t fX; //!< x-axis value
29
- int32_t fY; //!< y-axis value
30
-
31
- /** Sets fX to x, fY to y.
32
-
33
- @param x integer x-axis value of constructed SkIPoint
34
- @param y integer y-axis value of constructed SkIPoint
35
- @return SkIPoint (x, y)
36
- */
37
- static constexpr SkIPoint Make(int32_t x, int32_t y) {
38
- return {x, y};
39
- }
40
-
41
- /** Returns x-axis value of SkIPoint.
42
-
43
- @return fX
44
- */
45
- constexpr int32_t x() const { return fX; }
46
-
47
- /** Returns y-axis value of SkIPoint.
48
-
49
- @return fY
50
- */
51
- constexpr int32_t y() const { return fY; }
52
-
53
- /** Returns true if fX and fY are both zero.
54
-
55
- @return true if fX is zero and fY is zero
56
- */
57
- bool isZero() const { return (fX | fY) == 0; }
58
-
59
- /** Sets fX to x and fY to y.
60
-
61
- @param x new value for fX
62
- @param y new value for fY
63
- */
64
- void set(int32_t x, int32_t y) {
65
- fX = x;
66
- fY = y;
67
- }
68
-
69
- /** Returns SkIPoint changing the signs of fX and fY.
70
-
71
- @return SkIPoint as (-fX, -fY)
72
- */
73
- SkIPoint operator-() const {
74
- return {-fX, -fY};
75
- }
76
-
77
- /** Offsets SkIPoint by ivector v. Sets SkIPoint to (fX + v.fX, fY + v.fY).
78
-
79
- @param v ivector to add
80
- */
81
- void operator+=(const SkIVector& v) {
82
- fX = Sk32_sat_add(fX, v.fX);
83
- fY = Sk32_sat_add(fY, v.fY);
84
- }
85
-
86
- /** Subtracts ivector v from SkIPoint. Sets SkIPoint to: (fX - v.fX, fY - v.fY).
87
-
88
- @param v ivector to subtract
89
- */
90
- void operator-=(const SkIVector& v) {
91
- fX = Sk32_sat_sub(fX, v.fX);
92
- fY = Sk32_sat_sub(fY, v.fY);
93
- }
94
-
95
- /** Returns true if SkIPoint is equivalent to SkIPoint constructed from (x, y).
96
-
97
- @param x value compared with fX
98
- @param y value compared with fY
99
- @return true if SkIPoint equals (x, y)
100
- */
101
- bool equals(int32_t x, int32_t y) const {
102
- return fX == x && fY == y;
103
- }
104
-
105
- /** Returns true if a is equivalent to b.
106
-
107
- @param a SkIPoint to compare
108
- @param b SkIPoint to compare
109
- @return true if a.fX == b.fX and a.fY == b.fY
110
- */
111
- friend bool operator==(const SkIPoint& a, const SkIPoint& b) {
112
- return a.fX == b.fX && a.fY == b.fY;
113
- }
114
-
115
- /** Returns true if a is not equivalent to b.
116
-
117
- @param a SkIPoint to compare
118
- @param b SkIPoint to compare
119
- @return true if a.fX != b.fX or a.fY != b.fY
120
- */
121
- friend bool operator!=(const SkIPoint& a, const SkIPoint& b) {
122
- return a.fX != b.fX || a.fY != b.fY;
123
- }
124
-
125
- /** Returns ivector from b to a; computed as (a.fX - b.fX, a.fY - b.fY).
126
-
127
- Can also be used to subtract ivector from ivector, returning ivector.
128
-
129
- @param a SkIPoint or ivector to subtract from
130
- @param b ivector to subtract
131
- @return ivector from b to a
132
- */
133
- friend SkIVector operator-(const SkIPoint& a, const SkIPoint& b) {
134
- return { Sk32_sat_sub(a.fX, b.fX), Sk32_sat_sub(a.fY, b.fY) };
135
- }
136
-
137
- /** Returns SkIPoint resulting from SkIPoint a offset by ivector b, computed as:
138
- (a.fX + b.fX, a.fY + b.fY).
139
-
140
- Can also be used to offset SkIPoint b by ivector a, returning SkIPoint.
141
- Can also be used to add ivector to ivector, returning ivector.
142
-
143
- @param a SkIPoint or ivector to add to
144
- @param b SkIPoint or ivector to add
145
- @return SkIPoint equal to a offset by b
146
- */
147
- friend SkIPoint operator+(const SkIPoint& a, const SkIVector& b) {
148
- return { Sk32_sat_add(a.fX, b.fX), Sk32_sat_add(a.fY, b.fY) };
149
- }
150
- };
151
-
152
- struct SkPoint;
153
-
154
- /** SkVector provides an alternative name for SkPoint. SkVector and SkPoint can
155
- be used interchangeably for all purposes.
156
- */
157
- typedef SkPoint SkVector;
158
-
159
- /** \struct SkPoint
160
- SkPoint holds two 32-bit floating point coordinates.
161
- */
162
- struct SK_API SkPoint {
163
- SkScalar fX; //!< x-axis value
164
- SkScalar fY; //!< y-axis value
165
-
166
- /** Sets fX to x, fY to y. Used both to set SkPoint and vector.
167
-
168
- @param x SkScalar x-axis value of constructed SkPoint or vector
169
- @param y SkScalar y-axis value of constructed SkPoint or vector
170
- @return SkPoint (x, y)
171
- */
172
- static constexpr SkPoint Make(SkScalar x, SkScalar y) {
173
- return {x, y};
174
- }
175
-
176
- /** Returns x-axis value of SkPoint or vector.
177
-
178
- @return fX
179
- */
180
- constexpr SkScalar x() const { return fX; }
181
-
182
- /** Returns y-axis value of SkPoint or vector.
183
-
184
- @return fY
185
- */
186
- constexpr SkScalar y() const { return fY; }
187
-
188
- /** Returns true if fX and fY are both zero.
189
-
190
- @return true if fX is zero and fY is zero
191
- */
192
- bool isZero() const { return (0 == fX) & (0 == fY); }
193
-
194
- /** Sets fX to x and fY to y.
195
-
196
- @param x new value for fX
197
- @param y new value for fY
198
- */
199
- void set(SkScalar x, SkScalar y) {
200
- fX = x;
201
- fY = y;
202
- }
203
-
204
- /** Sets fX to x and fY to y, promoting integers to SkScalar values.
205
-
206
- Assigning a large integer value directly to fX or fY may cause a compiler
207
- error, triggered by narrowing conversion of int to SkScalar. This safely
208
- casts x and y to avoid the error.
209
-
210
- @param x new value for fX
211
- @param y new value for fY
212
- */
213
- void iset(int32_t x, int32_t y) {
214
- fX = SkIntToScalar(x);
215
- fY = SkIntToScalar(y);
216
- }
217
-
218
- /** Sets fX to p.fX and fY to p.fY, promoting integers to SkScalar values.
219
-
220
- Assigning an SkIPoint containing a large integer value directly to fX or fY may
221
- cause a compiler error, triggered by narrowing conversion of int to SkScalar.
222
- This safely casts p.fX and p.fY to avoid the error.
223
-
224
- @param p SkIPoint members promoted to SkScalar
225
- */
226
- void iset(const SkIPoint& p) {
227
- fX = SkIntToScalar(p.fX);
228
- fY = SkIntToScalar(p.fY);
229
- }
230
-
231
- /** Sets fX to absolute value of pt.fX; and fY to absolute value of pt.fY.
232
-
233
- @param pt members providing magnitude for fX and fY
234
- */
235
- void setAbs(const SkPoint& pt) {
236
- fX = SkScalarAbs(pt.fX);
237
- fY = SkScalarAbs(pt.fY);
238
- }
239
-
240
- /** Adds offset to each SkPoint in points array with count entries.
241
-
242
- @param points SkPoint array
243
- @param count entries in array
244
- @param offset vector added to points
245
- */
246
- static void Offset(SkPoint points[], int count, const SkVector& offset) {
247
- Offset(points, count, offset.fX, offset.fY);
248
- }
249
-
250
- /** Adds offset (dx, dy) to each SkPoint in points array of length count.
251
-
252
- @param points SkPoint array
253
- @param count entries in array
254
- @param dx added to fX in points
255
- @param dy added to fY in points
256
- */
257
- static void Offset(SkPoint points[], int count, SkScalar dx, SkScalar dy) {
258
- for (int i = 0; i < count; ++i) {
259
- points[i].offset(dx, dy);
260
- }
261
- }
262
-
263
- /** Adds offset (dx, dy) to SkPoint.
264
-
265
- @param dx added to fX
266
- @param dy added to fY
267
- */
268
- void offset(SkScalar dx, SkScalar dy) {
269
- fX += dx;
270
- fY += dy;
271
- }
272
-
273
- /** Returns the Euclidean distance from origin, computed as:
274
-
275
- sqrt(fX * fX + fY * fY)
276
-
277
- .
278
-
279
- @return straight-line distance to origin
280
- */
281
- SkScalar length() const { return SkPoint::Length(fX, fY); }
282
-
283
- /** Returns the Euclidean distance from origin, computed as:
284
-
285
- sqrt(fX * fX + fY * fY)
286
-
287
- .
288
-
289
- @return straight-line distance to origin
290
- */
291
- SkScalar distanceToOrigin() const { return this->length(); }
292
-
293
- /** Scales (fX, fY) so that length() returns one, while preserving ratio of fX to fY,
294
- if possible. If prior length is nearly zero, sets vector to (0, 0) and returns
295
- false; otherwise returns true.
296
-
297
- @return true if former length is not zero or nearly zero
298
-
299
- example: https://fiddle.skia.org/c/@Point_normalize_2
300
- */
301
- bool normalize();
302
-
303
- /** Sets vector to (x, y) scaled so length() returns one, and so that
304
- (fX, fY) is proportional to (x, y). If (x, y) length is nearly zero,
305
- sets vector to (0, 0) and returns false; otherwise returns true.
306
-
307
- @param x proportional value for fX
308
- @param y proportional value for fY
309
- @return true if (x, y) length is not zero or nearly zero
310
-
311
- example: https://fiddle.skia.org/c/@Point_setNormalize
312
- */
313
- bool setNormalize(SkScalar x, SkScalar y);
314
-
315
- /** Scales vector so that distanceToOrigin() returns length, if possible. If former
316
- length is nearly zero, sets vector to (0, 0) and return false; otherwise returns
317
- true.
318
-
319
- @param length straight-line distance to origin
320
- @return true if former length is not zero or nearly zero
321
-
322
- example: https://fiddle.skia.org/c/@Point_setLength
323
- */
324
- bool setLength(SkScalar length);
325
-
326
- /** Sets vector to (x, y) scaled to length, if possible. If former
327
- length is nearly zero, sets vector to (0, 0) and return false; otherwise returns
328
- true.
329
-
330
- @param x proportional value for fX
331
- @param y proportional value for fY
332
- @param length straight-line distance to origin
333
- @return true if (x, y) length is not zero or nearly zero
334
-
335
- example: https://fiddle.skia.org/c/@Point_setLength_2
336
- */
337
- bool setLength(SkScalar x, SkScalar y, SkScalar length);
338
-
339
- /** Sets dst to SkPoint times scale. dst may be SkPoint to modify SkPoint in place.
340
-
341
- @param scale factor to multiply SkPoint by
342
- @param dst storage for scaled SkPoint
343
-
344
- example: https://fiddle.skia.org/c/@Point_scale
345
- */
346
- void scale(SkScalar scale, SkPoint* dst) const;
347
-
348
- /** Scales SkPoint in place by scale.
349
-
350
- @param value factor to multiply SkPoint by
351
- */
352
- void scale(SkScalar value) { this->scale(value, this); }
353
-
354
- /** Changes the sign of fX and fY.
355
- */
356
- void negate() {
357
- fX = -fX;
358
- fY = -fY;
359
- }
360
-
361
- /** Returns SkPoint changing the signs of fX and fY.
362
-
363
- @return SkPoint as (-fX, -fY)
364
- */
365
- SkPoint operator-() const {
366
- return {-fX, -fY};
367
- }
368
-
369
- /** Adds vector v to SkPoint. Sets SkPoint to: (fX + v.fX, fY + v.fY).
370
-
371
- @param v vector to add
372
- */
373
- void operator+=(const SkVector& v) {
374
- fX += v.fX;
375
- fY += v.fY;
376
- }
377
-
378
- /** Subtracts vector v from SkPoint. Sets SkPoint to: (fX - v.fX, fY - v.fY).
379
-
380
- @param v vector to subtract
381
- */
382
- void operator-=(const SkVector& v) {
383
- fX -= v.fX;
384
- fY -= v.fY;
385
- }
386
-
387
- /** Returns SkPoint multiplied by scale.
388
-
389
- @param scale scalar to multiply by
390
- @return SkPoint as (fX * scale, fY * scale)
391
- */
392
- SkPoint operator*(SkScalar scale) const {
393
- return {fX * scale, fY * scale};
394
- }
395
-
396
- /** Multiplies SkPoint by scale. Sets SkPoint to: (fX * scale, fY * scale).
397
-
398
- @param scale scalar to multiply by
399
- @return reference to SkPoint
400
- */
401
- SkPoint& operator*=(SkScalar scale) {
402
- fX *= scale;
403
- fY *= scale;
404
- return *this;
405
- }
406
-
407
- /** Returns true if both fX and fY are measurable values.
408
-
409
- @return true for values other than infinities and NaN
410
- */
411
- bool isFinite() const {
412
- SkScalar accum = 0;
413
- accum *= fX;
414
- accum *= fY;
415
-
416
- // accum is either NaN or it is finite (zero).
417
- SkASSERT(0 == accum || SkScalarIsNaN(accum));
418
-
419
- // value==value will be true iff value is not NaN
420
- // TODO: is it faster to say !accum or accum==accum?
421
- return !SkScalarIsNaN(accum);
422
- }
423
-
424
- /** Returns true if SkPoint is equivalent to SkPoint constructed from (x, y).
425
-
426
- @param x value compared with fX
427
- @param y value compared with fY
428
- @return true if SkPoint equals (x, y)
429
- */
430
- bool equals(SkScalar x, SkScalar y) const {
431
- return fX == x && fY == y;
432
- }
433
-
434
- /** Returns true if a is equivalent to b.
435
-
436
- @param a SkPoint to compare
437
- @param b SkPoint to compare
438
- @return true if a.fX == b.fX and a.fY == b.fY
439
- */
440
- friend bool operator==(const SkPoint& a, const SkPoint& b) {
441
- return a.fX == b.fX && a.fY == b.fY;
442
- }
443
-
444
- /** Returns true if a is not equivalent to b.
445
-
446
- @param a SkPoint to compare
447
- @param b SkPoint to compare
448
- @return true if a.fX != b.fX or a.fY != b.fY
449
- */
450
- friend bool operator!=(const SkPoint& a, const SkPoint& b) {
451
- return a.fX != b.fX || a.fY != b.fY;
452
- }
453
-
454
- /** Returns vector from b to a, computed as (a.fX - b.fX, a.fY - b.fY).
455
-
456
- Can also be used to subtract vector from SkPoint, returning SkPoint.
457
- Can also be used to subtract vector from vector, returning vector.
458
-
459
- @param a SkPoint to subtract from
460
- @param b SkPoint to subtract
461
- @return vector from b to a
462
- */
463
- friend SkVector operator-(const SkPoint& a, const SkPoint& b) {
464
- return {a.fX - b.fX, a.fY - b.fY};
465
- }
466
-
467
- /** Returns SkPoint resulting from SkPoint a offset by vector b, computed as:
468
- (a.fX + b.fX, a.fY + b.fY).
469
-
470
- Can also be used to offset SkPoint b by vector a, returning SkPoint.
471
- Can also be used to add vector to vector, returning vector.
472
-
473
- @param a SkPoint or vector to add to
474
- @param b SkPoint or vector to add
475
- @return SkPoint equal to a offset by b
476
- */
477
- friend SkPoint operator+(const SkPoint& a, const SkVector& b) {
478
- return {a.fX + b.fX, a.fY + b.fY};
479
- }
480
-
481
- /** Returns the Euclidean distance from origin, computed as:
482
-
483
- sqrt(x * x + y * y)
484
-
485
- .
486
-
487
- @param x component of length
488
- @param y component of length
489
- @return straight-line distance to origin
490
-
491
- example: https://fiddle.skia.org/c/@Point_Length
492
- */
493
- static SkScalar Length(SkScalar x, SkScalar y);
494
-
495
- /** Scales (vec->fX, vec->fY) so that length() returns one, while preserving ratio of vec->fX
496
- to vec->fY, if possible. If original length is nearly zero, sets vec to (0, 0) and returns
497
- zero; otherwise, returns length of vec before vec is scaled.
498
-
499
- Returned prior length may be SK_ScalarInfinity if it can not be represented by SkScalar.
500
-
501
- Note that normalize() is faster if prior length is not required.
502
-
503
- @param vec normalized to unit length
504
- @return original vec length
505
-
506
- example: https://fiddle.skia.org/c/@Point_Normalize
507
- */
508
- static SkScalar Normalize(SkVector* vec);
509
-
510
- /** Returns the Euclidean distance between a and b.
511
-
512
- @param a line end point
513
- @param b line end point
514
- @return straight-line distance from a to b
515
- */
516
- static SkScalar Distance(const SkPoint& a, const SkPoint& b) {
517
- return Length(a.fX - b.fX, a.fY - b.fY);
518
- }
519
-
520
- /** Returns the dot product of vector a and vector b.
521
-
522
- @param a left side of dot product
523
- @param b right side of dot product
524
- @return product of input magnitudes and cosine of the angle between them
525
- */
526
- static SkScalar DotProduct(const SkVector& a, const SkVector& b) {
527
- return a.fX * b.fX + a.fY * b.fY;
528
- }
529
-
530
- /** Returns the cross product of vector a and vector b.
531
-
532
- a and b form three-dimensional vectors with z-axis value equal to zero. The
533
- cross product is a three-dimensional vector with x-axis and y-axis values equal
534
- to zero. The cross product z-axis component is returned.
535
-
536
- @param a left side of cross product
537
- @param b right side of cross product
538
- @return area spanned by vectors signed by angle direction
539
- */
540
- static SkScalar CrossProduct(const SkVector& a, const SkVector& b) {
541
- return a.fX * b.fY - a.fY * b.fX;
542
- }
543
-
544
- /** Returns the cross product of vector and vec.
545
-
546
- Vector and vec form three-dimensional vectors with z-axis value equal to zero.
547
- The cross product is a three-dimensional vector with x-axis and y-axis values
548
- equal to zero. The cross product z-axis component is returned.
549
-
550
- @param vec right side of cross product
551
- @return area spanned by vectors signed by angle direction
552
- */
553
- SkScalar cross(const SkVector& vec) const {
554
- return CrossProduct(*this, vec);
555
- }
556
-
557
- /** Returns the dot product of vector and vector vec.
558
-
559
- @param vec right side of dot product
560
- @return product of input magnitudes and cosine of the angle between them
561
- */
562
- SkScalar dot(const SkVector& vec) const {
563
- return DotProduct(*this, vec);
564
- }
565
-
566
- };
567
-
568
- #endif
10
+ #include "include/private/base/SkPoint_impl.h" // IWYU pragma: export
@@ -9,6 +9,7 @@
9
9
  #define SkPoint3_DEFINED
10
10
 
11
11
  #include "include/core/SkPoint.h"
12
+ #include "include/core/SkScalar.h"
12
13
 
13
14
  struct SK_API SkPoint3 {
14
15
  SkScalar fX, fY, fZ;
@@ -10,37 +10,11 @@
10
10
 
11
11
  #include "include/core/SkTypes.h"
12
12
 
13
+ // TODO(kjlubick) remove this shim header after clients are migrated
13
14
  #if defined(SK_GANESH)
14
- #include "include/core/SkRefCnt.h"
15
- #include "include/gpu/GrBackendSurface.h"
16
- /**
17
- * This type is used to fulfill textures for PromiseImages. Once an instance is returned from a
18
- * PromiseImageTextureFulfillProc the GrBackendTexture it wraps must remain valid until the
19
- * corresponding PromiseImageTextureReleaseProc is called.
20
- */
21
- class SK_API SkPromiseImageTexture : public SkNVRefCnt<SkPromiseImageTexture> {
22
- public:
23
- SkPromiseImageTexture() = delete;
24
- SkPromiseImageTexture(const SkPromiseImageTexture&) = delete;
25
- SkPromiseImageTexture(SkPromiseImageTexture&&) = delete;
26
- ~SkPromiseImageTexture();
27
- SkPromiseImageTexture& operator=(const SkPromiseImageTexture&) = delete;
28
- SkPromiseImageTexture& operator=(SkPromiseImageTexture&&) = delete;
29
-
30
- static sk_sp<SkPromiseImageTexture> Make(const GrBackendTexture& backendTexture) {
31
- if (!backendTexture.isValid()) {
32
- return nullptr;
33
- }
34
- return sk_sp<SkPromiseImageTexture>(new SkPromiseImageTexture(backendTexture));
35
- }
36
-
37
- GrBackendTexture backendTexture() const { return fBackendTexture; }
38
-
39
- private:
40
- explicit SkPromiseImageTexture(const GrBackendTexture& backendTexture);
15
+ #include "include/private/chromium/GrPromiseImageTexture.h"
41
16
 
42
- GrBackendTexture fBackendTexture;
43
- };
44
- #endif // defined(SK_GANESH)
17
+ typedef GrPromiseImageTexture SkPromiseImageTexture;
18
+ #endif
45
19
 
46
20
  #endif // SkPromiseImageTexture_DEFINED
@@ -29,10 +29,10 @@ struct SkRect;
29
29
  its top, it is considered empty.
30
30
  */
31
31
  struct SK_API SkIRect {
32
- int32_t fLeft; //!< smaller x-axis bounds
33
- int32_t fTop; //!< smaller y-axis bounds
34
- int32_t fRight; //!< larger x-axis bounds
35
- int32_t fBottom; //!< larger y-axis bounds
32
+ int32_t fLeft = 0; //!< smaller x-axis bounds
33
+ int32_t fTop = 0; //!< smaller y-axis bounds
34
+ int32_t fRight = 0; //!< larger x-axis bounds
35
+ int32_t fBottom = 0; //!< larger y-axis bounds
36
36
 
37
37
  /** Returns constructed SkIRect set to (0, 0, 0, 0).
38
38
  Many other rectangles are empty; if left is equal to or greater than right,
@@ -581,10 +581,10 @@ struct SK_API SkIRect {
581
581
  its top, it is considered empty.
582
582
  */
583
583
  struct SK_API SkRect {
584
- SkScalar fLeft; //!< smaller x-axis bounds
585
- SkScalar fTop; //!< smaller y-axis bounds
586
- SkScalar fRight; //!< larger x-axis bounds
587
- SkScalar fBottom; //!< larger y-axis bounds
584
+ SkScalar fLeft = 0; //!< smaller x-axis bounds
585
+ SkScalar fTop = 0; //!< smaller y-axis bounds
586
+ SkScalar fRight = 0; //!< larger x-axis bounds
587
+ SkScalar fBottom = 0; //!< larger y-axis bounds
588
588
 
589
589
  /** Returns constructed SkRect set to (0, 0, 0, 0).
590
590
  Many other rectangles are empty; if left is equal to or greater than right,
@@ -74,11 +74,13 @@ struct SK_API SkSamplingOptions {
74
74
  : filter(fm)
75
75
  , mipmap(mm) {}
76
76
 
77
- explicit constexpr SkSamplingOptions(SkFilterMode fm)
77
+ // These are intentionally implicit because the single parameter clearly conveys what the
78
+ // implicitly created SkSamplingOptions will be.
79
+ constexpr SkSamplingOptions(SkFilterMode fm)
78
80
  : filter(fm)
79
81
  , mipmap(SkMipmapMode::kNone) {}
80
82
 
81
- explicit constexpr SkSamplingOptions(const SkCubicResampler& c)
83
+ constexpr SkSamplingOptions(const SkCubicResampler& c)
82
84
  : useCubic(true)
83
85
  , cubic(c) {}
84
86
 
@@ -82,7 +82,7 @@ static inline SkScalar SkScalarFraction(SkScalar x) {
82
82
 
83
83
  static inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
84
84
 
85
- #define SkScalarInvert(x) sk_ieee_float_divide_TODO_IS_DIVIDE_BY_ZERO_SAFE_HERE(SK_Scalar1, (x))
85
+ #define SkScalarInvert(x) (SK_Scalar1 / (x))
86
86
  #define SkScalarAve(a, b) (((a) + (b)) * SK_ScalarHalf)
87
87
  #define SkScalarHalf(a) ((a) * SK_ScalarHalf)
88
88
 
@@ -75,7 +75,11 @@ struct SK_API SkDeserialProcs {
75
75
 
76
76
  SkDeserialTypefaceProc fTypefaceProc = nullptr;
77
77
  void* fTypefaceCtx = nullptr;
78
+
79
+ // This looks like a flag, but it could be considered a proc as well (one that takes no
80
+ // parameters and returns a bool). Given that there are only two valid implementations of that
81
+ // proc, we just insert the bool directly.
82
+ bool fAllowSkSL = true;
78
83
  };
79
84
 
80
85
  #endif
81
-