@shopify/react-native-skia 0.1.129 → 0.1.130

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +1 -0
  2. package/cpp/api/JsiSkRuntimeEffect.h +7 -9
  3. package/cpp/api/JsiSkVertices.h +0 -2
  4. package/cpp/rnskia/values/RNSkValue.h +1 -1
  5. package/cpp/skia/include/codec/SkCodec.h +7 -1
  6. package/cpp/skia/include/core/SkAlphaType.h +45 -0
  7. package/cpp/skia/include/core/SkBitmap.h +4 -2
  8. package/cpp/skia/include/core/SkCanvas.h +31 -20
  9. package/cpp/skia/include/core/SkColor.h +1 -1
  10. package/cpp/skia/include/core/SkColorFilter.h +1 -0
  11. package/cpp/skia/include/core/SkColorType.h +66 -0
  12. package/cpp/skia/include/core/SkDeferredDisplayListRecorder.h +1 -1
  13. package/cpp/skia/include/core/SkDrawable.h +7 -0
  14. package/cpp/skia/include/core/SkEncodedImageFormat.h +1 -0
  15. package/cpp/skia/include/core/SkFont.h +4 -3
  16. package/cpp/skia/include/core/SkFontArguments.h +33 -1
  17. package/cpp/skia/include/core/SkGraphics.h +13 -0
  18. package/cpp/skia/include/core/SkImage.h +67 -22
  19. package/cpp/skia/include/core/SkImageEncoder.h +0 -3
  20. package/cpp/skia/include/core/SkImageGenerator.h +4 -3
  21. package/cpp/skia/include/core/SkImageInfo.h +35 -142
  22. package/cpp/skia/include/core/SkMesh.h +303 -0
  23. package/cpp/skia/include/core/SkMilestone.h +1 -1
  24. package/cpp/skia/include/core/SkOpenTypeSVGDecoder.h +30 -0
  25. package/cpp/skia/include/core/SkPaint.h +4 -19
  26. package/cpp/skia/include/core/SkPath.h +20 -33
  27. package/cpp/skia/include/core/SkPathBuilder.h +1 -6
  28. package/cpp/skia/include/core/SkPixelRef.h +1 -1
  29. package/cpp/skia/include/core/SkPixmap.h +3 -2
  30. package/cpp/skia/include/core/SkRSXform.h +1 -1
  31. package/cpp/skia/include/core/SkSamplingOptions.h +16 -5
  32. package/cpp/skia/include/core/SkSpan.h +5 -5
  33. package/cpp/skia/include/core/SkString.h +5 -8
  34. package/cpp/skia/include/core/SkSurface.h +21 -0
  35. package/cpp/skia/include/core/SkTypeface.h +20 -4
  36. package/cpp/skia/include/core/SkTypes.h +9 -5
  37. package/cpp/skia/include/effects/SkGradientShader.h +9 -18
  38. package/cpp/skia/include/effects/SkRuntimeEffect.h +16 -12
  39. package/cpp/skia/include/gpu/GpuTypes.h +32 -0
  40. package/cpp/skia/include/gpu/GrBackendSemaphore.h +1 -1
  41. package/cpp/skia/include/gpu/GrBackendSurface.h +6 -5
  42. package/cpp/skia/include/gpu/GrBackendSurfaceMutableState.h +1 -1
  43. package/cpp/skia/include/gpu/GrContextOptions.h +11 -20
  44. package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +7 -0
  45. package/cpp/skia/include/gpu/GrDirectContext.h +16 -11
  46. package/cpp/skia/include/gpu/GrDriverBugWorkaroundsAutogen.h +0 -2
  47. package/cpp/skia/include/gpu/GrRecordingContext.h +14 -7
  48. package/cpp/skia/include/gpu/GrSurfaceInfo.h +6 -6
  49. package/cpp/skia/include/gpu/dawn/GrDawnTypes.h +1 -1
  50. package/cpp/skia/include/gpu/gl/GrGLFunctions.h +3 -1
  51. package/cpp/skia/include/gpu/gl/GrGLInterface.h +2 -2
  52. package/cpp/skia/include/gpu/graphite/BackendTexture.h +64 -0
  53. package/cpp/skia/include/gpu/graphite/Context.h +124 -0
  54. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +71 -0
  55. package/cpp/skia/include/gpu/graphite/Recorder.h +104 -0
  56. package/cpp/skia/include/gpu/graphite/Recording.h +39 -0
  57. package/cpp/skia/include/gpu/graphite/SkStuff.h +47 -0
  58. package/cpp/skia/include/gpu/graphite/TextureInfo.h +91 -0
  59. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +24 -0
  60. package/cpp/skia/include/gpu/graphite/mtl/MtlTypes.h +68 -0
  61. package/cpp/skia/include/gpu/mock/GrMockTypes.h +1 -2
  62. package/cpp/skia/include/ports/SkCFObject.h +0 -4
  63. package/cpp/skia/include/ports/SkTypeface_win.h +2 -2
  64. package/cpp/skia/include/private/{GrSingleOwner.h → SingleOwner.h} +17 -10
  65. package/cpp/skia/include/private/SkChecksum.h +11 -0
  66. package/cpp/skia/include/private/SkEncodedInfo.h +22 -5
  67. package/cpp/skia/include/private/SkFloatingPoint.h +0 -53
  68. package/cpp/skia/include/private/SkImageInfoPriv.h +8 -2
  69. package/cpp/skia/include/private/SkMacros.h +13 -18
  70. package/cpp/skia/include/private/SkMutex.h +8 -0
  71. package/cpp/skia/include/private/SkPathRef.h +2 -16
  72. package/cpp/skia/include/private/SkSLDefines.h +9 -1
  73. package/cpp/skia/include/private/SkSLIRNode.h +6 -5
  74. package/cpp/skia/include/private/SkSLLayout.h +11 -10
  75. package/cpp/skia/include/private/SkSLModifiers.h +4 -3
  76. package/cpp/skia/include/private/SkSLProgramElement.h +2 -2
  77. package/cpp/skia/include/private/SkSLProgramKind.h +8 -5
  78. package/cpp/skia/include/private/SkSLStatement.h +2 -3
  79. package/cpp/skia/include/private/SkSLString.h +17 -56
  80. package/cpp/skia/include/private/SkSLSymbol.h +4 -4
  81. package/cpp/skia/include/private/SkShadowFlags.h +3 -1
  82. package/cpp/skia/include/private/SkStringView.h +47 -0
  83. package/cpp/skia/include/private/SkTArray.h +4 -3
  84. package/cpp/skia/include/private/SkTHash.h +66 -24
  85. package/cpp/skia/include/private/SkTLogic.h +2 -32
  86. package/cpp/skia/include/private/SkTemplates.h +2 -2
  87. package/cpp/skia/include/private/SkThreadAnnotations.h +4 -4
  88. package/cpp/skia/include/private/SkVx.h +28 -28
  89. package/cpp/skia/include/private/chromium/GrSlug.h +40 -3
  90. package/cpp/skia/include/private/chromium/SkChromeRemoteGlyphCache.h +12 -6
  91. package/cpp/skia/include/private/{GrContext_Base.h → gpu/ganesh/GrContext_Base.h} +7 -0
  92. package/cpp/skia/include/private/{GrD3DTypesMinimal.h → gpu/ganesh/GrD3DTypesMinimal.h} +0 -0
  93. package/cpp/skia/include/private/{GrDawnTypesPriv.h → gpu/ganesh/GrDawnTypesPriv.h} +0 -0
  94. package/cpp/skia/include/private/{GrGLTypesPriv.h → gpu/ganesh/GrGLTypesPriv.h} +1 -0
  95. package/cpp/skia/include/private/{GrImageContext.h → gpu/ganesh/GrImageContext.h} +4 -4
  96. package/cpp/skia/include/private/{GrMockTypesPriv.h → gpu/ganesh/GrMockTypesPriv.h} +0 -0
  97. package/cpp/skia/include/private/{GrMtlTypesPriv.h → gpu/ganesh/GrMtlTypesPriv.h} +0 -0
  98. package/cpp/skia/include/private/{GrTypesPriv.h → gpu/ganesh/GrTypesPriv.h} +25 -367
  99. package/cpp/skia/include/private/{GrVkTypesPriv.h → gpu/ganesh/GrVkTypesPriv.h} +0 -0
  100. package/cpp/skia/include/private/gpu/graphite/MtlTypesPriv.h +74 -0
  101. package/cpp/skia/include/sksl/DSL.h +4 -0
  102. package/cpp/skia/include/sksl/DSLBlock.h +8 -3
  103. package/cpp/skia/include/sksl/DSLCase.h +6 -6
  104. package/cpp/skia/include/sksl/DSLCore.h +89 -78
  105. package/cpp/skia/include/sksl/DSLExpression.h +78 -45
  106. package/cpp/skia/include/sksl/DSLFunction.h +23 -18
  107. package/cpp/skia/include/sksl/DSLLayout.h +14 -16
  108. package/cpp/skia/include/sksl/DSLModifiers.h +7 -5
  109. package/cpp/skia/include/sksl/DSLRuntimeEffects.h +1 -1
  110. package/cpp/skia/include/sksl/DSLStatement.h +16 -10
  111. package/cpp/skia/include/sksl/DSLSymbols.h +7 -7
  112. package/cpp/skia/include/sksl/DSLType.h +27 -23
  113. package/cpp/skia/include/sksl/DSLVar.h +72 -61
  114. package/cpp/skia/include/sksl/SkSLErrorReporter.h +12 -49
  115. package/cpp/skia/include/sksl/SkSLOperator.h +151 -0
  116. package/cpp/skia/include/sksl/SkSLPosition.h +102 -0
  117. package/cpp/skia/include/svg/SkSVGCanvas.h +5 -1
  118. package/cpp/skia/include/utils/SkAnimCodecPlayer.h +7 -0
  119. package/cpp/skia/include/utils/SkCamera.h +2 -0
  120. package/cpp/skia/include/utils/SkCanvasStateUtils.h +4 -1
  121. package/cpp/skia/include/utils/SkCustomTypeface.h +6 -4
  122. package/cpp/skia/include/utils/SkNWayCanvas.h +34 -0
  123. package/cpp/skia/include/utils/SkNullCanvas.h +5 -1
  124. package/cpp/skia/include/utils/SkOrderedFontMgr.h +12 -0
  125. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +30 -1
  126. package/cpp/skia/include/utils/SkParse.h +2 -0
  127. package/cpp/skia/include/utils/SkShadowUtils.h +3 -2
  128. package/cpp/skia/include/utils/SkTextUtils.h +8 -4
  129. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +27 -1
  130. package/cpp/skia/modules/svg/include/SkSVGDOM.h +4 -0
  131. package/cpp/skia/modules/svg/include/SkSVGOpenTypeSVGDecoder.h +32 -0
  132. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +3 -3
  133. package/cpp/skia/modules/svg/include/SkSVGSVG.h +2 -0
  134. package/cpp/skia/modules/svg/include/SkSVGTypes.h +48 -9
  135. package/ios/RNSkia-iOS/PlatformContext.h +1 -1
  136. package/ios/RNSkia-iOS/RNSkDrawViewImpl.mm +1 -0
  137. package/ios/RNSkia-iOS/SkiaDrawView.mm +1 -1
  138. package/lib/commonjs/renderer/components/shaders/Shader.js +1 -2
  139. package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
  140. package/lib/module/renderer/components/shaders/Shader.js +1 -2
  141. package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
  142. package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +0 -1
  143. package/lib/typescript/src/skia/types/RuntimeEffect/RuntimeEffect.d.ts +2 -4
  144. package/libs/android/arm64-v8a/libskia.a +0 -0
  145. package/libs/android/arm64-v8a/libsvg.a +0 -0
  146. package/libs/android/armeabi-v7a/libskia.a +0 -0
  147. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  148. package/libs/android/x86/libskia.a +0 -0
  149. package/libs/android/x86/libsvg.a +0 -0
  150. package/libs/android/x86_64/libskia.a +0 -0
  151. package/libs/android/x86_64/libsvg.a +0 -0
  152. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  153. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  154. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  155. package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
  156. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  157. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  158. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  159. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  160. package/package.json +2 -2
  161. package/src/renderer/components/shaders/Shader.tsx +1 -3
  162. package/src/skia/types/RuntimeEffect/RuntimeEffect.ts +1 -8
  163. package/cpp/skia/include/core/SkCustomMesh.h +0 -202
  164. package/cpp/skia/include/core/SkStringView.h +0 -185
  165. package/cpp/skia/include/private/SkPaintParamsKey.h +0 -110
  166. package/cpp/skia/include/private/SkShaderCodeDictionary.h +0 -63
  167. package/cpp/skia/include/private/SkTOptional.h +0 -362
