@shopify/react-native-skia 2.0.0-next.2 → 2.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/android/build.gradle +14 -10
  2. package/cpp/api/JsiSkCanvas.h +45 -2
  3. package/cpp/api/recorder/Drawings.h +31 -2
  4. package/cpp/api/recorder/Shaders.h +40 -0
  5. package/cpp/skia/include/codec/SkCodec.h +39 -1
  6. package/cpp/skia/include/config/SkUserConfig.h +1 -10
  7. package/cpp/skia/include/core/SkCanvas.h +8 -4
  8. package/cpp/skia/include/core/SkContourMeasure.h +2 -2
  9. package/cpp/skia/include/core/SkMilestone.h +1 -1
  10. package/cpp/skia/include/core/SkPaint.h +8 -5
  11. package/cpp/skia/include/core/SkStream.h +8 -3
  12. package/cpp/skia/include/core/SkTextBlob.h +9 -9
  13. package/cpp/skia/include/core/SkTypeface.h +4 -6
  14. package/cpp/skia/include/core/SkTypes.h +5 -0
  15. package/cpp/skia/include/docs/SkPDFDocument.h +47 -2
  16. package/cpp/skia/include/docs/SkPDFJpegHelpers.h +41 -0
  17. package/cpp/skia/include/effects/SkRuntimeEffect.h +5 -1
  18. package/cpp/skia/include/effects/SkTableMaskFilter.h +4 -0
  19. package/cpp/skia/include/gpu/graphite/BackendTexture.h +0 -2
  20. package/cpp/skia/include/gpu/graphite/ContextOptions.h +17 -0
  21. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +21 -18
  22. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +24 -0
  23. package/cpp/skia/include/gpu/graphite/TextureInfo.h +87 -42
  24. package/cpp/skia/include/gpu/graphite/YUVABackendTextures.h +13 -4
  25. package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +9 -0
  26. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +166 -0
  27. package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +3 -141
  28. package/cpp/skia/include/gpu/graphite/dawn/DawnUtils.h +2 -21
  29. package/cpp/skia/include/gpu/graphite/mtl/MtlBackendContext.h +4 -0
  30. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +30 -6
  31. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +4 -42
  32. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes_cpp.h +50 -0
  33. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteUtils.h +2 -20
  34. package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +14 -4
  35. package/cpp/skia/include/gpu/graphite/precompile/PrecompileShader.h +14 -6
  36. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteContext.h +31 -0
  37. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +36 -14
  38. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteUtils.h +3 -21
  39. package/cpp/skia/include/ports/SkTypeface_fontations.h +3 -0
  40. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +7 -0
  41. package/cpp/skia/include/private/base/SkAnySubclass.h +6 -0
  42. package/cpp/skia/include/private/chromium/SkPMColor.h +38 -0
  43. package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -2
  44. package/cpp/skia/modules/skunicode/include/SkUnicode.h +10 -6
  45. package/cpp/skia/modules/svg/include/SkSVGDOM.h +1 -3
  46. package/cpp/skia/src/base/SkTInternalLList.h +1 -1
  47. package/cpp/skia/src/core/SkLRUCache.h +6 -3
  48. package/lib/commonjs/external/reanimated/textures.d.ts +2 -4
  49. package/lib/commonjs/external/reanimated/textures.js +8 -15
  50. package/lib/commonjs/external/reanimated/textures.js.map +1 -1
  51. package/lib/commonjs/renderer/Canvas.d.ts +1 -2
  52. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  53. package/lib/commonjs/sksg/HostConfig.js +2 -1
  54. package/lib/commonjs/sksg/HostConfig.js.map +1 -1
  55. package/lib/commonjs/sksg/Recorder/Player.d.ts +1 -1
  56. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  57. package/lib/commonjs/sksg/Recorder/commands/Box.js +2 -2
  58. package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -1
  59. package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +1 -3
  60. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +1 -58
  61. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  62. package/lib/module/external/reanimated/textures.d.ts +2 -4
  63. package/lib/module/external/reanimated/textures.js +7 -12
  64. package/lib/module/external/reanimated/textures.js.map +1 -1
  65. package/lib/module/renderer/Canvas.d.ts +1 -2
  66. package/lib/module/renderer/Canvas.js.map +1 -1
  67. package/lib/module/sksg/HostConfig.js +2 -1
  68. package/lib/module/sksg/HostConfig.js.map +1 -1
  69. package/lib/module/sksg/Recorder/Player.d.ts +1 -1
  70. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  71. package/lib/module/sksg/Recorder/commands/Box.js +2 -2
  72. package/lib/module/sksg/Recorder/commands/Box.js.map +1 -1
  73. package/lib/module/sksg/Recorder/commands/Drawing.d.ts +1 -3
  74. package/lib/module/sksg/Recorder/commands/Drawing.js +2 -58
  75. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  76. package/lib/typescript/lib/commonjs/external/reanimated/textures.d.ts +1 -3
  77. package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -1
  78. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +0 -1
  79. package/lib/typescript/lib/module/external/reanimated/textures.d.ts +1 -3
  80. package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -1
  81. package/lib/typescript/lib/module/sksg/Recorder/commands/Drawing.d.ts +0 -1
  82. package/lib/typescript/src/external/reanimated/textures.d.ts +2 -4
  83. package/lib/typescript/src/renderer/Canvas.d.ts +1 -2
  84. package/lib/typescript/src/sksg/Recorder/Player.d.ts +1 -1
  85. package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +1 -3
  86. package/libs/android/arm64-v8a/libskia.a +0 -0
  87. package/libs/android/arm64-v8a/libskottie.a +0 -0
  88. package/libs/android/arm64-v8a/libskparagraph.a +0 -0
  89. package/libs/android/arm64-v8a/libsksg.a +0 -0
  90. package/libs/android/arm64-v8a/libskshaper.a +0 -0
  91. package/libs/android/arm64-v8a/libskunicode_icu.a +0 -0
  92. package/libs/android/arm64-v8a/libsvg.a +0 -0
  93. package/libs/android/armeabi-v7a/libskia.a +0 -0
  94. package/libs/android/armeabi-v7a/libskottie.a +0 -0
  95. package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
  96. package/libs/android/armeabi-v7a/libsksg.a +0 -0
  97. package/libs/android/armeabi-v7a/libskshaper.a +0 -0
  98. package/libs/android/armeabi-v7a/libskunicode_icu.a +0 -0
  99. package/libs/android/armeabi-v7a/libsvg.a +0 -0
  100. package/libs/android/x86/libskia.a +0 -0
  101. package/libs/android/x86/libskottie.a +0 -0
  102. package/libs/android/x86/libskparagraph.a +0 -0
  103. package/libs/android/x86/libsksg.a +0 -0
  104. package/libs/android/x86/libskshaper.a +0 -0
  105. package/libs/android/x86/libskunicode_icu.a +0 -0
  106. package/libs/android/x86/libsvg.a +0 -0
  107. package/libs/android/x86_64/libskia.a +0 -0
  108. package/libs/android/x86_64/libskottie.a +0 -0
  109. package/libs/android/x86_64/libskparagraph.a +0 -0
  110. package/libs/android/x86_64/libsksg.a +0 -0
  111. package/libs/android/x86_64/libskshaper.a +0 -0
  112. package/libs/android/x86_64/libskunicode_icu.a +0 -0
  113. package/libs/android/x86_64/libsvg.a +0 -0
  114. package/libs/apple/libskia.xcframework/Info.plist +15 -15
  115. package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  116. package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  117. package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
  118. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
  119. package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  120. package/libs/apple/libskottie.xcframework/Info.plist +7 -7
  121. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  122. package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  123. package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
  124. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
  125. package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  126. package/libs/apple/libskparagraph.xcframework/Info.plist +13 -13
  127. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  128. package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  129. package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
  130. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
  131. package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  132. package/libs/apple/libsksg.xcframework/Info.plist +13 -13
  133. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  134. package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  135. package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
  136. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
  137. package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  138. package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
  139. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  140. package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  141. package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
  142. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
  143. package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  144. package/libs/apple/libskunicode_core.xcframework/Info.plist +12 -12
  145. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
  146. package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  147. package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
  148. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
  149. package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
  150. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +15 -15
  151. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  152. package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  153. package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
  154. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
  155. package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
  156. package/libs/apple/libsvg.xcframework/Info.plist +8 -8
  157. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  158. package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  159. package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
  160. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
  161. package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  162. package/package.json +3 -3
  163. package/src/__tests__/snapshots/box/box-shadow-opacity.png +0 -0
  164. package/src/__tests__/snapshots/platform-buffer.png +0 -0
  165. package/src/__tests__/snapshots/screens/snapshot2-android-ci.png +0 -0
  166. package/src/external/reanimated/textures.tsx +12 -20
  167. package/src/renderer/Canvas.tsx +1 -1
  168. package/src/renderer/__tests__/e2e/Box.spec.tsx +22 -0
  169. package/src/renderer/__tests__/e2e/NativeBuffer.spec.tsx +2 -0
  170. package/src/sksg/HostConfig.ts +2 -1
  171. package/src/sksg/Recorder/Player.ts +1 -1
  172. package/src/sksg/Recorder/commands/Box.ts +2 -2
  173. package/src/sksg/Recorder/commands/Drawing.ts +0 -65
  174. package/cpp/skia/include/core/SkColorPriv.h +0 -165
  175. package/cpp/skia/include/private/SkColorData.h +0 -385
