OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkSwizzler_DEFINED | 8 #ifndef SkSwizzler_DEFINED |
9 #define SkSwizzler_DEFINED | 9 #define SkSwizzler_DEFINED |
10 | 10 |
11 #include "SkCodec.h" | 11 #include "SkCodec.h" |
12 #include "SkColor.h" | 12 #include "SkColor.h" |
13 #include "SkImageInfo.h" | 13 #include "SkImageInfo.h" |
14 #include "SkSampler.h" | 14 #include "SkSampler.h" |
15 | 15 |
16 class SkSwizzler : public SkSampler { | 16 class SkSwizzler : public SkSampler { |
17 public: | 17 public: |
18 /** | 18 /** |
19 * Enum describing the config of the source data. | 19 * Enum describing the config of the source data. |
20 */ | 20 */ |
21 enum SrcConfig { | 21 enum SrcConfig { |
22 kUnknown, // Invalid type. | 22 kUnknown, // Invalid type. |
23 kBit, // A single bit to distinguish between white and black. | 23 kBit, // A single bit to distinguish between white and black. |
24 kGray, | 24 kGray, |
| 25 kGrayAlpha, |
25 kIndex1, | 26 kIndex1, |
26 kIndex2, | 27 kIndex2, |
27 kIndex4, | 28 kIndex4, |
28 kIndex, | 29 kIndex, |
29 kRGB, | 30 kRGB, |
30 kBGR, | 31 kBGR, |
31 kBGRX, // The alpha channel can be anything, but the image is opaque
. | 32 kBGRX, // The alpha channel can be anything, but the image is opaque
. |
32 kRGBA, | 33 kRGBA, |
33 kBGRA, | 34 kBGRA, |
34 kCMYK, | 35 kCMYK, |
(...skipping 13 matching lines...) Expand all Loading... |
48 case kIndex1: | 49 case kIndex1: |
49 return 1; | 50 return 1; |
50 case kIndex2: | 51 case kIndex2: |
51 return 2; | 52 return 2; |
52 case kIndex4: | 53 case kIndex4: |
53 return 4; | 54 return 4; |
54 case kGray: | 55 case kGray: |
55 case kIndex: | 56 case kIndex: |
56 case kNoOp8: | 57 case kNoOp8: |
57 return 8; | 58 return 8; |
| 59 case kGrayAlpha: |
58 case kNoOp16: | 60 case kNoOp16: |
59 return 16; | 61 return 16; |
60 case kRGB: | 62 case kRGB: |
61 case kBGR: | 63 case kBGR: |
62 return 24; | 64 return 24; |
63 case kRGBA: | 65 case kRGBA: |
64 case kBGRX: | 66 case kBGRX: |
65 case kBGRA: | 67 case kBGRA: |
66 case kCMYK: | 68 case kCMYK: |
67 case kNoOp32: | 69 case kNoOp32: |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 const uint8_t* SK_RESTRICT src, | 157 const uint8_t* SK_RESTRICT src, |
156 int dstWidth, int bpp, int deltaSrc, int offset, | 158 int dstWidth, int bpp, int deltaSrc, int offset, |
157 const SkPMColor ctable[]); | 159 const SkPMColor ctable[]); |
158 | 160 |
159 template <RowProc Proc> | 161 template <RowProc Proc> |
160 static void SkipLeading8888ZerosThen(void* SK_RESTRICT dstRow, | 162 static void SkipLeading8888ZerosThen(void* SK_RESTRICT dstRow, |
161 const uint8_t* SK_RESTRICT src, | 163 const uint8_t* SK_RESTRICT src, |
162 int dstWidth, int bpp, int deltaSrc, in
t offset, | 164 int dstWidth, int bpp, int deltaSrc, in
t offset, |
163 const SkPMColor ctable[]); | 165 const SkPMColor ctable[]); |
164 | 166 |
| 167 template <RowProc Proc> |
| 168 static void SkipLeadingGrayAlphaZerosThen(void* dst, const uint8_t* src, int
width, int bpp, |
| 169 int deltaSrc, int offset, const Sk
PMColor ctable[]); |
| 170 |
165 // May be NULL. We have not implemented optimized functions for all support
ed transforms. | 171 // May be NULL. We have not implemented optimized functions for all support
ed transforms. |
166 const RowProc fFastProc; | 172 const RowProc fFastProc; |
167 // Always non-NULL. Supports sampling. | 173 // Always non-NULL. Supports sampling. |
168 const RowProc fSlowProc; | 174 const RowProc fSlowProc; |
169 // The actual RowProc we are using. This depends on if fFastProc is non-NUL
L and | 175 // The actual RowProc we are using. This depends on if fFastProc is non-NUL
L and |
170 // whether or not we are sampling. | 176 // whether or not we are sampling. |
171 RowProc fActualProc; | 177 RowProc fActualProc; |
172 | 178 |
173 const SkPMColor* fColorTable; // Unowned pointer | 179 const SkPMColor* fColorTable; // Unowned pointer |
174 | 180 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // fBPP is bitsPerPixel | 262 // fBPP is bitsPerPixel |
257 const int fDstBPP; // Bytes per pixel for the destination
color type | 263 const int fDstBPP; // Bytes per pixel for the destination
color type |
258 | 264 |
259 SkSwizzler(RowProc fastProc, RowProc proc, const SkPMColor* ctable, int srcO
ffset, | 265 SkSwizzler(RowProc fastProc, RowProc proc, const SkPMColor* ctable, int srcO
ffset, |
260 int srcWidth, int dstOffset, int dstWidth, int srcBPP, int dstBPP); | 266 int srcWidth, int dstOffset, int dstWidth, int srcBPP, int dstBPP); |
261 | 267 |
262 int onSetSampleX(int) override; | 268 int onSetSampleX(int) override; |
263 | 269 |
264 }; | 270 }; |
265 #endif // SkSwizzler_DEFINED | 271 #endif // SkSwizzler_DEFINED |
OLD | NEW |