@@ -8,41 +8,52 @@
8
8
  #ifndef SkImage_DEFINED
9
9
  #define SkImage_DEFINED
10
10
 
11
- #include "include/core/SkImageEncoder.h"
12
11
  #include "include/core/SkImageInfo.h"
13
12
  #include "include/core/SkRefCnt.h"
14
13
  #include "include/core/SkSamplingOptions.h"
15
14
  #include "include/core/SkScalar.h"
16
15
  #include "include/core/SkShader.h"
17
16
  #include "include/core/SkTileMode.h"
18
- #include "include/private/SkTOptional.h"
19
17
  #if SK_SUPPORT_GPU
20
18
  #include "include/gpu/GrTypes.h"
21
19
  #endif
20
+ #if SK_GRAPHITE_ENABLED
21
+ #include "include/gpu/graphite/GraphiteTypes.h"
22
+ #endif
22
23
  #include <functional> // std::function
24
+ #include <optional>
23
25
 
24
26
  #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
25
27
  #include <android/hardware_buffer.h>
26
28
  #endif
27
29
 
28
- class SkData;
30
+ class GrBackendFormat;
31
+ class GrBackendTexture;
32
+ class GrContextThreadSafeProxy;
33
+ class GrDirectContext;
34
+ class GrRecordingContext;
35
+ class GrYUVABackendTextureInfo;
36
+ class GrYUVABackendTextures;
29
37
  class SkCanvas;
