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 kIndex1, | 25 kIndex1, |
26 kIndex2, | 26 kIndex2, |
27 kIndex4, | 27 kIndex4, |
28 kIndex, | 28 kIndex, |
29 kRGB, | 29 kRGB, |
30 kBGR, | 30 kBGR, |
31 kRGBX, | 31 kBGRX, // The alpha channel can be anything, but the image is opaque
. |
32 kBGRX, | |
33 kRGBA, | 32 kRGBA, |
34 kBGRA, | 33 kBGRA, |
35 kRGB_565, | |
36 kCMYK, | 34 kCMYK, |
| 35 kNoOp8, // kNoOp modes are used exclusively for sampling, subsetting,
and |
| 36 kNoOp16, // copying. The pixels themselves do not need to be modified
. |
| 37 kNoOp32, |
37 }; | 38 }; |
38 | 39 |
39 /* | 40 /* |
40 * | 41 * |
41 * Returns bits per pixel for source config | 42 * Returns bits per pixel for source config |
42 * | 43 * |
43 */ | 44 */ |
44 static int BitsPerPixel(SrcConfig sc) { | 45 static int BitsPerPixel(SrcConfig sc) { |
45 switch (sc) { | 46 switch (sc) { |
46 case kBit: | 47 case kBit: |
47 case kIndex1: | 48 case kIndex1: |
48 return 1; | 49 return 1; |
49 case kIndex2: | 50 case kIndex2: |
50 return 2; | 51 return 2; |
51 case kIndex4: | 52 case kIndex4: |
52 return 4; | 53 return 4; |
53 case kGray: | 54 case kGray: |
54 case kIndex: | 55 case kIndex: |
| 56 case kNoOp8: |
55 return 8; | 57 return 8; |
56 case kRGB_565: | 58 case kNoOp16: |
57 return 16; | 59 return 16; |
58 case kRGB: | 60 case kRGB: |
59 case kBGR: | 61 case kBGR: |
60 return 24; | 62 return 24; |
61 case kRGBX: | |
62 case kRGBA: | 63 case kRGBA: |
63 case kBGRX: | 64 case kBGRX: |
64 case kBGRA: | 65 case kBGRA: |
65 case kCMYK: | 66 case kCMYK: |
| 67 case kNoOp32: |
66 return 32; | 68 return 32; |
67 default: | 69 default: |
68 SkASSERT(false); | 70 SkASSERT(false); |
69 return 0; | 71 return 0; |
70 } | 72 } |
71 } | 73 } |
72 | 74 |
73 /* | 75 /* |
74 * | 76 * |
75 * Returns bytes per pixel for source config | 77 * Returns bytes per pixel for source config |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // fBPP is bitsPerPixel | 252 // fBPP is bitsPerPixel |
251 const int fDstBPP; // Bytes per pixel for the destination
color type | 253 const int fDstBPP; // Bytes per pixel for the destination
color type |
252 | 254 |
253 SkSwizzler(RowProc fastProc, RowProc proc, const SkPMColor* ctable, int srcO
ffset, | 255 SkSwizzler(RowProc fastProc, RowProc proc, const SkPMColor* ctable, int srcO
ffset, |
254 int srcWidth, int dstOffset, int dstWidth, int srcBPP, int dstBPP); | 256 int srcWidth, int dstOffset, int dstWidth, int srcBPP, int dstBPP); |
255 | 257 |
256 int onSetSampleX(int) override; | 258 int onSetSampleX(int) override; |
257 | 259 |
258 }; | 260 }; |
259 #endif // SkSwizzler_DEFINED | 261 #endif // SkSwizzler_DEFINED |
OLD | NEW |