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 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 /* | 55 /* |
56 * | 56 * |
57 * Checks if the result of decoding a row indicates that the row was | 57 * Checks if the result of decoding a row indicates that the row was |
58 * opaque. | 58 * opaque. |
59 * | 59 * |
60 */ | 60 */ |
61 static bool IsOpaque(ResultAlpha r) { | 61 static bool IsOpaque(ResultAlpha r) { |
62 return kOpaque_ResultAlpha == r; | 62 return kOpaque_ResultAlpha == r; |
63 } | 63 } |
64 | 64 |
65 /* | 65 /* |
66 * | 66 * |
67 * Constructs the proper result code based on accumulated alpha masks | 67 * Constructs the proper result code based on accumulated alpha masks |
68 * | 68 * |
69 */ | 69 */ |
70 static ResultAlpha GetResult(uint8_t zeroAlpha, uint8_t maxAlpha); | 70 static ResultAlpha GetResult(uint8_t zeroAlpha, uint8_t maxAlpha); |
71 | 71 |
72 /* | 72 /* |
73 * | 73 * |
74 * Returns bits per pixel for source config | 74 * Returns bits per pixel for source config |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 * @param dstRowBytes rowBytes for dst. | 121 * @param dstRowBytes rowBytes for dst. |
122 * @param ZeroInitialized Whether dst is zero-initialized. The | 122 * @param ZeroInitialized Whether dst is zero-initialized. The |
123 implementation may choose to skip writing zeroes | 123 implementation may choose to skip writing zeroes |
124 * if set to kYes_ZeroInitialized. | 124 * if set to kYes_ZeroInitialized. |
125 * @return A new SkSwizzler or NULL on failure. | 125 * @return A new SkSwizzler or NULL on failure. |
126 */ | 126 */ |
127 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, | 127 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, |
128 const SkImageInfo&, void* dst, | 128 const SkImageInfo&, void* dst, |
129 size_t dstRowBytes, | 129 size_t dstRowBytes, |
130 SkImageGenerator::ZeroInitialized); | 130 SkImageGenerator::ZeroInitialized); |
| 131 |
| 132 /** |
| 133 * Fill the remainder of the destination with a single color |
| 134 * |
| 135 * @param y |
| 136 * The starting row for the fill. |
| 137 * |
| 138 * @param colorOrIndex |
| 139 * @param colorTable |
| 140 * If dstInfo.colorType() is kIndex8, colorOrIndex is assumed to be a uint8_
t |
| 141 * index, and colorTable is ignored. Each 8-bit pixel will be set to (uint8_
t) |
| 142 * index. |
| 143 * |
| 144 * If dstInfo.colorType() is kN32, colorOrIndex is treated differently depen
ding on |
| 145 * whether colorTable is NULL: |
| 146 * |
| 147 * A NULL colorTable means colorOrIndex is treated as an SkPMColor (premul o
r |
| 148 * unpremul, depending on dstInfo.alphaType()). Each 4-byte pixel will be se
t to |
| 149 * colorOrIndex. |
| 150 |
| 151 * A non-NULL colorTable means colorOrIndex is treated as a uint8_t index in
to |
| 152 * the colorTable. i.e. each 4-byte pixel will be set to |
| 153 * colorTable[(uint8_t) colorOrIndex]. |
| 154 * |
| 155 * Other SkColorTypes are not supported. |
| 156 * |
| 157 */ |
| 158 static void Fill(void* dst, const SkImageInfo& dstInfo, size_t dstRowBytes,
uint32_t y, |
| 159 uint32_t colorOrIndex, SkPMColor* colorTable); |
| 160 |
131 /** | 161 /** |
132 * Swizzle the next line. Call height times, once for each row of source. | 162 * Swizzle the next line. Call height times, once for each row of source. |
133 * @param src The next row of the source data. | 163 * @param src The next row of the source data. |
134 * @return A result code describing if the row was fully opaque, fully | 164 * @return A result code describing if the row was fully opaque, fully |
135 * transparent, or neither | 165 * transparent, or neither |
136 */ | 166 */ |
137 ResultAlpha next(const uint8_t* SK_RESTRICT src); | 167 ResultAlpha next(const uint8_t* SK_RESTRICT src); |
138 | 168 |
139 /** | 169 /** |
140 * | 170 * |
141 * Alternate version of next that allows the caller to specify the row. | 171 * Alternate version of next that allows the caller to specify the row. |
142 * It is very important to only use one version of next. Since the other | 172 * It is very important to only use one version of next. Since the other |
143 * version modifies the dst pointer, it will change the behavior of this | 173 * version modifies the dst pointer, it will change the behavior of this |
144 * function. We will check this in Debug mode. | 174 * function. We will check this in Debug mode. |
145 * | 175 * |
146 */ | 176 */ |
147 ResultAlpha next(const uint8_t* SK_RESTRICT src, int y); | 177 ResultAlpha next(const uint8_t* SK_RESTRICT src, int y); |
148 | 178 |
149 /** | 179 /** |
150 * Update the destination row. | 180 * Update the destination row. |
151 * | 181 * |
152 * Typically this is done by next, but for a client that wants to manually | 182 * Typically this is done by next, but for a client that wants to manually |
153 * modify the destination row (for example, for decoding scanline one at a | 183 * modify the destination row (for example, for decoding scanline one at a |
154 * time) they can call this before each call to next. | 184 * time) they can call this before each call to next. |
155 * TODO: Maybe replace this with a version of next which allows supplying t
he | 185 * TODO: Maybe replace this with a version of next which allows supplying t
he |
156 * destination? | 186 * destination? |
157 */ | 187 */ |
158 void setDstRow(void* dst) { fDstRow = dst; } | 188 void setDstRow(void* dst) { fDstRow = dst; } |
| 189 |
159 private: | 190 private: |
160 | 191 |
161 #ifdef SK_DEBUG | 192 #ifdef SK_DEBUG |
162 /* | 193 /* |
163 * | 194 * |
164 * Keep track of which version of next the caller is using | 195 * Keep track of which version of next the caller is using |
165 * | 196 * |
166 */ | 197 */ |
167 enum NextMode { | 198 enum NextMode { |
168 kUninitialized_NextMode, | 199 kUninitialized_NextMode, |
(...skipping 28 matching lines...) Expand all Loading... |
197 const SkImageInfo fDstInfo; | 228 const SkImageInfo fDstInfo; |
198 void* fDstRow; | 229 void* fDstRow; |
199 const size_t fDstRowBytes; | 230 const size_t fDstRowBytes; |
200 int fCurrY; | 231 int fCurrY; |
201 | 232 |
202 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, | 233 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, |
203 const SkImageInfo& info, void* dst, size_t rowBytes); | 234 const SkImageInfo& info, void* dst, size_t rowBytes); |
204 | 235 |
205 }; | 236 }; |
206 #endif // SkSwizzler_DEFINED | 237 #endif // SkSwizzler_DEFINED |
OLD | NEW |