38
+ class SkData;
30
39
  class SkImage;
31
40
  class SkImageFilter;
32
41
  class SkImageGenerator;
33
42
  class SkMipmap;
34
43
  class SkPaint;
35
44
  class SkPicture;
45
+ class SkPixmap;
36
46
  class SkPromiseImageTexture;
37
47
  class SkSurface;
38
48
  class SkYUVAPixmaps;
39
- class GrBackendFormat;
40
- class GrBackendTexture;
41
- class GrDirectContext;
42
- class GrRecordingContext;
43
- class GrContextThreadSafeProxy;
44
- class GrYUVABackendTextureInfo;
45
- class GrYUVABackendTextures;
49
+
50
+ enum class SkEncodedImageFormat;
51
+
52
+ #if SK_GRAPHITE_ENABLED
53
+ namespace skgpu::graphite {
54
+ class Recorder;
55
+ };
56
+ #endif
46
57
 
47
58
  /** \class SkImage
48
59
  SkImage describes a two dimensional array of pixels to draw. The pixels may be
@@ -184,7 +195,7 @@ public:
184
195
  example: https://fiddle.skia.org/c/@Image_MakeFromEncoded
185
196
  */
186
197
  static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded,
187
- skstd::optional<SkAlphaType> alphaType = skstd::nullopt);
198
+ std::optional<SkAlphaType> alphaType = std::nullopt);
188
199
 
