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

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

Issue 1390213002: Add subsetting to SkScanlineDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@fill-refactor
Patch Set: Response to comments Created 5 years, 2 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/SkMaskSwizzler.h ('k') | src/codec/SkSwizzler.h » ('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 "SkMaskSwizzler.h" 10 #include "SkMaskSwizzler.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 srcPtr += sampleX; 243 srcPtr += sampleX;
244 } 244 }
245 return SkSwizzler::kOpaque_ResultAlpha; 245 return SkSwizzler::kOpaque_ResultAlpha;
246 } 246 }
247 247
248 /* 248 /*
249 * 249 *
250 * Create a new mask swizzler 250 * Create a new mask swizzler
251 * 251 *
252 */ 252 */
253 SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler( 253 SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
254 const SkImageInfo& dstInfo, const SkImageInfo& srcInfo, SkMasks* masks, 254 const SkImageInfo& srcInfo, SkMasks* masks, uint32_t bitsPerPixel,
255 uint32_t bitsPerPixel) { 255 const SkCodec::Options& options) {
256 256
257 // Choose the appropriate row procedure 257 // Choose the appropriate row procedure
258 RowProc proc = nullptr; 258 RowProc proc = nullptr;
259 switch (bitsPerPixel) { 259 switch (bitsPerPixel) {
260 case 16: 260 case 16:
261 switch (dstInfo.colorType()) { 261 switch (dstInfo.colorType()) {
262 case kN32_SkColorType: 262 case kN32_SkColorType:
263 switch (dstInfo.alphaType()) { 263 switch (dstInfo.alphaType()) {
264 case kUnpremul_SkAlphaType: 264 case kUnpremul_SkAlphaType:
265 proc = &swizzle_mask16_to_n32_unpremul; 265 proc = &swizzle_mask16_to_n32_unpremul;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 break; 345 break;
346 default: 346 default:
347 break; 347 break;
348 } 348 }
349 break; 349 break;
350 default: 350 default:
351 SkASSERT(false); 351 SkASSERT(false);
352 return nullptr; 352 return nullptr;
353 } 353 }
354 354
355 return new SkMaskSwizzler(dstInfo.width(), masks, proc); 355 int srcOffset = 0;
356 int srcWidth = dstInfo.width();
357 if (options.fSubset) {
358 srcOffset = options.fSubset->left();
359 srcWidth = options.fSubset->width();
360 }
361
362 return new SkMaskSwizzler(masks, proc, srcOffset, srcWidth);
356 } 363 }
357 364
358 /* 365 /*
359 * 366 *
360 * Constructor for mask swizzler 367 * Constructor for mask swizzler
361 * 368 *
362 */ 369 */
363 SkMaskSwizzler::SkMaskSwizzler(int width, SkMasks* masks, RowProc proc) 370 SkMaskSwizzler::SkMaskSwizzler(SkMasks* masks, RowProc proc, int srcOffset, int srcWidth)
364 : fMasks(masks) 371 : fMasks(masks)
365 , fRowProc(proc) 372 , fRowProc(proc)
366 , fSrcWidth(width) 373 , fSrcWidth(srcWidth)
367 , fDstWidth(width) 374 , fDstWidth(srcWidth)
368 , fSampleX(1) 375 , fSampleX(1)
369 , fX0(0) 376 , fSrcOffset(srcOffset)
377 , fX0(srcOffset)
370 {} 378 {}
371 379
372 int SkMaskSwizzler::onSetSampleX(int sampleX) { 380 int SkMaskSwizzler::onSetSampleX(int sampleX) {
373 // FIXME: Share this function with SkSwizzler? 381 // FIXME: Share this function with SkSwizzler?
374 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be 382 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be
375 // way to report failure? 383 // way to report failure?
376 fSampleX = sampleX; 384 fSampleX = sampleX;
377 fX0 = get_start_coord(sampleX); 385 fX0 = get_start_coord(sampleX) + fSrcOffset;
378 fDstWidth = get_scaled_dimension(fSrcWidth, sampleX); 386 fDstWidth = get_scaled_dimension(fSrcWidth, sampleX);
379 387
380 // check that fX0 is less than original width 388 // check that fX0 is less than original width
381 SkASSERT(fX0 >= 0 && fX0 < fSrcWidth); 389 SkASSERT(fX0 >= 0 && fX0 < fSrcWidth);
382 return fDstWidth; 390 return fDstWidth;
383 } 391 }
384 392
385 /* 393 /*
386 * 394 *
387 * Swizzle the specified row 395 * Swizzle the specified row
388 * 396 *
389 */ 397 */
390 SkSwizzler::ResultAlpha SkMaskSwizzler::swizzle(void* dst, const uint8_t* SK_RES TRICT src) { 398 SkSwizzler::ResultAlpha SkMaskSwizzler::swizzle(void* dst, const uint8_t* SK_RES TRICT src) {
391 SkASSERT(nullptr != dst && nullptr != src); 399 SkASSERT(nullptr != dst && nullptr != src);
392 return fRowProc(dst, src, fDstWidth, fMasks, fX0, fSampleX); 400 return fRowProc(dst, src, fDstWidth, fMasks, fX0, fSampleX);
393 } 401 }
OLDNEW
« no previous file with comments | « src/codec/SkMaskSwizzler.h ('k') | src/codec/SkSwizzler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698