Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: src/codec/SkSwizzler.cpp

Issue 980903002: Option for SkCodec to treat dst as all zeroes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update SkBmpCodec to use new ZeroInitialized API. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | src/core/SkImageGenerator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "SkCodecPriv.h" 8 #include "SkCodecPriv.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkSwizzler.h" 10 #include "SkSwizzler.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 src += deltaSrc; 192 src += deltaSrc;
193 alphaMask &= alpha; 193 alphaMask &= alpha;
194 } 194 }
195 return alphaMask != 0xFF; 195 return alphaMask != 0xFF;
196 } 196 }
197 */ 197 */
198 198
199 SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc, 199 SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc,
200 const SkPMColor* ctable, 200 const SkPMColor* ctable,
201 const SkImageInfo& info, void* dst, 201 const SkImageInfo& info, void* dst,
202 size_t dstRowBytes, bool skipZeroes) { 202 size_t dstRowBytes,
203 SkImageGenerator::ZeroInitialized zeroIni t) {
203 if (kUnknown_SkColorType == info.colorType()) { 204 if (kUnknown_SkColorType == info.colorType()) {
204 return NULL; 205 return NULL;
205 } 206 }
206 if (info.minRowBytes() > dstRowBytes) { 207 if (info.minRowBytes() > dstRowBytes) {
207 return NULL; 208 return NULL;
208 } 209 }
209 if ((kIndex == sc || kIndex4 == sc || kIndex2 == sc || kIndex1 == sc) 210 if ((kIndex == sc || kIndex4 == sc || kIndex2 == sc || kIndex1 == sc)
210 && NULL == ctable) { 211 && NULL == ctable) {
211 return NULL; 212 return NULL;
212 } 213 }
213 RowProc proc = NULL; 214 RowProc proc = NULL;
214 switch (sc) { 215 switch (sc) {
215 case kIndex1: 216 case kIndex1:
216 case kIndex2: 217 case kIndex2:
217 case kIndex4: 218 case kIndex4:
218 switch (info.colorType()) { 219 switch (info.colorType()) {
219 case kN32_SkColorType: 220 case kN32_SkColorType:
220 proc = &swizzle_small_index_to_n32; 221 proc = &swizzle_small_index_to_n32;
221 break; 222 break;
222 default: 223 default:
223 break; 224 break;
224 } 225 }
225 break; 226 break;
226 case kIndex: 227 case kIndex:
227 switch (info.colorType()) { 228 switch (info.colorType()) {
228 case kN32_SkColorType: 229 case kN32_SkColorType:
229 if (skipZeroes) { 230 // We assume the color premultiplied ctable (or not) as desi red.
231 if (SkImageGenerator::kYes_ZeroInitialized == zeroInit) {
230 proc = &swizzle_index_to_n32_skipZ; 232 proc = &swizzle_index_to_n32_skipZ;
231 } else { 233 } else {
232 proc = &swizzle_index_to_n32; 234 proc = &swizzle_index_to_n32;
233 } 235 }
234 break; 236 break;
235 default: 237 default:
236 break; 238 break;
237 } 239 }
238 break; 240 break;
239 case kBGR: 241 case kBGR:
(...skipping 22 matching lines...) Expand all
262 proc = &swizzle_rgbx_to_n32; 264 proc = &swizzle_rgbx_to_n32;
263 break; 265 break;
264 default: 266 default:
265 break; 267 break;
266 } 268 }
267 break; 269 break;
268 case kRGBA: 270 case kRGBA:
269 switch (info.colorType()) { 271 switch (info.colorType()) {
270 case kN32_SkColorType: 272 case kN32_SkColorType:
271 if (info.alphaType() == kUnpremul_SkAlphaType) { 273 if (info.alphaType() == kUnpremul_SkAlphaType) {
272 // Respect skipZeroes? 274 // Respect zeroInit?
273 proc = &swizzle_rgba_to_n32_unpremul; 275 proc = &swizzle_rgba_to_n32_unpremul;
274 } else { 276 } else {
275 if (skipZeroes) { 277 if (SkImageGenerator::kYes_ZeroInitialized == zeroInit) {
276 proc = &swizzle_rgba_to_n32_premul_skipZ; 278 proc = &swizzle_rgba_to_n32_premul_skipZ;
277 } else { 279 } else {
278 proc = &swizzle_rgba_to_n32_premul; 280 proc = &swizzle_rgba_to_n32_premul;
279 } 281 }
280 } 282 }
281 break; 283 break;
282 default: 284 default:
283 break; 285 break;
284 } 286 }
285 break; 287 break;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 SkASSERT(kConsecutive_NextMode != fNextMode); 342 SkASSERT(kConsecutive_NextMode != fNextMode);
341 SkDEBUGCODE(fNextMode = kDesignateRow_NextMode); 343 SkDEBUGCODE(fNextMode = kDesignateRow_NextMode);
342 344
343 // Choose the row 345 // Choose the row
344 void* row = SkTAddOffset<void>(fDstRow, y*fDstRowBytes); 346 void* row = SkTAddOffset<void>(fDstRow, y*fDstRowBytes);
345 347
346 // Decode the row 348 // Decode the row
347 return fRowProc(row, src, fDstInfo.width(), fDeltaSrc, fCurrY, 349 return fRowProc(row, src, fDstInfo.width(), fDeltaSrc, fCurrY,
348 fColorTable); 350 fColorTable);
349 } 351 }
OLDNEW
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | src/core/SkImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698