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

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

Issue 1372973002: Move all knowledge of X sampling into SkScaledCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@codecSDmerge
Patch Set: Attempt to fix RLE overflow 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/SkSampler.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 334 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 // Get the sample size 355 return new SkMaskSwizzler(dstInfo.width(), masks, proc);
356 int sampleX;
357 SkScaledCodec::ComputeSampleSize(dstInfo, srcInfo, &sampleX, NULL);
358
359 return new SkMaskSwizzler(dstInfo, masks, proc, sampleX);
360 } 356 }
361 357
362 /* 358 /*
363 * 359 *
364 * Constructor for mask swizzler 360 * Constructor for mask swizzler
365 * 361 *
366 */ 362 */
367 SkMaskSwizzler::SkMaskSwizzler(const SkImageInfo& dstInfo, SkMasks* masks, 363 SkMaskSwizzler::SkMaskSwizzler(int width, SkMasks* masks, RowProc proc)
368 RowProc proc, uint32_t sampleX) 364 : fMasks(masks)
369 : fDstInfo(dstInfo)
370 , fMasks(masks)
371 , fRowProc(proc) 365 , fRowProc(proc)
372 , fSampleX(sampleX) 366 , fSrcWidth(width)
373 , fStartX(get_start_coord(sampleX)) 367 , fDstWidth(width)
368 , fSampleX(1)
369 , fX0(0)
374 {} 370 {}
375 371
372 int SkMaskSwizzler::onSetSampleX(int sampleX) {
373 // FIXME: Share this function with SkSwizzler?
374 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be
375 // way to report failure?
376 fSampleX = sampleX;
377 fX0 = get_start_coord(sampleX);
378 fDstWidth = get_scaled_dimension(fSrcWidth, sampleX);
379
380 // check that fX0 is less than original width
381 SkASSERT(fX0 >= 0 && fX0 < fSrcWidth);
382 return fDstWidth;
383 }
384
376 /* 385 /*
377 * 386 *
378 * Swizzle the specified row 387 * Swizzle the specified row
379 * 388 *
380 */ 389 */
381 SkSwizzler::ResultAlpha SkMaskSwizzler::swizzle(void* dst, const uint8_t* SK_RES TRICT src) { 390 SkSwizzler::ResultAlpha SkMaskSwizzler::swizzle(void* dst, const uint8_t* SK_RES TRICT src) {
382 SkASSERT(nullptr != dst && nullptr != src); 391 SkASSERT(nullptr != dst && nullptr != src);
383 return fRowProc(dst, src, fDstInfo.width(), fMasks, fStartX, fSampleX); 392 return fRowProc(dst, src, fDstWidth, fMasks, fX0, fSampleX);
384 } 393 }
OLDNEW
« no previous file with comments | « src/codec/SkMaskSwizzler.h ('k') | src/codec/SkSampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698