@shopify/react-native-skia 2.4.6 → 2.4.14
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.
- package/android/cpp/jni/JniPlatformContext.cpp +1 -1
- package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +11 -1
- package/apple/RNSkApplePlatformContext.h +4 -0
- package/apple/RNSkApplePlatformContext.mm +69 -0
- package/apple/SkiaCVPixelBufferUtils.mm +8 -4
- package/cpp/api/JsiSkFontMgr.h +30 -6
- package/cpp/api/JsiSkImageFilterFactory.h +4 -2
- package/cpp/api/JsiSkPictureFactory.h +9 -6
- package/cpp/api/recorder/RNRecorder.h +33 -55
- package/cpp/rnskia/RNSkPictureView.h +7 -5
- package/cpp/rnskia/RNSkPlatformContext.h +16 -0
- package/cpp/skia/include/codec/SkAndroidCodec.h +3 -2
- package/cpp/skia/include/codec/SkAvifDecoder.h +2 -2
- package/cpp/skia/include/codec/SkBmpDecoder.h +1 -1
- package/cpp/skia/include/codec/SkCodec.h +2 -8
- package/cpp/skia/include/codec/SkEncodedOrigin.h +17 -0
- package/cpp/skia/include/codec/SkGifDecoder.h +1 -1
- package/cpp/skia/include/codec/SkIcoDecoder.h +1 -1
- package/cpp/skia/include/codec/SkJpegDecoder.h +8 -1
- package/cpp/skia/include/codec/SkJpegxlDecoder.h +1 -1
- package/cpp/skia/include/codec/SkPngDecoder.h +8 -1
- package/cpp/skia/include/codec/SkRawDecoder.h +1 -1
- package/cpp/skia/include/codec/SkWbmpDecoder.h +1 -1
- package/cpp/skia/include/codec/SkWebpDecoder.h +8 -1
- package/cpp/skia/include/core/SkCPURecorder.h +1 -0
- package/cpp/skia/include/core/SkCanvas.h +3 -2
- package/cpp/skia/include/core/SkColorTable.h +1 -1
- package/cpp/skia/include/core/SkColorType.h +4 -0
- package/cpp/skia/include/core/SkDocument.h +1 -1
- package/cpp/skia/include/core/SkGraphics.h +7 -2
- package/cpp/skia/include/core/SkImage.h +5 -1
- package/cpp/skia/include/core/SkImageGenerator.h +5 -3
- package/cpp/skia/include/core/SkM44.h +3 -3
- package/cpp/skia/include/core/SkMatrix.h +0 -23
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkOverdrawCanvas.h +1 -1
- package/cpp/skia/include/core/SkPath.h +216 -185
- package/cpp/skia/include/core/SkPathBuilder.h +97 -47
- package/cpp/skia/include/core/SkPathTypes.h +7 -1
- package/cpp/skia/include/core/SkPixmap.h +8 -8
- package/cpp/skia/include/core/SkRRect.h +24 -3
- package/cpp/skia/include/core/SkRecorder.h +3 -1
- package/cpp/skia/include/core/SkScalar.h +1 -1
- package/cpp/skia/include/core/SkSerialProcs.h +8 -4
- package/cpp/skia/include/core/SkStream.h +16 -9
- package/cpp/skia/include/core/SkString.h +1 -1
- package/cpp/skia/include/core/SkStrokeRec.h +1 -1
- package/cpp/skia/include/core/SkYUVAInfo.h +3 -0
- package/cpp/skia/include/docs/SkPDFDocument.h +1 -1
- package/cpp/skia/include/docs/SkPDFJpegHelpers.h +1 -1
- package/cpp/skia/include/docs/SkXPSDocument.h +18 -2
- package/cpp/skia/include/effects/SkRuntimeEffect.h +3 -1
- package/cpp/skia/include/encode/SkPngRustEncoder.h +18 -0
- package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrExternalTextureGenerator.h +1 -1
- package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +7 -6
- package/cpp/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h +6 -0
- package/cpp/skia/include/gpu/ganesh/vk/GrBackendDrawableInfo.h +2 -4
- package/cpp/skia/include/gpu/graphite/Context.h +15 -1
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +52 -11
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +44 -0
- package/cpp/skia/include/gpu/graphite/LogPriority.h +1 -1
- package/cpp/skia/include/gpu/graphite/PersistentPipelineStorage.h +45 -0
- package/cpp/skia/include/gpu/graphite/PrecompileContext.h +1 -1
- package/cpp/skia/include/gpu/graphite/Recorder.h +14 -0
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +13 -5
- package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +1 -4
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -4
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +2 -8
- package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanTypes.h +124 -9
- package/cpp/skia/include/ports/SkFontMgr_fuchsia.h +3 -1
- package/cpp/skia/include/ports/SkImageGeneratorCG.h +1 -1
- package/cpp/skia/include/ports/SkImageGeneratorNDK.h +1 -1
- package/cpp/skia/include/ports/SkImageGeneratorWIC.h +1 -1
- package/cpp/skia/include/ports/SkTypeface_fontations.h +1 -1
- package/cpp/skia/include/private/SkEncodedInfo.h +38 -29
- package/cpp/skia/include/private/SkJpegMetadataDecoder.h +18 -13
- package/cpp/skia/include/private/SkPathRef.h +3 -6
- package/cpp/skia/include/private/base/SkAlign.h +3 -7
- package/cpp/skia/include/private/base/SkContainers.h +1 -1
- package/cpp/skia/include/private/base/SkSpan_impl.h +29 -0
- package/cpp/skia/include/private/base/SkTArray.h +7 -8
- package/cpp/skia/include/private/base/SkTDArray.h +4 -4
- package/cpp/skia/include/private/base/SkTemplates.h +5 -5
- package/cpp/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +6 -5
- package/cpp/skia/include/svg/SkSVGCanvas.h +21 -1
- package/cpp/skia/include/utils/SkNoDrawCanvas.h +1 -1
- package/cpp/skia/include/utils/SkPaintFilterCanvas.h +1 -1
- package/cpp/skia/modules/skcms/src/skcms_public.h +29 -4
- package/cpp/skia/modules/skottie/include/Skottie.h +11 -0
- package/cpp/skia/modules/skottie/include/SlotManager.h +1 -1
- package/cpp/skia/modules/skparagraph/include/Metrics.h +1 -1
- package/cpp/skia/modules/skparagraph/include/Paragraph.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGMerge.h +1 -1
- package/cpp/skia/modules/sksg/include/SkSGPath.h +1 -1
- package/cpp/skia/modules/skshaper/include/SkShaper.h +2 -0
- package/cpp/skia/modules/skunicode/include/SkUnicode.h +4 -4
- package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeComponentTransfer.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGNode.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGValue.h +1 -1
- package/lib/commonjs/skia/core/Font.js +7 -1
- package/lib/commonjs/skia/core/Font.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +1 -7
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.d.ts +4 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +7 -2
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/skia/core/Font.js +7 -1
- package/lib/module/skia/core/Font.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +1 -7
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -1
- package/lib/module/views/SkiaPictureView.web.d.ts +4 -1
- package/lib/module/views/SkiaPictureView.web.js +7 -3
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/core/Font.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -11
- package/lib/typescript/lib/commonjs/views/SkiaPictureView.web.d.ts +1 -1
- package/lib/typescript/lib/module/mock/index.d.ts +1 -1
- package/lib/typescript/lib/module/skia/core/Font.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -1
- package/lib/typescript/lib/module/views/SkiaPictureView.web.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -1
- package/lib/typescript/src/views/SkiaPictureView.web.d.ts +4 -1
- package/package.json +8 -8
- package/scripts/install-skia.mjs +74 -1
- package/src/skia/core/Font.ts +9 -4
- package/src/skia/web/JsiSkCanvas.ts +1 -3
- package/src/views/SkiaPictureView.web.tsx +8 -7
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
#define skgpu_VulkanTypes_DEFINED
|
|
10
10
|
|
|
11
11
|
#include "include/core/SkTypes.h"
|
|
12
|
+
#include "include/private/base/SkTo.h"
|
|
12
13
|
#include "include/private/gpu/vk/SkiaVulkan.h"
|
|
13
14
|
|
|
14
15
|
#include <cstddef>
|
|
15
16
|
#include <cstdint>
|
|
16
17
|
#include <functional>
|
|
18
|
+
#include <optional>
|
|
17
19
|
#include <string>
|
|
18
20
|
#include <vector>
|
|
19
21
|
|
|
@@ -23,6 +25,10 @@
|
|
|
23
25
|
|
|
24
26
|
namespace skgpu {
|
|
25
27
|
|
|
28
|
+
namespace graphite {
|
|
29
|
+
class VulkanYcbcrConversion;
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
using VulkanGetProc = std::function<PFN_vkVoidFunction(
|
|
27
33
|
const char*, // function name
|
|
28
34
|
VkInstance, // instance or VK_NULL_HANDLE
|
|
@@ -60,16 +66,62 @@ private:
|
|
|
60
66
|
|
|
61
67
|
// Used to pass in the necessary information to create a VkSamplerYcbcrConversion object for an
|
|
62
68
|
// VkExternalFormatANDROID.
|
|
63
|
-
struct VulkanYcbcrConversionInfo {
|
|
69
|
+
struct SK_API VulkanYcbcrConversionInfo {
|
|
70
|
+
public:
|
|
71
|
+
// Makes an invalid VulkanYcbcrConversionInfo
|
|
72
|
+
VulkanYcbcrConversionInfo() = default;
|
|
73
|
+
|
|
74
|
+
// For external images format features here should be those returned by a call to
|
|
75
|
+
// vkAndroidHardwareBufferFormatPropertiesANDROID
|
|
76
|
+
VulkanYcbcrConversionInfo(uint64_t externalFormat,
|
|
77
|
+
VkSamplerYcbcrModelConversion ycbcrModel,
|
|
78
|
+
VkSamplerYcbcrRange ycbcrRange,
|
|
79
|
+
VkChromaLocation xChromaOffset,
|
|
80
|
+
VkChromaLocation yChromaOffset,
|
|
81
|
+
VkFilter chromaFilter,
|
|
82
|
+
VkBool32 forceExplicitReconstruction,
|
|
83
|
+
VkComponentMapping components,
|
|
84
|
+
VkFormatFeatureFlags formatFeatures)
|
|
85
|
+
: VulkanYcbcrConversionInfo(VK_FORMAT_UNDEFINED,
|
|
86
|
+
externalFormat,
|
|
87
|
+
ycbcrModel,
|
|
88
|
+
ycbcrRange,
|
|
89
|
+
xChromaOffset,
|
|
90
|
+
yChromaOffset,
|
|
91
|
+
chromaFilter,
|
|
92
|
+
forceExplicitReconstruction,
|
|
93
|
+
components,
|
|
94
|
+
formatFeatures) {}
|
|
95
|
+
|
|
96
|
+
VulkanYcbcrConversionInfo(VkFormat format,
|
|
97
|
+
VkSamplerYcbcrModelConversion ycbcrModel,
|
|
98
|
+
VkSamplerYcbcrRange ycbcrRange,
|
|
99
|
+
VkChromaLocation xChromaOffset,
|
|
100
|
+
VkChromaLocation yChromaOffset,
|
|
101
|
+
VkFilter chromaFilter,
|
|
102
|
+
VkBool32 forceExplicitReconstruction,
|
|
103
|
+
VkComponentMapping components,
|
|
104
|
+
VkFormatFeatureFlags formatFeatures)
|
|
105
|
+
: VulkanYcbcrConversionInfo(format,
|
|
106
|
+
0,
|
|
107
|
+
ycbcrModel,
|
|
108
|
+
ycbcrRange,
|
|
109
|
+
xChromaOffset,
|
|
110
|
+
yChromaOffset,
|
|
111
|
+
chromaFilter,
|
|
112
|
+
forceExplicitReconstruction,
|
|
113
|
+
components,
|
|
114
|
+
formatFeatures) {}
|
|
115
|
+
|
|
64
116
|
bool operator==(const VulkanYcbcrConversionInfo& that) const {
|
|
65
117
|
// Invalid objects are not required to have all other fields initialized or matching.
|
|
66
118
|
if (!this->isValid() && !that.isValid()) {
|
|
67
119
|
return true;
|
|
68
120
|
}
|
|
69
121
|
|
|
70
|
-
// Note that we do not need to check for
|
|
71
|
-
// Vulkan spec dictates that Android hardware buffers with the same external
|
|
72
|
-
// have the same support for key features. See
|
|
122
|
+
// Note that we do not need to check for fSamplerFilterMustMatchChromaFilter equality. This
|
|
123
|
+
// is because the Vulkan spec dictates that Android hardware buffers with the same external
|
|
124
|
+
// format must have the same support for key features. See
|
|
73
125
|
// https://docs.vulkan.org/spec/latest/chapters/memory.html#_android_hardware_buffer_external_memory
|
|
74
126
|
// for more details.
|
|
75
127
|
return this->fFormat == that.fFormat &&
|
|
@@ -89,9 +141,70 @@ struct VulkanYcbcrConversionInfo {
|
|
|
89
141
|
|
|
90
142
|
bool isValid() const {
|
|
91
143
|
return fYcbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY ||
|
|
92
|
-
|
|
144
|
+
this->hasExternalFormat();
|
|
93
145
|
}
|
|
94
146
|
|
|
147
|
+
VkFormat format() const { return fFormat; }
|
|
148
|
+
|
|
149
|
+
bool hasExternalFormat() const { return fExternalFormat != 0; }
|
|
150
|
+
uint64_t externalFormat() const { return fExternalFormat; }
|
|
151
|
+
|
|
152
|
+
VkSamplerYcbcrModelConversion model() const { return fYcbcrModel; }
|
|
153
|
+
VkSamplerYcbcrRange range() const { return fYcbcrRange; }
|
|
154
|
+
VkChromaLocation xChromaOffset() const { return fXChromaOffset; }
|
|
155
|
+
VkChromaLocation yChromaOffset() const { return fYChromaOffset; }
|
|
156
|
+
VkFilter chromaFilter() const { return fChromaFilter; }
|
|
157
|
+
VkBool32 forceExplicitReconstruction() const { return fForceExplicitReconstruction; }
|
|
158
|
+
VkComponentMapping components() const { return fComponents; }
|
|
159
|
+
|
|
160
|
+
bool samplerFilterMustMatchChromaFilter() const { return fSamplerFilterMustMatchChromaFilter; }
|
|
161
|
+
bool supportsLinearFilter() const { return fSupportsLinearFilter; }
|
|
162
|
+
|
|
163
|
+
// Returns a populated VkSamplerYcbcrConversionCreateInfo object based on
|
|
164
|
+
// VulkanYcbcrConversionInfo
|
|
165
|
+
void toVkSamplerYcbcrConversionCreateInfo(VkSamplerYcbcrConversionCreateInfo* outInfo,
|
|
166
|
+
std::optional<VkFilter>* requiredSamplerFilter) const;
|
|
167
|
+
|
|
168
|
+
private:
|
|
169
|
+
VulkanYcbcrConversionInfo(VkFormat format,
|
|
170
|
+
uint64_t externalFormat,
|
|
171
|
+
VkSamplerYcbcrModelConversion ycbcrModel,
|
|
172
|
+
VkSamplerYcbcrRange ycbcrRange,
|
|
173
|
+
VkChromaLocation xChromaOffset,
|
|
174
|
+
VkChromaLocation yChromaOffset,
|
|
175
|
+
VkFilter chromaFilter,
|
|
176
|
+
VkBool32 forceExplicitReconstruction,
|
|
177
|
+
VkComponentMapping components,
|
|
178
|
+
VkFormatFeatureFlags formatFeatures);
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
// For use internally to recreate from an ImmutableSamplerInfo. We don't have feature flags
|
|
182
|
+
// and assume we've updated all the fields as required by the feature flags previously.
|
|
183
|
+
friend class graphite::VulkanYcbcrConversion;
|
|
184
|
+
|
|
185
|
+
VulkanYcbcrConversionInfo(VkFormat format,
|
|
186
|
+
uint64_t externalFormat,
|
|
187
|
+
VkSamplerYcbcrModelConversion ycbcrModel,
|
|
188
|
+
VkSamplerYcbcrRange ycbcrRange,
|
|
189
|
+
VkChromaLocation xChromaOffset,
|
|
190
|
+
VkChromaLocation yChromaOffset,
|
|
191
|
+
VkFilter chromaFilter,
|
|
192
|
+
VkBool32 forceExplicitReconstruction,
|
|
193
|
+
VkComponentMapping components,
|
|
194
|
+
bool mustMatchChromaFilter,
|
|
195
|
+
bool supportsLinearFilter)
|
|
196
|
+
: fFormat(format)
|
|
197
|
+
, fExternalFormat(externalFormat)
|
|
198
|
+
, fYcbcrModel(ycbcrModel)
|
|
199
|
+
, fYcbcrRange(ycbcrRange)
|
|
200
|
+
, fXChromaOffset(xChromaOffset)
|
|
201
|
+
, fYChromaOffset(yChromaOffset)
|
|
202
|
+
, fChromaFilter(chromaFilter)
|
|
203
|
+
, fForceExplicitReconstruction(forceExplicitReconstruction)
|
|
204
|
+
, fComponents(components)
|
|
205
|
+
, fSamplerFilterMustMatchChromaFilter(mustMatchChromaFilter)
|
|
206
|
+
, fSupportsLinearFilter(supportsLinearFilter) {}
|
|
207
|
+
|
|
95
208
|
// Format of the source image. Must be set to VK_FORMAT_UNDEFINED for external images or
|
|
96
209
|
// a valid image format otherwise.
|
|
97
210
|
VkFormat fFormat = VK_FORMAT_UNDEFINED;
|
|
@@ -107,15 +220,17 @@ struct VulkanYcbcrConversionInfo {
|
|
|
107
220
|
VkFilter fChromaFilter = VK_FILTER_NEAREST;
|
|
108
221
|
VkBool32 fForceExplicitReconstruction = false;
|
|
109
222
|
|
|
110
|
-
// For external images format features here should be those returned by a call to
|
|
111
|
-
// vkAndroidHardwareBufferFormatPropertiesANDROID
|
|
112
|
-
VkFormatFeatureFlags fFormatFeatures = 0;
|
|
113
|
-
|
|
114
223
|
// This is ignored when fExternalFormat is non-zero.
|
|
115
224
|
VkComponentMapping fComponents = {VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
116
225
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
117
226
|
VK_COMPONENT_SWIZZLE_IDENTITY,
|
|
118
227
|
VK_COMPONENT_SWIZZLE_IDENTITY};
|
|
228
|
+
|
|
229
|
+
// Default these values to the most restrictive. These defaults only really matter until
|
|
230
|
+
// we force all clients to go through our constructors. At that point these will be set to the
|
|
231
|
+
// correct values.
|
|
232
|
+
bool fSamplerFilterMustMatchChromaFilter = true;
|
|
233
|
+
bool fSupportsLinearFilter = false;
|
|
119
234
|
};
|
|
120
235
|
|
|
121
236
|
typedef void* VulkanDeviceLostContext;
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
#include <fuchsia/fonts/cpp/fidl.h>
|
|
12
12
|
|
|
13
13
|
#include "include/core/SkRefCnt.h"
|
|
14
|
+
#include <memory>
|
|
14
15
|
|
|
15
16
|
class SkFontMgr;
|
|
17
|
+
class SkFontScanner;
|
|
16
18
|
|
|
17
|
-
SK_API sk_sp<SkFontMgr> SkFontMgr_New_Fuchsia(fuchsia::fonts::ProviderSyncPtr provider);
|
|
19
|
+
SK_API sk_sp<SkFontMgr> SkFontMgr_New_Fuchsia(fuchsia::fonts::ProviderSyncPtr provider, std::unique_ptr<SkFontScanner> scanner);
|
|
18
20
|
|
|
19
21
|
#endif // SkFontMgr_fuchsia_DEFINED
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
#include <memory>
|
|
22
22
|
|
|
23
23
|
namespace SkImageGeneratorCG {
|
|
24
|
-
SK_API std::unique_ptr<SkImageGenerator> MakeFromEncodedCG(sk_sp<SkData>);
|
|
24
|
+
SK_API std::unique_ptr<SkImageGenerator> MakeFromEncodedCG(sk_sp<const SkData>);
|
|
25
25
|
} // namespace SkImageGeneratorCG
|
|
26
26
|
|
|
27
27
|
#endif // defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
|
|
@@ -33,7 +33,7 @@ namespace SkImageGeneratorNDK {
|
|
|
33
33
|
* API like SkCodecImageGenerator::getScaledDimensions() to report which
|
|
34
34
|
* dimensions are supported?
|
|
35
35
|
*/
|
|
36
|
-
SK_API std::unique_ptr<SkImageGenerator> MakeFromEncodedNDK(sk_sp<SkData>);
|
|
36
|
+
SK_API std::unique_ptr<SkImageGenerator> MakeFromEncodedNDK(sk_sp<const SkData>);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
#endif // SK_ENABLE_NDK_IMAGES
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* https://msdn.microsoft.com/en-us/library/windows/desktop/ff485844.aspx
|
|
35
35
|
*/
|
|
36
36
|
namespace SkImageGeneratorWIC {
|
|
37
|
-
SK_API std::unique_ptr<SkImageGenerator> MakeFromEncodedWIC(sk_sp<SkData>);
|
|
37
|
+
SK_API std::unique_ptr<SkImageGenerator> MakeFromEncodedWIC(sk_sp<const SkData>);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
#endif // SK_BUILD_FOR_WIN
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
SK_API sk_sp<SkTypeface> SkTypeface_Make_Fontations(std::unique_ptr<SkStreamAsset> fontData,
|
|
19
19
|
const SkFontArguments& args);
|
|
20
20
|
|
|
21
|
-
SK_API sk_sp<SkTypeface> SkTypeface_Make_Fontations(sk_sp<SkData> fontData,
|
|
21
|
+
SK_API sk_sp<SkTypeface> SkTypeface_Make_Fontations(sk_sp<const SkData> fontData,
|
|
22
22
|
const SkFontArguments& args);
|
|
23
23
|
|
|
24
24
|
#endif
|
|
@@ -28,16 +28,16 @@ struct SkEncodedInfo {
|
|
|
28
28
|
public:
|
|
29
29
|
class ICCProfile {
|
|
30
30
|
public:
|
|
31
|
-
static std::unique_ptr<ICCProfile> Make(sk_sp<SkData>);
|
|
31
|
+
static std::unique_ptr<ICCProfile> Make(sk_sp<const SkData>);
|
|
32
32
|
static std::unique_ptr<ICCProfile> Make(const skcms_ICCProfile&);
|
|
33
33
|
|
|
34
34
|
const skcms_ICCProfile* profile() const { return &fProfile; }
|
|
35
|
-
sk_sp<SkData> data() const { return fData; }
|
|
35
|
+
sk_sp<const SkData> data() const { return fData; }
|
|
36
36
|
private:
|
|
37
|
-
ICCProfile(const skcms_ICCProfile&, sk_sp<SkData> = nullptr);
|
|
37
|
+
ICCProfile(const skcms_ICCProfile&, sk_sp<const SkData> = nullptr);
|
|
38
38
|
|
|
39
|
-
skcms_ICCProfile
|
|
40
|
-
sk_sp<SkData>
|
|
39
|
+
skcms_ICCProfile fProfile;
|
|
40
|
+
sk_sp<const SkData> fData;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
enum Alpha {
|
|
@@ -172,7 +172,7 @@ public:
|
|
|
172
172
|
if (!fProfile) return nullptr;
|
|
173
173
|
return fProfile->profile();
|
|
174
174
|
}
|
|
175
|
-
sk_sp<SkData> profileData() const {
|
|
175
|
+
sk_sp<const SkData> profileData() const {
|
|
176
176
|
if (!fProfile) return nullptr;
|
|
177
177
|
return fProfile->data();
|
|
178
178
|
}
|
|
@@ -213,9 +213,14 @@ public:
|
|
|
213
213
|
|
|
214
214
|
// Explicit copy method, to avoid accidental copying.
|
|
215
215
|
SkEncodedInfo copy() const {
|
|
216
|
-
return SkEncodedInfo(
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
return SkEncodedInfo(fWidth,
|
|
217
|
+
fHeight,
|
|
218
|
+
fColor,
|
|
219
|
+
fAlpha,
|
|
220
|
+
fBitsPerComponent,
|
|
221
|
+
fColorDepth,
|
|
222
|
+
fProfile ? std::make_unique<const ICCProfile>(*fProfile) : nullptr,
|
|
223
|
+
fHdrMetadata);
|
|
219
224
|
}
|
|
220
225
|
|
|
221
226
|
// Return number of bits of R/G/B channel
|
|
@@ -230,18 +235,22 @@ public:
|
|
|
230
235
|
}
|
|
231
236
|
|
|
232
237
|
private:
|
|
233
|
-
SkEncodedInfo(int width,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
238
|
+
SkEncodedInfo(int width,
|
|
239
|
+
int height,
|
|
240
|
+
Color color,
|
|
241
|
+
Alpha alpha,
|
|
242
|
+
uint8_t bitsPerComponent,
|
|
243
|
+
uint8_t colorDepth,
|
|
244
|
+
std::unique_ptr<const ICCProfile> profile,
|
|
245
|
+
const skhdr::Metadata& hdrMetadata)
|
|
246
|
+
: fWidth(width)
|
|
247
|
+
, fHeight(height)
|
|
248
|
+
, fColor(color)
|
|
249
|
+
, fAlpha(alpha)
|
|
250
|
+
, fBitsPerComponent(bitsPerComponent)
|
|
251
|
+
, fColorDepth(colorDepth)
|
|
252
|
+
, fProfile(std::move(profile))
|
|
253
|
+
, fHdrMetadata(hdrMetadata) {}
|
|
245
254
|
|
|
246
255
|
static void VerifyColor(Color color, Alpha alpha, int bitsPerComponent) {
|
|
247
256
|
// Avoid `-Wunused-parameter` warnings on non-debug builds.
|
|
@@ -289,14 +298,14 @@ private:
|
|
|
289
298
|
SkASSERT(false); // Unrecognized `color` enum value.
|
|
290
299
|
}
|
|
291
300
|
|
|
292
|
-
int
|
|
293
|
-
int
|
|
294
|
-
Color
|
|
295
|
-
Alpha
|
|
296
|
-
uint8_t
|
|
297
|
-
uint8_t
|
|
298
|
-
std::unique_ptr<ICCProfile> fProfile;
|
|
299
|
-
skhdr::Metadata
|
|
301
|
+
int fWidth;
|
|
302
|
+
int fHeight;
|
|
303
|
+
Color fColor;
|
|
304
|
+
Alpha fAlpha;
|
|
305
|
+
uint8_t fBitsPerComponent;
|
|
306
|
+
uint8_t fColorDepth;
|
|
307
|
+
std::unique_ptr<const ICCProfile> fProfile;
|
|
308
|
+
skhdr::Metadata fHdrMetadata;
|
|
300
309
|
};
|
|
301
310
|
|
|
302
311
|
#endif
|
|
@@ -32,13 +32,14 @@ public:
|
|
|
32
32
|
* A segment from a JPEG file. This is usually populated from a jpeg_marker_struct.
|
|
33
33
|
*/
|
|
34
34
|
struct SK_API Segment {
|
|
35
|
-
Segment(uint8_t marker, sk_sp<SkData> data)
|
|
35
|
+
Segment(uint8_t marker, sk_sp<const SkData> data)
|
|
36
|
+
: fMarker(marker), fData(std::move(data)) {}
|
|
36
37
|
|
|
37
38
|
// The segment's marker.
|
|
38
39
|
uint8_t fMarker = 0;
|
|
39
40
|
|
|
40
41
|
// The segment's parameters (not including the marker and parameter length).
|
|
41
|
-
sk_sp<SkData> fData;
|
|
42
|
+
sk_sp<const SkData> fData;
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
/**
|
|
@@ -50,28 +51,28 @@ public:
|
|
|
50
51
|
/**
|
|
51
52
|
* Create metadata for the specified encoded JPEG file. This may return nullptr.
|
|
52
53
|
*/
|
|
53
|
-
static std::unique_ptr<SkJpegMetadataDecoder> Make(sk_sp<SkData> data);
|
|
54
|
+
static std::unique_ptr<SkJpegMetadataDecoder> Make(sk_sp<const SkData> data);
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
57
|
* Return the Exif data attached to the image (if any) and nullptr otherwise. If |copyData| is
|
|
57
58
|
* false, then the returned SkData may directly reference the data provided when this object was
|
|
58
59
|
* created.
|
|
59
60
|
*/
|
|
60
|
-
virtual sk_sp<SkData> getExifMetadata(bool copyData) const = 0;
|
|
61
|
+
virtual sk_sp<const SkData> getExifMetadata(bool copyData) const = 0;
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
64
|
* Return the ICC profile of the image if any, and nullptr otherwise. If |copyData| is false,
|
|
64
65
|
* then the returned SkData may directly reference the data provided when this object was
|
|
65
66
|
* created.
|
|
66
67
|
*/
|
|
67
|
-
virtual sk_sp<SkData> getICCProfileData(bool copyData) const = 0;
|
|
68
|
+
virtual sk_sp<const SkData> getICCProfileData(bool copyData) const = 0;
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
* Return the ISO 21496-1 metadata, if any, and nullptr otherwise. If |copyData| is false,
|
|
71
72
|
* then the returned SkData may directly reference the data provided when this object was
|
|
72
73
|
* created.
|
|
73
74
|
*/
|
|
74
|
-
virtual sk_sp<SkData> getISOGainmapMetadata(bool copyData) const = 0;
|
|
75
|
+
virtual sk_sp<const SkData> getISOGainmapMetadata(bool copyData) const = 0;
|
|
75
76
|
|
|
76
77
|
/**
|
|
77
78
|
* Return true if there is a possibility that this image contains a gainmap image.
|
|
@@ -83,16 +84,20 @@ public:
|
|
|
83
84
|
* gainmap image and return in |outGainmapInfo| its gainmap rendering parameters. Return true if
|
|
84
85
|
* both output variables were successfully populated, otherwise return false.
|
|
85
86
|
*/
|
|
86
|
-
virtual
|
|
87
|
+
virtual std::pair<sk_sp<const SkData>, SkGainmapInfo> findGainmapImage(
|
|
88
|
+
sk_sp<const SkData>) const = 0;
|
|
89
|
+
|
|
90
|
+
// deprecated
|
|
91
|
+
virtual bool findGainmapImage(sk_sp<const SkData> baseImageData,
|
|
87
92
|
sk_sp<SkData>& outGainmapImagedata,
|
|
88
93
|
SkGainmapInfo& outGainmapInfo) = 0;
|
|
89
94
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
virtual sk_sp<SkData> getJUMBFMetadata(bool copyData) const = 0;
|
|
95
|
+
/**
|
|
96
|
+
* Return the first JUMBF superbox, if any, and nullptr otherwise. If |copyData| is false,
|
|
97
|
+
* then the returned SkData may directly reference the data provided when this object was
|
|
98
|
+
* created.
|
|
99
|
+
*/
|
|
100
|
+
virtual sk_sp<const SkData> getJUMBFMetadata(bool copyData) const = 0;
|
|
96
101
|
};
|
|
97
102
|
|
|
98
103
|
#endif
|
|
@@ -118,7 +118,7 @@ public:
|
|
|
118
118
|
{
|
|
119
119
|
fBoundsIsDirty = true; // this also invalidates fIsFinite
|
|
120
120
|
fGenerationID = 0; // recompute
|
|
121
|
-
fSegmentMask = segmentMask;
|
|
121
|
+
fSegmentMask = SkToU8(segmentMask);
|
|
122
122
|
fType = SkPathIsAType::kGeneral;
|
|
123
123
|
SkDEBUGCODE(fEditorsAttached.store(0);)
|
|
124
124
|
if (mx && !mx->isIdentity()) {
|
|
@@ -330,15 +330,13 @@ public:
|
|
|
330
330
|
|
|
331
331
|
bool operator== (const SkPathRef& ref) const;
|
|
332
332
|
|
|
333
|
-
void interpolate(const SkPathRef& ending, SkScalar weight, SkPathRef* out) const;
|
|
334
|
-
|
|
335
333
|
/**
|
|
336
334
|
* Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the
|
|
337
335
|
* same ID then they have the same verbs and points. However, two path refs may have the same
|
|
338
336
|
* contents but different genIDs.
|
|
339
337
|
* skbug.com/40032862 for background on why fillType is necessary (for now).
|
|
340
338
|
*/
|
|
341
|
-
uint32_t genID(
|
|
339
|
+
uint32_t genID(SkPathFillType fillType) const;
|
|
342
340
|
|
|
343
341
|
void addGenIDChangeListener(sk_sp<SkIDChangeListener>); // Threadsafe.
|
|
344
342
|
int genIDChangeListenerCount(); // Threadsafe
|
|
@@ -389,7 +387,7 @@ private:
|
|
|
389
387
|
|
|
390
388
|
// Return true if the computed bounds are finite.
|
|
391
389
|
static bool ComputePtBounds(SkRect* bounds, const SkPathRef& ref) {
|
|
392
|
-
return bounds->setBoundsCheck(
|
|
390
|
+
return bounds->setBoundsCheck(ref.pointSpan());
|
|
393
391
|
}
|
|
394
392
|
|
|
395
393
|
// called, if dirty, by getBounds()
|
|
@@ -541,7 +539,6 @@ private:
|
|
|
541
539
|
mutable bool fIsFinite; // only meaningful if bounds are valid
|
|
542
540
|
|
|
543
541
|
friend class PathRefTest_Private;
|
|
544
|
-
friend class ForceIsRRect_Private; // unit test isRRect
|
|
545
542
|
friend class SkPath;
|
|
546
543
|
friend class SkPathBuilder;
|
|
547
544
|
friend class SkPathPriv;
|
|
@@ -35,7 +35,7 @@ template <typename T> static constexpr bool SkIsAlignPtr(T x) {
|
|
|
35
35
|
/**
|
|
36
36
|
* align up to a power of 2
|
|
37
37
|
*/
|
|
38
|
-
static
|
|
38
|
+
template <typename T> static constexpr T SkAlignTo(T x, T alignment) {
|
|
39
39
|
// The same as alignment && SkIsPow2(value), w/o a dependency cycle.
|
|
40
40
|
SkASSERT(alignment && (alignment & (alignment - 1)) == 0);
|
|
41
41
|
return (x + alignment - 1) & ~(alignment - 1);
|
|
@@ -44,12 +44,8 @@ static inline constexpr size_t SkAlignTo(size_t x, size_t alignment) {
|
|
|
44
44
|
/**
|
|
45
45
|
* align up to a non power of 2
|
|
46
46
|
*/
|
|
47
|
-
static
|
|
48
|
-
|
|
49
|
-
if (misalignment) {
|
|
50
|
-
x += alignment - misalignment;
|
|
51
|
-
}
|
|
52
|
-
return x;
|
|
47
|
+
template <typename T> static constexpr T SkAlignNonPow2(T x, T alignment) {
|
|
48
|
+
return ((x + alignment - 1) / alignment) * alignment;
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
#endif
|
|
@@ -24,7 +24,7 @@ public:
|
|
|
24
24
|
// Rounds a requested capacity up towards `kCapacityMultiple` in a constexpr-friendly fashion.
|
|
25
25
|
template <typename T>
|
|
26
26
|
static constexpr size_t RoundUp(size_t capacity) {
|
|
27
|
-
return SkAlignTo(capacity * sizeof(T), kCapacityMultiple) / sizeof(T);
|
|
27
|
+
return SkAlignTo(capacity * sizeof(T), (size_t) kCapacityMultiple) / sizeof(T);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
private:
|
|
@@ -8,6 +8,27 @@
|
|
|
8
8
|
#ifndef SkSpan_DEFINED
|
|
9
9
|
#define SkSpan_DEFINED
|
|
10
10
|
|
|
11
|
+
/*
|
|
12
|
+
* Define this to keep the bespoke SkSpan implementation, until clients are ready.
|
|
13
|
+
* When this is not defined, SkSpan becomes just an alias for std::span
|
|
14
|
+
*/
|
|
15
|
+
#define SK_USE_LEGACY_SKSPAN
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* SkSpan handles single POD initialization differently from std::span
|
|
19
|
+
* This macro allows clients to initialize a span with a single POD that will work with
|
|
20
|
+
* either implementation of SkSpan.
|
|
21
|
+
*
|
|
22
|
+
* When we switch to std::span entirely, callsites can remove this macro, and juse type {{a}}
|
|
23
|
+
*/
|
|
24
|
+
#ifdef SK_USE_LEGACY_SKSPAN
|
|
25
|
+
#define SKSPAN_INIT_ONE(elem) {elem}
|
|
26
|
+
#else
|
|
27
|
+
#define SKSPAN_INIT_ONE(elem) {{elem}}
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#ifdef SK_USE_LEGACY_SKSPAN
|
|
31
|
+
|
|
11
32
|
#include "include/private/base/SkAssert.h"
|
|
12
33
|
#include "include/private/base/SkDebug.h"
|
|
13
34
|
#include "include/private/base/SkTo.h"
|
|
@@ -126,4 +147,12 @@ template <typename Container>
|
|
|
126
147
|
SkSpan(Container&&) ->
|
|
127
148
|
SkSpan<std::remove_pointer_t<decltype(std::data(std::declval<Container>()))>>;
|
|
128
149
|
|
|
150
|
+
#else
|
|
151
|
+
|
|
152
|
+
#include <span>
|
|
153
|
+
|
|
154
|
+
template <typename T> using SkSpan = std::span<T>;
|
|
155
|
+
|
|
156
|
+
#endif // legacy
|
|
157
|
+
|
|
129
158
|
#endif // SkSpan_DEFINED
|
|
@@ -81,7 +81,7 @@ public:
|
|
|
81
81
|
/**
|
|
82
82
|
* Creates a TArray by copying contents from an SkSpan. The new array will be heap allocated.
|
|
83
83
|
*/
|
|
84
|
-
TArray(SkSpan<const T> data) : TArray(data.
|
|
84
|
+
TArray(SkSpan<const T> data) : TArray(data.data(), static_cast<int>(data.size())) {}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Creates a TArray by copying contents of an initializer list.
|
|
@@ -154,12 +154,11 @@ public:
|
|
|
154
154
|
/**
|
|
155
155
|
* Resets to a copy of a C array and resets any reserve count.
|
|
156
156
|
*/
|
|
157
|
-
void reset(const T
|
|
158
|
-
SkASSERT(count >= 0);
|
|
157
|
+
void reset(SkSpan<const T> src) {
|
|
159
158
|
this->clear();
|
|
160
|
-
this->checkRealloc(
|
|
161
|
-
this->changeSize(
|
|
162
|
-
this->copy(
|
|
159
|
+
this->checkRealloc(src.size(), kExactFit);
|
|
160
|
+
this->changeSize(src.size());
|
|
161
|
+
this->copy(src.data());
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
/**
|
|
@@ -530,7 +529,7 @@ protected:
|
|
|
530
529
|
if (size > InitialCapacity) {
|
|
531
530
|
this->initData(size);
|
|
532
531
|
} else {
|
|
533
|
-
this->setDataFromBytes(
|
|
532
|
+
this->setDataFromBytes({storage->data(), storage->size()});
|
|
534
533
|
this->changeSize(size);
|
|
535
534
|
|
|
536
535
|
// setDataFromBytes always sets fOwnMemory to true, but we are actually using static
|
|
@@ -549,7 +548,7 @@ protected:
|
|
|
549
548
|
template <int InitialCapacity>
|
|
550
549
|
TArray(SkSpan<const T> data, SkAlignedSTStorage<InitialCapacity, T>* storage)
|
|
551
550
|
: TArray{storage, static_cast<int>(data.size())} {
|
|
552
|
-
this->copy(data.
|
|
551
|
+
this->copy(data.data());
|
|
553
552
|
}
|
|
554
553
|
|
|
555
554
|
private:
|
|
@@ -176,10 +176,10 @@ public:
|
|
|
176
176
|
fStorage.clear();
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
// Sets the number of elements in the array.
|
|
180
|
+
// If the array does not have space for count elements, it will increase
|
|
181
|
+
// the storage allocated to some amount greater than that required.
|
|
182
|
+
// It will never shrink the storage.
|
|
183
183
|
void resize(int count) {
|
|
184
184
|
fStorage.resize(count);
|
|
185
185
|
}
|
|
@@ -82,7 +82,7 @@ template <auto F> using SkFunctionObject =
|
|
|
82
82
|
reference is null when the destructor is called, we do not call the
|
|
83
83
|
function.
|
|
84
84
|
*/
|
|
85
|
-
template <typename T, void (*P)(T*)> class SkAutoTCallVProc
|
|
85
|
+
template <typename T, void (*P)(T*)> class [[nodiscard]] SkAutoTCallVProc
|
|
86
86
|
: public std::unique_ptr<T, SkFunctionObject<P>> {
|
|
87
87
|
using inherited = std::unique_ptr<T, SkFunctionObject<P>>;
|
|
88
88
|
public:
|
|
@@ -141,10 +141,10 @@ public:
|
|
|
141
141
|
size_t size_bytes() const { return sizeof(T) * fSize; }
|
|
142
142
|
|
|
143
143
|
T* begin() {
|
|
144
|
-
return fData;
|
|
144
|
+
return fData.get();
|
|
145
145
|
}
|
|
146
146
|
const T* begin() const {
|
|
147
|
-
return fData;
|
|
147
|
+
return fData.get();
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// It's safe to use fItemArray + fSize because if fItemArray is nullptr then adding 0 is
|
|
@@ -153,13 +153,13 @@ public:
|
|
|
153
153
|
if (fData == nullptr) {
|
|
154
154
|
SkASSERT(fSize == 0);
|
|
155
155
|
}
|
|
156
|
-
return
|
|
156
|
+
return this->begin() + fSize;
|
|
157
157
|
}
|
|
158
158
|
const T* end() const {
|
|
159
159
|
if (fData == nullptr) {
|
|
160
160
|
SkASSERT(fSize == 0);
|
|
161
161
|
}
|
|
162
|
-
return
|
|
162
|
+
return this->begin() + fSize;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
private:
|
|
@@ -32,7 +32,7 @@ class SkSurface;
|
|
|
32
32
|
*/
|
|
33
33
|
class SK_API GrDeferredDisplayListRecorder {
|
|
34
34
|
public:
|
|
35
|
-
GrDeferredDisplayListRecorder(const GrSurfaceCharacterization&);
|
|
35
|
+
explicit GrDeferredDisplayListRecorder(const GrSurfaceCharacterization&);
|
|
36
36
|
~GrDeferredDisplayListRecorder();
|
|
37
37
|
|
|
38
38
|
const GrSurfaceCharacterization& characterization() const {
|