189
200
  /*
190
201
  * Experimental:
@@ -264,7 +275,7 @@ public:
264
275
  @param width width of full SkImage
265
276
  @param height height of full SkImage
266
277
  @param type type of compression used
267
- @param mipMapped does 'data' contain data for all the mipmap levels?
278
+ @param mipmapped does 'data' contain data for all the mipmap levels?
268
279
  @param isProtected do the contents of 'data' require DRM protection (on Vulkan)?
269
280
  @return created SkImage, or nullptr
270
281
  */
@@ -272,7 +283,7 @@ public:
272
283
  sk_sp<SkData> data,
273
284
  int width, int height,
274
285
  CompressionType type,
275
- GrMipmapped mipMapped = GrMipmapped::kNo,
286
+ GrMipmapped mipmapped = GrMipmapped::kNo,
276
287
  GrProtected isProtected = GrProtected::kNo);
277
288
 
278
289
  /** User function called when supplied texture may be deleted.
@@ -390,12 +401,21 @@ public:
390
401
  @param colorSpace range of colors; may be nullptr
391
402
  @return created SkImage, or nullptr
392
403
  */
404
+ static sk_sp<SkImage> MakeFromAdoptedTexture(GrRecordingContext* context,
405
+ const GrBackendTexture& backendTexture,
406
+ GrSurfaceOrigin textureOrigin,
407
+ SkColorType colorType);
393
408
  static sk_sp<SkImage> MakeFromAdoptedTexture(GrRecordingContext* context,
394
409
  const GrBackendTexture& backendTexture,
395
410
  GrSurfaceOrigin textureOrigin,
396
411
  SkColorType colorType,
397
- SkAlphaType alphaType = kPremul_SkAlphaType,
398
- sk_sp<SkColorSpace> colorSpace = nullptr);
412
+ SkAlphaType alphaType);
413
+ static sk_sp<SkImage> MakeFromAdoptedTexture(GrRecordingContext* context,
414
+ const GrBackendTexture& backendTexture,
415
+ GrSurfaceOrigin textureOrigin,
416
+ SkColorType colorType,
417
+ SkAlphaType alphaType,
418
+ sk_sp<SkColorSpace> colorSpace);
399
419
 
400
420
  /** Creates an SkImage from YUV[A] planar textures. This requires that the textures stay valid
401
421
  for the lifetime of the image. The ReleaseContext can be used to know when it is safe to
@@ -442,7 +462,7 @@ public:
442
462
  */
443
463
  static sk_sp<SkImage> MakeFromYUVAPixmaps(GrRecordingContext* context,
444
464
  const SkYUVAPixmaps& pixmaps,
445
- GrMipMapped buildMips = GrMipmapped::kNo,
465
+ GrMipmapped buildMips = GrMipmapped::kNo,
446
466
  bool limitToMaxTextureSize = false,
447
467
  sk_sp<SkColorSpace> imageColorSpace = nullptr);
448
468
 
@@ -472,7 +492,7 @@ public:
472
492
  @param gpuContextProxy the thread-safe proxy of the gpu context. required.
473
493
  @param backendFormat format of promised gpu texture
474
494
  @param dimensions width & height of promised gpu texture
475
- @param mipMapped mip mapped state of promised gpu texture
495
+ @param mipmapped mip mapped state of promised gpu texture
476
496
  @param origin surface origin of promised gpu texture
477
497
  @param colorType color type of promised gpu texture
478
498
  @param alphaType alpha type of promised gpu texture
