@shopify/react-native-skia 2.0.0-next.3 → 2.0.0-next.5
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/apple/RNSkApplePlatformContext.h +2 -1
- package/apple/RNSkApplePlatformContext.mm +6 -4
- package/apple/RNSkAppleView.h +1 -1
- package/apple/RNSkAppleView.mm +1 -1
- package/apple/SkiaManager.mm +2 -1
- package/apple/SkiaUIView.h +1 -1
- package/cpp/api/JsiSkCanvas.h +29 -25
- package/cpp/api/recorder/Drawings.h +13 -17
- package/cpp/api/recorder/Shaders.h +21 -32
- package/cpp/skia/include/codec/SkCodec.h +39 -1
- package/cpp/skia/include/config/SkUserConfig.h +1 -10
- package/cpp/skia/include/core/SkCanvas.h +8 -4
- package/cpp/skia/include/core/SkContourMeasure.h +2 -2
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPaint.h +8 -5
- package/cpp/skia/include/core/SkStream.h +8 -3
- package/cpp/skia/include/core/SkTextBlob.h +9 -9
- package/cpp/skia/include/core/SkTypeface.h +4 -6
- package/cpp/skia/include/core/SkTypes.h +5 -0
- package/cpp/skia/include/docs/SkPDFDocument.h +47 -2
- package/cpp/skia/include/docs/SkPDFJpegHelpers.h +41 -0
- package/cpp/skia/include/effects/SkRuntimeEffect.h +5 -1
- package/cpp/skia/include/effects/SkTableMaskFilter.h +4 -0
- package/cpp/skia/include/gpu/graphite/BackendTexture.h +0 -2
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +17 -0
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +21 -18
- package/cpp/skia/include/gpu/graphite/PrecompileContext.h +24 -0
- package/cpp/skia/include/gpu/graphite/TextureInfo.h +87 -42
- package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +13 -4
- package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +9 -0
- package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +166 -0
- package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +3 -141
- package/cpp/skia/include/gpu/graphite/dawn/DawnUtils.h +2 -21
- package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +4 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +30 -6
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +4 -42
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h +50 -0
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteUtils.h +2 -20
- package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +14 -4
- package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +14 -6
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +31 -0
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +36 -14
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteUtils.h +3 -21
- package/cpp/skia/include/ports/SkTypeface_fontations.h +3 -0
- package/cpp/skia/include/private/SkJpegMetadataDecoder.h +7 -0
- package/cpp/skia/include/private/base/SkAnySubclass.h +6 -0
- package/cpp/skia/include/private/chromium/SkPMColor.h +38 -0
- package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -2
- package/cpp/skia/modules/skunicode/include/SkUnicode.h +10 -6
- package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -3
- package/cpp/skia/src/base/SkTInternalLList.h +1 -1
- package/cpp/skia/src/core/SkLRUCache.h +6 -3
- package/lib/commonjs/external/reanimated/textures.d.ts +2 -4
- package/lib/commonjs/external/reanimated/textures.js +8 -15
- package/lib/commonjs/external/reanimated/textures.js.map +1 -1
- package/lib/commonjs/sksg/HostConfig.js +2 -1
- package/lib/commonjs/sksg/HostConfig.js.map +1 -1
- package/lib/module/external/reanimated/textures.d.ts +2 -4
- package/lib/module/external/reanimated/textures.js +7 -12
- package/lib/module/external/reanimated/textures.js.map +1 -1
- package/lib/module/sksg/HostConfig.js +2 -1
- package/lib/module/sksg/HostConfig.js.map +1 -1
- package/lib/typescript/lib/commonjs/external/reanimated/textures.d.ts +1 -3
- package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -1
- package/lib/typescript/lib/module/external/reanimated/textures.d.ts +1 -3
- package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -1
- package/lib/typescript/src/external/reanimated/textures.d.ts +2 -4
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libskparagraph.a +0 -0
- package/libs/android/arm64-v8a/libsksg.a +0 -0
- package/libs/android/arm64-v8a/libskshaper.a +0 -0
- package/libs/android/arm64-v8a/libskunicode_icu.a +0 -0
- package/libs/android/arm64-v8a/libsvg.a +0 -0
- package/libs/android/armeabi-v7a/libskia.a +0 -0
- package/libs/android/armeabi-v7a/libskottie.a +0 -0
- package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
- package/libs/android/armeabi-v7a/libsksg.a +0 -0
- package/libs/android/armeabi-v7a/libskshaper.a +0 -0
- package/libs/android/armeabi-v7a/libskunicode_icu.a +0 -0
- package/libs/android/armeabi-v7a/libsvg.a +0 -0
- package/libs/android/x86/libskia.a +0 -0
- package/libs/android/x86/libskottie.a +0 -0
- package/libs/android/x86/libskparagraph.a +0 -0
- package/libs/android/x86/libsksg.a +0 -0
- package/libs/android/x86/libskshaper.a +0 -0
- package/libs/android/x86/libskunicode_icu.a +0 -0
- package/libs/android/x86/libsvg.a +0 -0
- package/libs/android/x86_64/libskia.a +0 -0
- package/libs/android/x86_64/libskottie.a +0 -0
- package/libs/android/x86_64/libskparagraph.a +0 -0
- package/libs/android/x86_64/libsksg.a +0 -0
- package/libs/android/x86_64/libskshaper.a +0 -0
- package/libs/android/x86_64/libskunicode_icu.a +0 -0
- package/libs/android/x86_64/libsvg.a +0 -0
- package/libs/apple/libskia.xcframework/Info.plist +15 -15
- package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/apple/libskottie.xcframework/Info.plist +7 -7
- package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/apple/libskparagraph.xcframework/Info.plist +13 -13
- package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/apple/libsksg.xcframework/Info.plist +13 -13
- package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
- package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/Info.plist +12 -12
- package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +15 -15
- package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libsvg.xcframework/Info.plist +8 -8
- package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +1 -1
- package/src/external/reanimated/textures.tsx +12 -20
- package/src/sksg/HostConfig.ts +2 -1
- package/cpp/skia/include/core/SkColorPriv.h +0 -165
- package/cpp/skia/include/private/SkColorData.h +0 -385
@@ -1,385 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2006 The Android Open Source Project
|
3
|
-
*
|
4
|
-
* Use of this source code is governed by a BSD-style license that can be
|
5
|
-
* found in the LICENSE file.
|
6
|
-
*/
|
7
|
-
|
8
|
-
#ifndef SkColorData_DEFINED
|
9
|
-
#define SkColorData_DEFINED
|
10
|
-
|
11
|
-
#include "include/core/SkColor.h"
|
12
|
-
#include "include/core/SkColorPriv.h"
|
13
|
-
#include "include/private/base/SkTo.h"
|
14
|
-
|
15
|
-
////////////////////////////////////////////////////////////////////////////////////////////
|
16
|
-
// Convert a 16bit pixel to a 32bit pixel
|
17
|
-
|
18
|
-
#define SK_R16_BITS 5
|
19
|
-
#define SK_G16_BITS 6
|
20
|
-
#define SK_B16_BITS 5
|
21
|
-
|
22
|
-
#define SK_R16_SHIFT (SK_B16_BITS + SK_G16_BITS)
|
23
|
-
#define SK_G16_SHIFT (SK_B16_BITS)
|
24
|
-
#define SK_B16_SHIFT 0
|
25
|
-
|
26
|
-
#define SK_R16_MASK ((1 << SK_R16_BITS) - 1)
|
27
|
-
#define SK_G16_MASK ((1 << SK_G16_BITS) - 1)
|
28
|
-
#define SK_B16_MASK ((1 << SK_B16_BITS) - 1)
|
29
|
-
|
30
|
-
#define SkGetPackedR16(color) (((unsigned)(color) >> SK_R16_SHIFT) & SK_R16_MASK)
|
31
|
-
#define SkGetPackedG16(color) (((unsigned)(color) >> SK_G16_SHIFT) & SK_G16_MASK)
|
32
|
-
#define SkGetPackedB16(color) (((unsigned)(color) >> SK_B16_SHIFT) & SK_B16_MASK)
|
33
|
-
|
34
|
-
static inline unsigned SkR16ToR32(unsigned r) {
|
35
|
-
return (r << (8 - SK_R16_BITS)) | (r >> (2 * SK_R16_BITS - 8));
|
36
|
-
}
|
37
|
-
|
38
|
-
static inline unsigned SkG16ToG32(unsigned g) {
|
39
|
-
return (g << (8 - SK_G16_BITS)) | (g >> (2 * SK_G16_BITS - 8));
|
40
|
-
}
|
41
|
-
|
42
|
-
static inline unsigned SkB16ToB32(unsigned b) {
|
43
|
-
return (b << (8 - SK_B16_BITS)) | (b >> (2 * SK_B16_BITS - 8));
|
44
|
-
}
|
45
|
-
|
46
|
-
#define SkPacked16ToR32(c) SkR16ToR32(SkGetPackedR16(c))
|
47
|
-
#define SkPacked16ToG32(c) SkG16ToG32(SkGetPackedG16(c))
|
48
|
-
#define SkPacked16ToB32(c) SkB16ToB32(SkGetPackedB16(c))
|
49
|
-
|
50
|
-
//////////////////////////////////////////////////////////////////////////////
|
51
|
-
|
52
|
-
#define SkASSERT_IS_BYTE(x) SkASSERT(0 == ((x) & ~0xFFu))
|
53
|
-
|
54
|
-
// Reverse the bytes coorsponding to RED and BLUE in a packed pixels. Note the
|
55
|
-
// pair of them are in the same 2 slots in both RGBA and BGRA, thus there is
|
56
|
-
// no need to pass in the colortype to this function.
|
57
|
-
static inline uint32_t SkSwizzle_RB(uint32_t c) {
|
58
|
-
static const uint32_t kRBMask = (0xFF << SK_R32_SHIFT) | (0xFF << SK_B32_SHIFT);
|
59
|
-
|
60
|
-
unsigned c0 = (c >> SK_R32_SHIFT) & 0xFF;
|
61
|
-
unsigned c1 = (c >> SK_B32_SHIFT) & 0xFF;
|
62
|
-
return (c & ~kRBMask) | (c0 << SK_B32_SHIFT) | (c1 << SK_R32_SHIFT);
|
63
|
-
}
|
64
|
-
|
65
|
-
static inline uint32_t SkPackARGB_as_RGBA(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
|
66
|
-
SkASSERT_IS_BYTE(a);
|
67
|
-
SkASSERT_IS_BYTE(r);
|
68
|
-
SkASSERT_IS_BYTE(g);
|
69
|
-
SkASSERT_IS_BYTE(b);
|
70
|
-
return (a << SK_RGBA_A32_SHIFT) | (r << SK_RGBA_R32_SHIFT) |
|
71
|
-
(g << SK_RGBA_G32_SHIFT) | (b << SK_RGBA_B32_SHIFT);
|
72
|
-
}
|
73
|
-
|
74
|
-
static inline uint32_t SkPackARGB_as_BGRA(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
|
75
|
-
SkASSERT_IS_BYTE(a);
|
76
|
-
SkASSERT_IS_BYTE(r);
|
77
|
-
SkASSERT_IS_BYTE(g);
|
78
|
-
SkASSERT_IS_BYTE(b);
|
79
|
-
return (a << SK_BGRA_A32_SHIFT) | (r << SK_BGRA_R32_SHIFT) |
|
80
|
-
(g << SK_BGRA_G32_SHIFT) | (b << SK_BGRA_B32_SHIFT);
|
81
|
-
}
|
82
|
-
|
83
|
-
static inline SkPMColor SkSwizzle_RGBA_to_PMColor(uint32_t c) {
|
84
|
-
#ifdef SK_PMCOLOR_IS_RGBA
|
85
|
-
return c;
|
86
|
-
#else
|
87
|
-
return SkSwizzle_RB(c);
|
88
|
-
#endif
|
89
|
-
}
|
90
|
-
|
91
|
-
static inline SkPMColor SkSwizzle_BGRA_to_PMColor(uint32_t c) {
|
92
|
-
#ifdef SK_PMCOLOR_IS_BGRA
|
93
|
-
return c;
|
94
|
-
#else
|
95
|
-
return SkSwizzle_RB(c);
|
96
|
-
#endif
|
97
|
-
}
|
98
|
-
|
99
|
-
//////////////////////////////////////////////////////////////////////////////
|
100
|
-
|
101
|
-
///@{
|
102
|
-
/** See ITU-R Recommendation BT.709 at http://www.itu.int/rec/R-REC-BT.709/ .*/
|
103
|
-
#define SK_ITU_BT709_LUM_COEFF_R (0.2126f)
|
104
|
-
#define SK_ITU_BT709_LUM_COEFF_G (0.7152f)
|
105
|
-
#define SK_ITU_BT709_LUM_COEFF_B (0.0722f)
|
106
|
-
///@}
|
107
|
-
|
108
|
-
///@{
|
109
|
-
/** A float value which specifies this channel's contribution to luminance. */
|
110
|
-
#define SK_LUM_COEFF_R SK_ITU_BT709_LUM_COEFF_R
|
111
|
-
#define SK_LUM_COEFF_G SK_ITU_BT709_LUM_COEFF_G
|
112
|
-
#define SK_LUM_COEFF_B SK_ITU_BT709_LUM_COEFF_B
|
113
|
-
///@}
|
114
|
-
|
115
|
-
/** Computes the luminance from the given r, g, and b in accordance with
|
116
|
-
SK_LUM_COEFF_X. For correct results, r, g, and b should be in linear space.
|
117
|
-
*/
|
118
|
-
static inline U8CPU SkComputeLuminance(U8CPU r, U8CPU g, U8CPU b) {
|
119
|
-
//The following is
|
120
|
-
//r * SK_LUM_COEFF_R + g * SK_LUM_COEFF_G + b * SK_LUM_COEFF_B
|
121
|
-
//with SK_LUM_COEFF_X in 1.8 fixed point (rounding adjusted to sum to 256).
|
122
|
-
return (r * 54 + g * 183 + b * 19) >> 8;
|
123
|
-
}
|
124
|
-
|
125
|
-
/** Calculates 256 - (value * alpha256) / 255 in range [0,256],
|
126
|
-
* for [0,255] value and [0,256] alpha256.
|
127
|
-
*/
|
128
|
-
static inline U16CPU SkAlphaMulInv256(U16CPU value, U16CPU alpha256) {
|
129
|
-
unsigned prod = 0xFFFF - value * alpha256;
|
130
|
-
return (prod + (prod >> 8)) >> 8;
|
131
|
-
}
|
132
|
-
|
133
|
-
// The caller may want negative values, so keep all params signed (int)
|
134
|
-
// so we don't accidentally slip into unsigned math and lose the sign
|
135
|
-
// extension when we shift (in SkAlphaMul)
|
136
|
-
static inline int SkAlphaBlend(int src, int dst, int scale256) {
|
137
|
-
SkASSERT((unsigned)scale256 <= 256);
|
138
|
-
return dst + SkAlphaMul(src - dst, scale256);
|
139
|
-
}
|
140
|
-
|
141
|
-
static inline uint16_t SkPackRGB16(unsigned r, unsigned g, unsigned b) {
|
142
|
-
SkASSERT(r <= SK_R16_MASK);
|
143
|
-
SkASSERT(g <= SK_G16_MASK);
|
144
|
-
SkASSERT(b <= SK_B16_MASK);
|
145
|
-
|
146
|
-
return SkToU16((r << SK_R16_SHIFT) | (g << SK_G16_SHIFT) | (b << SK_B16_SHIFT));
|
147
|
-
}
|
148
|
-
|
149
|
-
#define SK_R16_MASK_IN_PLACE (SK_R16_MASK << SK_R16_SHIFT)
|
150
|
-
#define SK_G16_MASK_IN_PLACE (SK_G16_MASK << SK_G16_SHIFT)
|
151
|
-
#define SK_B16_MASK_IN_PLACE (SK_B16_MASK << SK_B16_SHIFT)
|
152
|
-
|
153
|
-
///////////////////////////////////////////////////////////////////////////////
|
154
|
-
|
155
|
-
/**
|
156
|
-
* Abstract 4-byte interpolation, implemented on top of SkPMColor
|
157
|
-
* utility functions. Third parameter controls blending of the first two:
|
158
|
-
* (src, dst, 0) returns dst
|
159
|
-
* (src, dst, 0xFF) returns src
|
160
|
-
* scale is [0..256], unlike SkFourByteInterp which takes [0..255]
|
161
|
-
*/
|
162
|
-
static inline SkPMColor SkFourByteInterp256(SkPMColor src, SkPMColor dst, int scale) {
|
163
|
-
unsigned a = SkTo<uint8_t>(SkAlphaBlend(SkGetPackedA32(src), SkGetPackedA32(dst), scale));
|
164
|
-
unsigned r = SkTo<uint8_t>(SkAlphaBlend(SkGetPackedR32(src), SkGetPackedR32(dst), scale));
|
165
|
-
unsigned g = SkTo<uint8_t>(SkAlphaBlend(SkGetPackedG32(src), SkGetPackedG32(dst), scale));
|
166
|
-
unsigned b = SkTo<uint8_t>(SkAlphaBlend(SkGetPackedB32(src), SkGetPackedB32(dst), scale));
|
167
|
-
|
168
|
-
return SkPackARGB32(a, r, g, b);
|
169
|
-
}
|
170
|
-
|
171
|
-
/**
|
172
|
-
* Abstract 4-byte interpolation, implemented on top of SkPMColor
|
173
|
-
* utility functions. Third parameter controls blending of the first two:
|
174
|
-
* (src, dst, 0) returns dst
|
175
|
-
* (src, dst, 0xFF) returns src
|
176
|
-
*/
|
177
|
-
static inline SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight) {
|
178
|
-
int scale = (int)SkAlpha255To256(srcWeight);
|
179
|
-
return SkFourByteInterp256(src, dst, scale);
|
180
|
-
}
|
181
|
-
|
182
|
-
/**
|
183
|
-
* 0xAARRGGBB -> 0x00AA00GG, 0x00RR00BB
|
184
|
-
*/
|
185
|
-
static inline void SkSplay(uint32_t color, uint32_t* ag, uint32_t* rb) {
|
186
|
-
const uint32_t mask = 0x00FF00FF;
|
187
|
-
*ag = (color >> 8) & mask;
|
188
|
-
*rb = color & mask;
|
189
|
-
}
|
190
|
-
|
191
|
-
/**
|
192
|
-
* 0xAARRGGBB -> 0x00AA00GG00RR00BB
|
193
|
-
* (note, ARGB -> AGRB)
|
194
|
-
*/
|
195
|
-
static inline uint64_t SkSplay(uint32_t color) {
|
196
|
-
const uint32_t mask = 0x00FF00FF;
|
197
|
-
uint64_t agrb = (color >> 8) & mask; // 0x0000000000AA00GG
|
198
|
-
agrb <<= 32; // 0x00AA00GG00000000
|
199
|
-
agrb |= color & mask; // 0x00AA00GG00RR00BB
|
200
|
-
return agrb;
|
201
|
-
}
|
202
|
-
|
203
|
-
/**
|
204
|
-
* 0xAAxxGGxx, 0xRRxxBBxx-> 0xAARRGGBB
|
205
|
-
*/
|
206
|
-
static inline uint32_t SkUnsplay(uint32_t ag, uint32_t rb) {
|
207
|
-
const uint32_t mask = 0xFF00FF00;
|
208
|
-
return (ag & mask) | ((rb & mask) >> 8);
|
209
|
-
}
|
210
|
-
|
211
|
-
/**
|
212
|
-
* 0xAAxxGGxxRRxxBBxx -> 0xAARRGGBB
|
213
|
-
* (note, AGRB -> ARGB)
|
214
|
-
*/
|
215
|
-
static inline uint32_t SkUnsplay(uint64_t agrb) {
|
216
|
-
const uint32_t mask = 0xFF00FF00;
|
217
|
-
return SkPMColor(
|
218
|
-
((agrb & mask) >> 8) | // 0x00RR00BB
|
219
|
-
((agrb >> 32) & mask)); // 0xAARRGGBB
|
220
|
-
}
|
221
|
-
|
222
|
-
static inline SkPMColor SkFastFourByteInterp256_32(SkPMColor src, SkPMColor dst, unsigned scale) {
|
223
|
-
SkASSERT(scale <= 256);
|
224
|
-
|
225
|
-
// Two 8-bit blends per two 32-bit registers, with space to make sure the math doesn't collide.
|
226
|
-
uint32_t src_ag, src_rb, dst_ag, dst_rb;
|
227
|
-
SkSplay(src, &src_ag, &src_rb);
|
228
|
-
SkSplay(dst, &dst_ag, &dst_rb);
|
229
|
-
|
230
|
-
const uint32_t ret_ag = src_ag * scale + (256 - scale) * dst_ag;
|
231
|
-
const uint32_t ret_rb = src_rb * scale + (256 - scale) * dst_rb;
|
232
|
-
|
233
|
-
return SkUnsplay(ret_ag, ret_rb);
|
234
|
-
}
|
235
|
-
|
236
|
-
static inline SkPMColor SkFastFourByteInterp256_64(SkPMColor src, SkPMColor dst, unsigned scale) {
|
237
|
-
SkASSERT(scale <= 256);
|
238
|
-
// Four 8-bit blends in one 64-bit register, with space to make sure the math doesn't collide.
|
239
|
-
return SkUnsplay(SkSplay(src) * scale + (256-scale) * SkSplay(dst));
|
240
|
-
}
|
241
|
-
|
242
|
-
// TODO(mtklein): Replace slow versions with fast versions, using scale + (scale>>7) everywhere.
|
243
|
-
|
244
|
-
/**
|
245
|
-
* Same as SkFourByteInterp256, but faster.
|
246
|
-
*/
|
247
|
-
static inline SkPMColor SkFastFourByteInterp256(SkPMColor src, SkPMColor dst, unsigned scale) {
|
248
|
-
// On a 64-bit machine, _64 is about 10% faster than _32, but ~40% slower on a 32-bit machine.
|
249
|
-
if (sizeof(void*) == 4) {
|
250
|
-
return SkFastFourByteInterp256_32(src, dst, scale);
|
251
|
-
} else {
|
252
|
-
return SkFastFourByteInterp256_64(src, dst, scale);
|
253
|
-
}
|
254
|
-
}
|
255
|
-
|
256
|
-
/**
|
257
|
-
* Nearly the same as SkFourByteInterp, but faster and a touch more accurate, due to better
|
258
|
-
* srcWeight scaling to [0, 256].
|
259
|
-
*/
|
260
|
-
static inline SkPMColor SkFastFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight) {
|
261
|
-
SkASSERT(srcWeight <= 255);
|
262
|
-
// scale = srcWeight + (srcWeight >> 7) is more accurate than
|
263
|
-
// scale = srcWeight + 1, but 7% slower
|
264
|
-
return SkFastFourByteInterp256(src, dst, srcWeight + (srcWeight >> 7));
|
265
|
-
}
|
266
|
-
|
267
|
-
/**
|
268
|
-
* Interpolates between colors src and dst using [0,256] scale.
|
269
|
-
*/
|
270
|
-
static inline SkPMColor SkPMLerp(SkPMColor src, SkPMColor dst, unsigned scale) {
|
271
|
-
return SkFastFourByteInterp256(src, dst, scale);
|
272
|
-
}
|
273
|
-
|
274
|
-
static inline SkPMColor SkBlendARGB32(SkPMColor src, SkPMColor dst, U8CPU aa) {
|
275
|
-
SkASSERT((unsigned)aa <= 255);
|
276
|
-
|
277
|
-
unsigned src_scale = SkAlpha255To256(aa);
|
278
|
-
unsigned dst_scale = SkAlphaMulInv256(SkGetPackedA32(src), src_scale);
|
279
|
-
|
280
|
-
const uint32_t mask = 0xFF00FF;
|
281
|
-
|
282
|
-
uint32_t src_rb = (src & mask) * src_scale;
|
283
|
-
uint32_t src_ag = ((src >> 8) & mask) * src_scale;
|
284
|
-
|
285
|
-
uint32_t dst_rb = (dst & mask) * dst_scale;
|
286
|
-
uint32_t dst_ag = ((dst >> 8) & mask) * dst_scale;
|
287
|
-
|
288
|
-
return (((src_rb + dst_rb) >> 8) & mask) | ((src_ag + dst_ag) & ~mask);
|
289
|
-
}
|
290
|
-
|
291
|
-
////////////////////////////////////////////////////////////////////////////////////////////
|
292
|
-
// Convert a 32bit pixel to a 16bit pixel (no dither)
|
293
|
-
|
294
|
-
#define SkR32ToR16_MACRO(r) ((unsigned)(r) >> (SK_R32_BITS - SK_R16_BITS))
|
295
|
-
#define SkG32ToG16_MACRO(g) ((unsigned)(g) >> (SK_G32_BITS - SK_G16_BITS))
|
296
|
-
#define SkB32ToB16_MACRO(b) ((unsigned)(b) >> (SK_B32_BITS - SK_B16_BITS))
|
297
|
-
|
298
|
-
#ifdef SK_DEBUG
|
299
|
-
static inline unsigned SkR32ToR16(unsigned r) {
|
300
|
-
SkR32Assert(r);
|
301
|
-
return SkR32ToR16_MACRO(r);
|
302
|
-
}
|
303
|
-
static inline unsigned SkG32ToG16(unsigned g) {
|
304
|
-
SkG32Assert(g);
|
305
|
-
return SkG32ToG16_MACRO(g);
|
306
|
-
}
|
307
|
-
static inline unsigned SkB32ToB16(unsigned b) {
|
308
|
-
SkB32Assert(b);
|
309
|
-
return SkB32ToB16_MACRO(b);
|
310
|
-
}
|
311
|
-
#else
|
312
|
-
#define SkR32ToR16(r) SkR32ToR16_MACRO(r)
|
313
|
-
#define SkG32ToG16(g) SkG32ToG16_MACRO(g)
|
314
|
-
#define SkB32ToB16(b) SkB32ToB16_MACRO(b)
|
315
|
-
#endif
|
316
|
-
|
317
|
-
static inline U16CPU SkPixel32ToPixel16(SkPMColor c) {
|
318
|
-
unsigned r = ((c >> (SK_R32_SHIFT + (8 - SK_R16_BITS))) & SK_R16_MASK) << SK_R16_SHIFT;
|
319
|
-
unsigned g = ((c >> (SK_G32_SHIFT + (8 - SK_G16_BITS))) & SK_G16_MASK) << SK_G16_SHIFT;
|
320
|
-
unsigned b = ((c >> (SK_B32_SHIFT + (8 - SK_B16_BITS))) & SK_B16_MASK) << SK_B16_SHIFT;
|
321
|
-
return r | g | b;
|
322
|
-
}
|
323
|
-
|
324
|
-
static inline U16CPU SkPack888ToRGB16(U8CPU r, U8CPU g, U8CPU b) {
|
325
|
-
return (SkR32ToR16(r) << SK_R16_SHIFT) |
|
326
|
-
(SkG32ToG16(g) << SK_G16_SHIFT) |
|
327
|
-
(SkB32ToB16(b) << SK_B16_SHIFT);
|
328
|
-
}
|
329
|
-
|
330
|
-
/////////////////////////////////////////////////////////////////////////////////////////
|
331
|
-
|
332
|
-
static inline SkColor SkPixel16ToColor(U16CPU src) {
|
333
|
-
SkASSERT(src == SkToU16(src));
|
334
|
-
|
335
|
-
unsigned r = SkPacked16ToR32(src);
|
336
|
-
unsigned g = SkPacked16ToG32(src);
|
337
|
-
unsigned b = SkPacked16ToB32(src);
|
338
|
-
|
339
|
-
SkASSERT((r >> (8 - SK_R16_BITS)) == SkGetPackedR16(src));
|
340
|
-
SkASSERT((g >> (8 - SK_G16_BITS)) == SkGetPackedG16(src));
|
341
|
-
SkASSERT((b >> (8 - SK_B16_BITS)) == SkGetPackedB16(src));
|
342
|
-
|
343
|
-
return SkColorSetRGB(r, g, b);
|
344
|
-
}
|
345
|
-
|
346
|
-
///////////////////////////////////////////////////////////////////////////////
|
347
|
-
|
348
|
-
typedef uint16_t SkPMColor16;
|
349
|
-
|
350
|
-
// Put in OpenGL order (r g b a)
|
351
|
-
#define SK_A4444_SHIFT 0
|
352
|
-
#define SK_R4444_SHIFT 12
|
353
|
-
#define SK_G4444_SHIFT 8
|
354
|
-
#define SK_B4444_SHIFT 4
|
355
|
-
|
356
|
-
static inline U8CPU SkReplicateNibble(unsigned nib) {
|
357
|
-
SkASSERT(nib <= 0xF);
|
358
|
-
return (nib << 4) | nib;
|
359
|
-
}
|
360
|
-
|
361
|
-
#define SkGetPackedA4444(c) (((unsigned)(c) >> SK_A4444_SHIFT) & 0xF)
|
362
|
-
#define SkGetPackedR4444(c) (((unsigned)(c) >> SK_R4444_SHIFT) & 0xF)
|
363
|
-
#define SkGetPackedG4444(c) (((unsigned)(c) >> SK_G4444_SHIFT) & 0xF)
|
364
|
-
#define SkGetPackedB4444(c) (((unsigned)(c) >> SK_B4444_SHIFT) & 0xF)
|
365
|
-
|
366
|
-
#define SkPacked4444ToA32(c) SkReplicateNibble(SkGetPackedA4444(c))
|
367
|
-
|
368
|
-
static inline SkPMColor SkPixel4444ToPixel32(U16CPU c) {
|
369
|
-
uint32_t d = (SkGetPackedA4444(c) << SK_A32_SHIFT) |
|
370
|
-
(SkGetPackedR4444(c) << SK_R32_SHIFT) |
|
371
|
-
(SkGetPackedG4444(c) << SK_G32_SHIFT) |
|
372
|
-
(SkGetPackedB4444(c) << SK_B32_SHIFT);
|
373
|
-
return d | (d << 4);
|
374
|
-
}
|
375
|
-
|
376
|
-
using SkPMColor4f = SkRGBA4f<kPremul_SkAlphaType>;
|
377
|
-
|
378
|
-
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT = { 0, 0, 0, 0 };
|
379
|
-
constexpr SkPMColor4f SK_PMColor4fBLACK = { 0, 0, 0, 1 };
|
380
|
-
constexpr SkPMColor4f SK_PMColor4fWHITE = { 1, 1, 1, 1 };
|
381
|
-
constexpr SkPMColor4f SK_PMColor4fILLEGAL = { SK_FloatNegativeInfinity,
|
382
|
-
SK_FloatNegativeInfinity,
|
383
|
-
SK_FloatNegativeInfinity,
|
384
|
-
SK_FloatNegativeInfinity };
|
385
|
-
#endif // SkColorData_DEFINED
|