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

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

Issue 1407603003: Fix SkSwizzler bug (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added test and rebase 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 360 }
361 361
362 return new SkMaskSwizzler(masks, proc, srcOffset, srcWidth); 362 return new SkMaskSwizzler(masks, proc, srcOffset, srcWidth);
363 } 363 }
364 364
365 /* 365 /*
366 * 366 *
367 * Constructor for mask swizzler 367 * Constructor for mask swizzler
368 * 368 *
369 */ 369 */
370 SkMaskSwizzler::SkMaskSwizzler(SkMasks* masks, RowProc proc, int srcOffset, int srcWidth) 370 SkMaskSwizzler::SkMaskSwizzler(SkMasks* masks, RowProc proc, int srcOffset, int subsetWidth)
371 : fMasks(masks) 371 : fMasks(masks)
372 , fRowProc(proc) 372 , fRowProc(proc)
373 , fSrcWidth(srcWidth) 373 , fSubsetWidth(subsetWidth)
374 , fDstWidth(srcWidth) 374 , fDstWidth(subsetWidth)
375 , fSampleX(1) 375 , fSampleX(1)
376 , fSrcOffset(srcOffset) 376 , fSrcOffset(srcOffset)
377 , fX0(srcOffset) 377 , fX0(srcOffset)
378 {} 378 {}
379 379
380 int SkMaskSwizzler::onSetSampleX(int sampleX) { 380 int SkMaskSwizzler::onSetSampleX(int sampleX) {
381 // FIXME: Share this function with SkSwizzler? 381 // FIXME: Share this function with SkSwizzler?
382 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
383 // way to report failure? 383 // way to report failure?
384 fSampleX = sampleX; 384 fSampleX = sampleX;
385 fX0 = get_start_coord(sampleX) + fSrcOffset; 385 fX0 = get_start_coord(sampleX) + fSrcOffset;
386 fDstWidth = get_scaled_dimension(fSrcWidth, sampleX); 386 fDstWidth = get_scaled_dimension(fSubsetWidth, sampleX);
387 387
388 // check that fX0 is less than original width 388 // check that fX0 is valid
389 SkASSERT(fX0 >= 0 && fX0 < fSrcWidth); 389 SkASSERT(fX0 >= 0);
390 return fDstWidth; 390 return fDstWidth;
391 } 391 }
392 392
393 /* 393 /*
394 * 394 *
395 * Swizzle the specified row 395 * Swizzle the specified row
396 * 396 *
397 */ 397 */
398 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) {
399 SkASSERT(nullptr != dst && nullptr != src); 399 SkASSERT(nullptr != dst && nullptr != src);
400 return fRowProc(dst, src, fDstWidth, fMasks, fX0, fSampleX); 400 return fRowProc(dst, src, fDstWidth, fMasks, fX0, fSampleX);
401 } 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