@@ -485,7 +505,7 @@ public:
485
505
  static sk_sp<SkImage> MakePromiseTexture(sk_sp<GrContextThreadSafeProxy> gpuContextProxy,
486
506
  const GrBackendFormat& backendFormat,
487
507
  SkISize dimensions,
488
- GrMipmapped mipMapped,
508
+ GrMipmapped mipmapped,
489
509
  GrSurfaceOrigin origin,
490
510
  SkColorType colorType,
491
511
  SkAlphaType alphaType,
@@ -722,7 +742,7 @@ public:
722
742
  */
723
743
  bool peekPixels(SkPixmap* pixmap) const;
724
744
 
725
- /** Returns true the contents of SkImage was created on or uploaded to GPU memory,
745
+ /** Returns true if the contents of SkImage was created on or uploaded to GPU memory,
726
746
  and is available as a GPU texture.
727
747
 
728
748
  @return true if SkImage is a GPU texture
@@ -1101,14 +1121,14 @@ public:
1101
1121
  #if SK_SUPPORT_GPU
1102
1122
  /** Returns SkImage backed by GPU texture associated with context. Returned SkImage is
1103
1123
  compatible with SkSurface created with dstColorSpace. The returned SkImage respects
1104
- mipMapped setting; if mipMapped equals GrMipmapped::kYes, the backing texture
1124
+ mipmapped setting; if mipmapped equals GrMipmapped::kYes, the backing texture
1105
1125
  allocates mip map levels.
1106
1126
 
1107
- The mipMapped parameter is effectively treated as kNo if MIP maps are not supported by the
1127
+ The mipmapped parameter is effectively treated as kNo if MIP maps are not supported by the
1108
1128
  GPU.
1109
1129
 
1110
1130
  Returns original SkImage if the image is already texture-backed, the context matches, and
1111
- mipMapped is compatible with the backing GPU texture. SkBudgeted is ignored in this case.
1131
+ mipmapped is compatible with the backing GPU texture. SkBudgeted is ignored in this case.
1112
1132
 
1113
1133
  Returns nullptr if context is nullptr, or if SkImage was created with another
1114
1134
  GrDirectContext.
@@ -1122,6 +1142,31 @@ public:
1122
1142
  sk_sp<SkImage> makeTextureImage(GrDirectContext*,
1123
1143
  GrMipmapped = GrMipmapped::kNo,
1124
1144
  SkBudgeted = SkBudgeted::kYes) const;
1145
+ #endif
1146
+ #ifdef SK_GRAPHITE_ENABLED
1147
+ /** Graphite version of makeTextureImage.
1148
+
1149
+ Returns SkImage backed by GPU texture, using Recorder for creation and uploads if necessary.
1150
+ The returned SkImage respects mipmapped setting for non-GPU SkImages; if mipmapped
1151
+ equals GrMipmapped::kYes, the backing texture allocates mip map levels.
1152
+
1153
+ It is assumed that MIP maps are always supported by the GPU.
1154
+
1155
+ Returns original SkImage if the image is already texture-backed, the recorder matches, and
1156
+ mipmapped is compatible with the backing GPU texture. If mipmapped is not compatible,
1157
+ it will return nullptr.
1158
+
1159
+ Returns nullptr if recorder is nullptr, or if SkImage was created with another
1160
+ Recorder and work on that Recorder has not been submitted.
1161
+
1162
+ @param Recorder the Recorder to use for storing commands
1163
+ @param Mipmapped whether created SkImage texture must allocate mip map levels
1164
+ @return created SkImage, or nullptr
1165
+ */
1166
+ sk_sp<SkImage> makeTextureImage(skgpu::graphite::Recorder*,
1167
+ skgpu::graphite::Mipmapped = skgpu::graphite::Mipmapped::kNo,
1168
+ SkBudgeted = SkBudgeted::kYes) const;
1169
+
1125
1170
  #endif
1126
1171
 
1127
1172
  /** Returns raster image or lazy image. Copies SkImage backed by GPU texture into
@@ -8,9 +8,6 @@
8
8
  #ifndef SkImageEncoder_DEFINED
9
9
  #define SkImageEncoder_DEFINED
10
10
 
11
- // TODO: update clients so we can remove this include, they should IWYU
12
- #include "include/core/SkBitmap.h"
13
-
14
11
  #include "include/core/SkData.h"
15
12
  #include "include/core/SkEncodedImageFormat.h"
16
13
  #include "include/core/SkPixmap.h"
@@ -13,7 +13,8 @@
13
13
  #include "include/core/SkImage.h"
14
14
  #include "include/core/SkImageInfo.h"
15
15
  #include "include/core/SkYUVAPixmaps.h"
16
- #include "include/private/SkTOptional.h"
16
+
17
+ #include <optional>
17
18
 
18
19
  class GrRecordingContext;
19
20
  class GrSurfaceProxyView;
@@ -158,7 +159,7 @@ public:
158
159
  * kOpaque_SkAlphaType is not supported, and will return NULL.
159
160
  */
160
161
  static std::unique_ptr<SkImageGenerator> MakeFromEncoded(
161
- sk_sp<SkData>, skstd::optional<SkAlphaType> = skstd::nullopt);
162
+ sk_sp<SkData>, std::optional<SkAlphaType> = std::nullopt);
162
163
 