@@ -45,8 +45,8 @@ import {
45
45
  isDrawCommand,
46
46
  isGroup,
47
47
  materializeCommand,
48
- type Command,
49
48
  } from "./Core";
49
+ import type { Command } from "./Core";
50
50
  import type { DrawingContext } from "./DrawingContext";
51
51
 
52
52
  function play(ctx: DrawingContext, _command: Command) {
@@ -30,7 +30,7 @@ export const drawBox = (ctx: DrawingContext, command: BoxCommand) => {
30
30
  const { color = "black", blur, spread = 0, dx = 0, dy = 0 } = shadow;
31
31
  const lPaint = Skia.Paint();
32
32
  lPaint.setColor(processColor(Skia, color));
33
- lPaint.setAlphaf(paint.getAlphaf() * opacity);
33
+ lPaint.setAlphaf(lPaint.getAlphaf() * opacity);
34
34
  lPaint.setMaskFilter(
35
35
  Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)
36
36
  );
@@ -48,7 +48,7 @@ export const drawBox = (ctx: DrawingContext, command: BoxCommand) => {
48
48
  canvas.clipRRect(box, ClipOp.Intersect, false);
49
49
  const lPaint = Skia.Paint();
50
50
  lPaint.setColor(Skia.Color(color));
51
- lPaint.setAlphaf(paint.getAlphaf() * opacity);
51
+ lPaint.setAlphaf(lPaint.getAlphaf() * opacity);
52
52
 
53
53
  lPaint.setMaskFilter(
54
54
  Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)
@@ -1,9 +1,6 @@
1
1
  import {
2
- deflate,
3
2
  enumKey,
4
3
  fitRects,
5
- inflate,
6
- NodeType,
7
4
  processCircle,
8
5
  processColor,
9
6
  processPath,
@@ -12,8 +9,6 @@ import {
12
9
  } from "../../../dom/nodes";
13
10
  import type {
14
11
  AtlasProps,
15
- BoxProps,
16
- BoxShadowProps,
17
12
  CircleProps,
18
13
  DiffRectProps,
19
14
  DrawingNodeProps,
@@ -38,18 +33,13 @@ import { saturate } from "../../../renderer/processors";
38
33
  import type { SkPoint, SkRSXform } from "../../../skia/types";
39
34
  import {
40
35
  BlendMode,
41
- BlurStyle,
42
- ClipOp,
43
36
  FillType,
44
37
  FilterMode,
45
38
  isCubicSampling,
46
- isRRect,
47
39
  MipmapMode,
48
40
  PointMode,
49
41
  VertexMode,
50
42
  } from "../../../skia/types";
51
- import type { Node } from "../../Node";
52
- import { materialize } from "../../utils";
53
43
  import type { DrawingContext } from "../DrawingContext";
54
44
 
55
45
  export const drawLine = (ctx: DrawingContext, props: LineProps) => {
@@ -64,61 +54,6 @@ export const drawOval = (ctx: DrawingContext, props: OvalProps) => {
64
54
  ctx.canvas.drawOval(rect, ctx.paint);
65
55
  };
66
56
 
67
- export const drawBox = (
68
- ctx: DrawingContext,
69
- props: BoxProps,
70
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
- children: Node<any>[]
72
- ) => {
73
- "worklet";
74
- const { paint, Skia, canvas } = ctx;
75
- const { box: defaultBox } = props;
76
- const opacity = paint.getAlphaf();
77
- const box = isRRect(defaultBox) ? defaultBox : Skia.RRectXY(defaultBox, 0, 0);
78
- const shadows = children
79
- .map((node) => {
80
- if (node.type === NodeType.BoxShadow) {
81
- return materialize(node.props);
82
- }
83
- return null;
84
- })
85
- .filter((n): n is BoxShadowProps => n !== null);
86
- shadows
87
- .filter((shadow) => !shadow.inner)
88
- .map((shadow) => {
89
- const { color = "black", blur, spread = 0, dx = 0, dy = 0 } = shadow;
90
- const lPaint = Skia.Paint();
91
- lPaint.setColor(processColor(Skia, color));
92
- lPaint.setAlphaf(paint.getAlphaf() * opacity);
93
- lPaint.setMaskFilter(
94
- Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)
95
- );
96
- canvas.drawRRect(inflate(Skia, box, spread, spread, dx, dy), lPaint);
97
- });
98
-
99
- canvas.drawRRect(box, paint);
100
-
101
- shadows
102
- .filter((shadow) => shadow.inner)
103
- .map((shadow) => {
104
- const { color = "black", blur, spread = 0, dx = 0, dy = 0 } = shadow;
105
- const delta = Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));
106
- canvas.save();
107
- canvas.clipRRect(box, ClipOp.Intersect, false);
108
- const lPaint = Skia.Paint();
109
- lPaint.setColor(processColor(Skia, color));
110
- lPaint.setAlphaf(paint.getAlphaf() * opacity);
111
-
112
- lPaint.setMaskFilter(
113
- Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)
114
- );
115
- const inner = deflate(Skia, box, spread, spread, dx, dy);
116
- const outer = inflate(Skia, box, delta.x, delta.y);
117
- canvas.drawDRRect(outer, inner, lPaint);
118
- canvas.restore();
119
- });
120
- };
121
-
122
57
  export const drawImage = (ctx: DrawingContext, props: ImageProps) => {
123
58
  "worklet";
124
59
  const { image, sampling } = props;
@@ -1,165 +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 SkColorPriv_DEFINED
9
- #define SkColorPriv_DEFINED
10
-
11
- #include "include/core/SkColor.h"
12
- #include "include/private/base/SkMath.h"
13
- #include "include/private/base/SkTPin.h"
14
- #include "include/private/base/SkTo.h"
15
-
16
- #include <algorithm>
17
-
18
- /** Turn 0..255 into 0..256 by adding 1 at the half-way point. Used to turn a
19
- byte into a scale value, so that we can say scale * value >> 8 instead of
20
- alpha * value / 255.
21
-
22
- In debugging, asserts that alpha is 0..255
23
- */
24
- static inline unsigned SkAlpha255To256(U8CPU alpha) {
25
- SkASSERT(SkToU8(alpha) == alpha);
26
- // this one assues that blending on top of an opaque dst keeps it that way
27
- // even though it is less accurate than a+(a>>7) for non-opaque dsts
28
- return alpha + 1;
29
- }
30
-
31
- /** Multiplify value by 0..256, and shift the result down 8
32
- (i.e. return (value * alpha256) >> 8)
33
- */
34
- #define SkAlphaMul(value, alpha256) (((value) * (alpha256)) >> 8)
35
-
36
- static inline U8CPU SkUnitScalarClampToByte(SkScalar x) {
37
- return static_cast<U8CPU>(SkTPin(x, 0.0f, 1.0f) * 255 + 0.5);
38
- }
39
-
40
- #define SK_A32_BITS 8
41
- #define SK_R32_BITS 8
42
- #define SK_G32_BITS 8
43
- #define SK_B32_BITS 8
44
-
45
- #define SK_A32_MASK ((1 << SK_A32_BITS) - 1)
46
- #define SK_R32_MASK ((1 << SK_R32_BITS) - 1)
47
- #define SK_G32_MASK ((1 << SK_G32_BITS) - 1)
48
- #define SK_B32_MASK ((1 << SK_B32_BITS) - 1)
49
-
50
- /*
51
- * Skia's 32bit backend only supports 1 swizzle order at a time (compile-time).
52
- * This is specified by SK_R32_SHIFT=0 or SK_R32_SHIFT=16.
53
- *
54
- * For easier compatibility with Skia's GPU backend, we further restrict these
55
- * to either (in memory-byte-order) RGBA or BGRA. Note that this "order" does
56
- * not directly correspond to the same shift-order, since we have to take endianess
57
- * into account.
58
- *
59
- * Here we enforce this constraint.
60
- */
61
-
62
- #define SK_RGBA_R32_SHIFT 0
63
- #define SK_RGBA_G32_SHIFT 8
64
- #define SK_RGBA_B32_SHIFT 16
65
- #define SK_RGBA_A32_SHIFT 24
66
-
67
- #define SK_BGRA_B32_SHIFT 0
68
- #define SK_BGRA_G32_SHIFT 8
69
- #define SK_BGRA_R32_SHIFT 16
70
- #define SK_BGRA_A32_SHIFT 24
71
-
72
- #if defined(SK_PMCOLOR_IS_RGBA) || defined(SK_PMCOLOR_IS_BGRA)
73
- #error "Configure PMCOLOR by setting SK_R32_SHIFT."
74
- #endif
75
-
76
- // Deduce which SK_PMCOLOR_IS_ to define from the _SHIFT defines
77
-
78
- #if (SK_A32_SHIFT == SK_RGBA_A32_SHIFT && \
79
- SK_R32_SHIFT == SK_RGBA_R32_SHIFT && \
80
- SK_G32_SHIFT == SK_RGBA_G32_SHIFT && \
81
- SK_B32_SHIFT == SK_RGBA_B32_SHIFT)
82
- #define SK_PMCOLOR_IS_RGBA
83
- #elif (SK_A32_SHIFT == SK_BGRA_A32_SHIFT && \
84
- SK_R32_SHIFT == SK_BGRA_R32_SHIFT && \
85
- SK_G32_SHIFT == SK_BGRA_G32_SHIFT && \
86
- SK_B32_SHIFT == SK_BGRA_B32_SHIFT)
87
- #define SK_PMCOLOR_IS_BGRA
88
- #else
89
- #error "need 32bit packing to be either RGBA or BGRA"
90
- #endif
91
-
92
- #define SkGetPackedA32(packed) ((uint32_t)((packed) << (24 - SK_A32_SHIFT)) >> 24)
93
- #define SkGetPackedR32(packed) ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24)
94
- #define SkGetPackedG32(packed) ((uint32_t)((packed) << (24 - SK_G32_SHIFT)) >> 24)
95
- #define SkGetPackedB32(packed) ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24)
96
-
97
- #define SkA32Assert(a) SkASSERT((unsigned)(a) <= SK_A32_MASK)
98
- #define SkR32Assert(r) SkASSERT((unsigned)(r) <= SK_R32_MASK)
99
- #define SkG32Assert(g) SkASSERT((unsigned)(g) <= SK_G32_MASK)
100
- #define SkB32Assert(b) SkASSERT((unsigned)(b) <= SK_B32_MASK)
101
-
102
- /**
103
- * Pack the components into a SkPMColor
104
- */
105
- static inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
106
- SkA32Assert(a);
107
- SkR32Assert(r);
108
- SkG32Assert(g);
109
- SkB32Assert(b);
110
-
111
- return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) |
112
- (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
113
- }
114
-
115
- /**
116
- * Legacy "NoCheck" version of SkPackARGB32. Remove this once all callers are updated.
117
- */
118
- static inline SkPMColor SkPackARGB32NoCheck(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
119
- return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) |
120
- (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
121
- }
122
-
123
- static inline
124
- SkPMColor SkPremultiplyARGBInline(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
125
- SkA32Assert(a);
126
- SkR32Assert(r);
127
- SkG32Assert(g);
128
- SkB32Assert(b);
129
-
130
- if (a != 255) {
131
- r = SkMulDiv255Round(r, a);
132
- g = SkMulDiv255Round(g, a);
133
- b = SkMulDiv255Round(b, a);
134
- }
135
- return SkPackARGB32(a, r, g, b);
136
- }
137
-
138
- // When Android is compiled optimizing for size, SkAlphaMulQ doesn't get
139
- // inlined; forcing inlining significantly improves performance.
140
- static SK_ALWAYS_INLINE uint32_t SkAlphaMulQ(uint32_t c, unsigned scale) {
141
- uint32_t mask = 0xFF00FF;
142
-
143
- uint32_t rb = ((c & mask) * scale) >> 8;
144
- uint32_t ag = ((c >> 8) & mask) * scale;
145
- return (rb & mask) | (ag & ~mask);
146
- }
147
-
148
- static inline SkPMColor SkPMSrcOver(SkPMColor src, SkPMColor dst) {
149
- uint32_t scale = SkAlpha255To256(255 - SkGetPackedA32(src));
150
-
151
- uint32_t mask = 0xFF00FF;
152
- uint32_t rb = (((dst & mask) * scale) >> 8) & mask;
153
- uint32_t ag = (((dst >> 8) & mask) * scale) & ~mask;
154
-
155
- rb += (src & mask);
156
- ag += (src & ~mask);
157
-
158
- // Color channels (but not alpha) can overflow, so we have to saturate to 0xFF in each lane.
159
- return std::min(rb & 0x000001FF, 0x000000FFU) |
160
- std::min(ag & 0x0001FF00, 0x0000FF00U) |
161
- std::min(rb & 0x01FF0000, 0x00FF0000U) |
162
- (ag & 0xFF000000);
163
- }
164
-
165
- #endif
@@ -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