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 #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 Loading... |
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 } |
OLD | NEW |