163
164
  /** Return a new image generator backed by the specified picture. If the size is empty or
164
165
  * the picture is NULL, this returns NULL.
@@ -204,7 +205,7 @@ private:
204
205
  // It is called from NewFromEncoded() after it has checked for any runtime factory.
205
206
  // The SkData will never be NULL, as that will have been checked by NewFromEncoded.
206
207
  static std::unique_ptr<SkImageGenerator> MakeFromEncodedImpl(sk_sp<SkData>,
207
- skstd::optional<SkAlphaType>);
208
+ std::optional<SkAlphaType>);
208
209
 
209
210
  SkImageGenerator(SkImageGenerator&&) = delete;
210
211
  SkImageGenerator(const SkImageGenerator&) = delete;
@@ -8,9 +8,11 @@
8
8
  #ifndef SkImageInfo_DEFINED
9
9
  #define SkImageInfo_DEFINED
10
10
 
11
- #include "include/core/SkColorSpace.h"
11
+ #include "include/core/SkAlphaType.h"
12
+ #include "include/core/SkColorType.h"
12
13
  #include "include/core/SkMath.h"
13
14
  #include "include/core/SkRect.h"
15
+ #include "include/core/SkRefCnt.h"
14
16
  #include "include/core/SkSize.h"
15
17
 
16
18
  #include "include/private/SkTFitsIn.h"
@@ -18,93 +20,7 @@
18
20
 
19
21
  class SkReadBuffer;
20
22
  class SkWriteBuffer;
21
-
22
- /** \enum SkImageInfo::SkAlphaType
23
- Describes how to interpret the alpha component of a pixel. A pixel may
24
- be opaque, or alpha, describing multiple levels of transparency.
25
-
26
- In simple blending, alpha weights the draw color and the destination
27
- color to create a new color. If alpha describes a weight from zero to one:
28
-
29
- new color = draw color * alpha + destination color * (1 - alpha)
30
-
31
- In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.
32
-
33
- RGB may have alpha included in each component value; the stored
34
- value is the original RGB multiplied by alpha. Premultiplied color
35
- components improve performance.
36
- */
37
- enum SkAlphaType : int {
38
- kUnknown_SkAlphaType, //!< uninitialized
39
- kOpaque_SkAlphaType, //!< pixel is opaque
40
- kPremul_SkAlphaType, //!< pixel components are premultiplied by alpha
41
- kUnpremul_SkAlphaType, //!< pixel components are independent of alpha
42
- kLastEnum_SkAlphaType = kUnpremul_SkAlphaType, //!< last valid value
43
- };
44
-
45
- /** Returns true if SkAlphaType equals kOpaque_SkAlphaType.
46
-
47
- kOpaque_SkAlphaType is a hint that the SkColorType is opaque, or that all
48
- alpha values are set to their 1.0 equivalent. If SkAlphaType is
49
- kOpaque_SkAlphaType, and SkColorType is not opaque, then the result of
50
- drawing any pixel with a alpha value less than 1.0 is undefined.
51
- */
52
- static inline bool SkAlphaTypeIsOpaque(SkAlphaType at) {
53
- return kOpaque_SkAlphaType == at;
54
- }
55
-
56
- ///////////////////////////////////////////////////////////////////////////////
57
-
58
- /** \enum SkImageInfo::SkColorType
59
- Describes how pixel bits encode color. A pixel may be an alpha mask, a grayscale, RGB, or ARGB.
60
-
61
- kN32_SkColorType selects the native 32-bit ARGB format for the current configuration. This can
62
- lead to inconsistent results across platforms, so use with caution.
63
- */
64
- enum SkColorType : int {
65
- kUnknown_SkColorType, //!< uninitialized
66
- kAlpha_8_SkColorType, //!< pixel with alpha in 8-bit byte
67
- kRGB_565_SkColorType, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
68
- kARGB_4444_SkColorType, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word
69
- kRGBA_8888_SkColorType, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word
70
- kRGB_888x_SkColorType, //!< pixel with 8 bits each for red, green, blue; in 32-bit word
71
- kBGRA_8888_SkColorType, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word
72
- kRGBA_1010102_SkColorType, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
73
- kBGRA_1010102_SkColorType, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
74
- kRGB_101010x_SkColorType, //!< pixel with 10 bits each for red, green, blue; in 32-bit word
75
- kBGR_101010x_SkColorType, //!< pixel with 10 bits each for blue, green, red; in 32-bit word
76
- kGray_8_SkColorType, //!< pixel with grayscale level in 8-bit byte
77
- kRGBA_F16Norm_SkColorType, //!< pixel with half floats in [0,1] for red, green, blue, alpha;
78
- // in 64-bit word
79
- kRGBA_F16_SkColorType, //!< pixel with half floats for red, green, blue, alpha;
80
- // in 64-bit word
81
- kRGBA_F32_SkColorType, //!< pixel using C float for red, green, blue, alpha; in 128-bit word
82
-
83
- // The following 6 colortypes are just for reading from - not for rendering to
84
- kR8G8_unorm_SkColorType, //!< pixel with a uint8_t for red and green
85
-
86
- kA16_float_SkColorType, //!< pixel with a half float for alpha
87
- kR16G16_float_SkColorType, //!< pixel with a half float for red and green
88
-
89
- kA16_unorm_SkColorType, //!< pixel with a little endian uint16_t for alpha
90
- kR16G16_unorm_SkColorType, //!< pixel with a little endian uint16_t for red and green
91
- kR16G16B16A16_unorm_SkColorType, //!< pixel with a little endian uint16_t for red, green, blue
92
- // and alpha
93
-
94
- kSRGBA_8888_SkColorType,
95
-
96
- kLastEnum_SkColorType = kSRGBA_8888_SkColorType, //!< last valid value
97
-
98
- #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
99
- kN32_SkColorType = kBGRA_8888_SkColorType,//!< native 32-bit BGRA encoding
100
-
101
- #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
102
- kN32_SkColorType = kRGBA_8888_SkColorType,//!< native 32-bit RGBA encoding
103
-
104
- #else
105
- #error "SK_*32_SHIFT values must correspond to BGRA or RGBA byte order"
106
- #endif
107
- };
23
+ class SkColorSpace;
108
24
 
109
25
  /** Returns the number of bytes required to store a pixel, including unused padding.
110
26
  Returns zero if ct is kUnknown_SkColorType or invalid.
@@ -183,7 +99,8 @@ public:
183
99
 
184
100
  @return empty SkImageInfo
185
101
  */
186
- SkColorInfo() = default;
102
+ SkColorInfo();
103
+ ~SkColorInfo();
187
104
 
188
105
  /** Creates SkColorInfo from SkColorType ct, SkAlphaType at, and optionally SkColorSpace cs.
189
106
 
@@ -194,17 +111,16 @@ public:
194
111
  combination is supported.
195
112
  @return created SkColorInfo
196
113
  */
197
- SkColorInfo(SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs)
198
- : fColorSpace(std::move(cs)), fColorType(ct), fAlphaType(at) {}
114
+ SkColorInfo(SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs);
199
115
 
200
- SkColorInfo(const SkColorInfo&) = default;
201
- SkColorInfo(SkColorInfo&&) = default;
116
+ SkColorInfo(const SkColorInfo&);
117
+ SkColorInfo(SkColorInfo&&);
202
118
 
203
- SkColorInfo& operator=(const SkColorInfo&) = default;
204
- SkColorInfo& operator=(SkColorInfo&&) = default;
119
+ SkColorInfo& operator=(const SkColorInfo&);
120
+ SkColorInfo& operator=(SkColorInfo&&);
205
121
 
206
- SkColorSpace* colorSpace() const { return fColorSpace.get(); }
207
- sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
122
+ SkColorSpace* colorSpace() const;
123
+ sk_sp<SkColorSpace> refColorSpace() const;
208
124
  SkColorType colorType() const { return fColorType; }
209
125
  SkAlphaType alphaType() const { return fAlphaType; }
210
126
 
@@ -213,16 +129,13 @@ public:
213
129
  || SkColorTypeIsAlwaysOpaque(fColorType);
214
130
  }
215
131
 
216
- bool gammaCloseToSRGB() const { return fColorSpace && fColorSpace->gammaCloseToSRGB(); }
132
+ bool gammaCloseToSRGB() const;
217
133
 
218
134
  /** Does other represent the same color type, alpha type, and color space? */
219
- bool operator==(const SkColorInfo& other) const {
220
- return fColorType == other.fColorType && fAlphaType == other.fAlphaType &&
221
- SkColorSpace::Equals(fColorSpace.get(), other.fColorSpace.get());
222
- }
135
+ bool operator==(const SkColorInfo& other) const;
223
136
 
224
137
  /** Does other represent a different color type, alpha type, or color space? */
225
- bool operator!=(const SkColorInfo& other) const { return !(*this == other); }
138
+ bool operator!=(const SkColorInfo& other) const;
226
139
 
227
140
  /** Creates SkColorInfo with same SkColorType, SkColorSpace, with SkAlphaType set
228
141
  to newAlphaType.
@@ -230,23 +143,17 @@ public:
230
143
  Created SkColorInfo contains newAlphaType even if it is incompatible with
231
144
  SkColorType, in which case SkAlphaType in SkColorInfo is ignored.
232
145
  */
233
- SkColorInfo makeAlphaType(SkAlphaType newAlphaType) const {
234
- return SkColorInfo(this->colorType(), newAlphaType, this->refColorSpace());
235
- }
146
+ SkColorInfo makeAlphaType(SkAlphaType newAlphaType) const;
236
147
 
237
148
  /** Creates new SkColorInfo with same SkAlphaType, SkColorSpace, with SkColorType
238
149
  set to newColorType.
239
150
  */
240
- SkColorInfo makeColorType(SkColorType newColorType) const {
241
- return SkColorInfo(newColorType, this->alphaType(), this->refColorSpace());
242
- }
151
+ SkColorInfo makeColorType(SkColorType newColorType) const;
243
152
 
244
153
  /** Creates SkColorInfo with same SkAlphaType, SkColorType, with SkColorSpace
245
154
  set to cs. cs may be nullptr.
246
155
  */
247
- SkColorInfo makeColorSpace(sk_sp<SkColorSpace> cs) const {
248
- return SkColorInfo(this->colorType(), this->alphaType(), std::move(cs));
249
- }
156
+ SkColorInfo makeColorSpace(sk_sp<SkColorSpace> cs) const;
250
157
 
251
158
  /** Returns number of bytes per pixel required by SkColorType.
252
159
  Returns zero if colorType() is kUnknown_SkColorType.
@@ -306,14 +213,12 @@ public:
306
213
  @param cs range of colors; may be nullptr
307
214
  @return created SkImageInfo
308
215
  */
216
+ static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at);
309
217
  static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
310
- sk_sp<SkColorSpace> cs = nullptr) {
311
- return SkImageInfo({width, height}, {ct, at, std::move(cs)});
312
- }
218
+ sk_sp<SkColorSpace> cs);
219
+ static SkImageInfo Make(SkISize dimensions, SkColorType ct, SkAlphaType at);
313
220
  static SkImageInfo Make(SkISize dimensions, SkColorType ct, SkAlphaType at,
314
- sk_sp<SkColorSpace> cs = nullptr) {
315
- return SkImageInfo(dimensions, {ct, at, std::move(cs)});
316
- }
221
+ sk_sp<SkColorSpace> cs);
317
222
 
318
223
  /** Creates SkImageInfo from integral dimensions and SkColorInfo colorInfo,
319
224
 
@@ -347,10 +252,8 @@ public:
347
252
  @param cs range of colors; may be nullptr
348
253
  @return created SkImageInfo
349
254
  */
350
- static SkImageInfo MakeN32(int width, int height, SkAlphaType at,
351
- sk_sp<SkColorSpace> cs = nullptr) {
352
- return Make({width, height}, kN32_SkColorType, at, std::move(cs));
353
- }
255
+ static SkImageInfo MakeN32(int width, int height, SkAlphaType at);
256
+ static SkImageInfo MakeN32(int width, int height, SkAlphaType at, sk_sp<SkColorSpace> cs);
354
257
 
355
258
  /** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
356
259
  SkAlphaType at, with sRGB SkColorSpace.
@@ -380,9 +283,8 @@ public:
380
283
  @param cs range of colors; may be nullptr
381
284
  @return created SkImageInfo
382
285
  */
383
- static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs = nullptr) {
384
- return Make({width, height}, kN32_SkColorType, kPremul_SkAlphaType, std::move(cs));
385
- }
286
+ static SkImageInfo MakeN32Premul(int width, int height);
287
+ static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs);
386
288
 
387
289
  /** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
388
290
  kPremul_SkAlphaType, with SkColorSpace set to nullptr.
@@ -397,9 +299,8 @@ public:
397
299
  @param cs range of colors; may be nullptr
398
300
  @return created SkImageInfo
399
301
  */
400
- static SkImageInfo MakeN32Premul(SkISize dimensions, sk_sp<SkColorSpace> cs = nullptr) {
401
- return Make(dimensions, kN32_SkColorType, kPremul_SkAlphaType, std::move(cs));
402
- }
302
+ static SkImageInfo MakeN32Premul(SkISize dimensions);
303
+ static SkImageInfo MakeN32Premul(SkISize dimensions, sk_sp<SkColorSpace> cs);
403
304
 
404
305
  /** Creates SkImageInfo from integral dimensions width and height, kAlpha_8_SkColorType,
405
306
  kPremul_SkAlphaType, with SkColorSpace set to nullptr.
@@ -408,18 +309,14 @@ public:
408
309
  @param height pixel row count; must be zero or greater
409
310
  @return created SkImageInfo
410
311
  */
411
- static SkImageInfo MakeA8(int width, int height) {
412
- return Make({width, height}, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr);
413
- }
312
+ static SkImageInfo MakeA8(int width, int height);
414
313
  /** Creates SkImageInfo from integral dimensions, kAlpha_8_SkColorType,
415
314
  kPremul_SkAlphaType, with SkColorSpace set to nullptr.
416
315
 
417
316
  @param dimensions pixel row and column count; must be zero or greater
418
317
  @return created SkImageInfo
419
318
  */
420
- static SkImageInfo MakeA8(SkISize dimensions) {
421
- return Make(dimensions, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr);
422
- }
319
+ static SkImageInfo MakeA8(SkISize dimensions);
423
320
 
424
321
  /** Creates SkImageInfo from integral dimensions width and height, kUnknown_SkColorType,
425
322
  kUnknown_SkAlphaType, with SkColorSpace set to nullptr.
@@ -431,9 +328,7 @@ public:
431
328
  @param height pixel row count; must be zero or greater
432
329
  @return created SkImageInfo
433
330
  */
434
- static SkImageInfo MakeUnknown(int width, int height) {
435
- return Make({width, height}, kUnknown_SkColorType, kUnknown_SkAlphaType, nullptr);
436
- }
331
+ static SkImageInfo MakeUnknown(int width, int height);
437
332
 
438
333
  /** Creates SkImageInfo from integral dimensions width and height set to zero,
439
334
  kUnknown_SkColorType, kUnknown_SkAlphaType, with SkColorSpace set to nullptr.
@@ -468,7 +363,7 @@ public:
468
363
 
469
364
  @return SkColorSpace, or nullptr
470
365
  */
471
- SkColorSpace* colorSpace() const { return fColorInfo.colorSpace(); }
366
+ SkColorSpace* colorSpace() const;
472
367
 
473
368
  /** Returns smart pointer to SkColorSpace, the range of colors. The smart pointer
474
369
  tracks the number of objects sharing this SkColorSpace reference so the memory
@@ -478,7 +373,7 @@ public:
478
373
 
479
374
  @return SkColorSpace wrapped in a smart pointer
480
375
  */
481
- sk_sp<SkColorSpace> refColorSpace() const { return fColorInfo.refColorSpace(); }
376
+ sk_sp<SkColorSpace> refColorSpace() const;
482
377
 
483
378
  /** Returns if SkImageInfo describes an empty area of pixels by checking if either
484
379
  width or height is zero or smaller.
@@ -571,9 +466,7 @@ public:
571
466
  @param cs range of colors; may be nullptr
572
467
  @return created SkImageInfo
573
468
  */
574
- SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const {
575
- return Make(fDimensions, fColorInfo.makeColorSpace(std::move(cs)));
576
- }
469
+ SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const;
577
470
 
578
471
  /** Returns number of bytes per pixel required by SkColorType.
579
472
  Returns zero if colorType( is kUnknown_SkColorType.