| 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 "SkScaledCodec.h" | 10 #include "SkScaledCodec.h" |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 int srcOffset = 0; | 686 int srcOffset = 0; |
| 687 int srcWidth = dstInfo.width(); | 687 int srcWidth = dstInfo.width(); |
| 688 if (options.fSubset) { | 688 if (options.fSubset) { |
| 689 srcOffset = options.fSubset->left(); | 689 srcOffset = options.fSubset->left(); |
| 690 srcWidth = options.fSubset->width(); | 690 srcWidth = options.fSubset->width(); |
| 691 } | 691 } |
| 692 | 692 |
| 693 return new SkSwizzler(proc, ctable, srcOffset, srcWidth, bpp); | 693 return new SkSwizzler(proc, ctable, srcOffset, srcWidth, bpp); |
| 694 } | 694 } |
| 695 | 695 |
| 696 SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcOffset, int
srcWidth, int bpp) | 696 SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcOffset, int
subsetWidth, |
| 697 int bpp) |
| 697 : fRowProc(proc) | 698 : fRowProc(proc) |
| 698 , fColorTable(ctable) | 699 , fColorTable(ctable) |
| 699 , fSrcOffset(srcOffset) | 700 , fSrcOffset(srcOffset) |
| 700 , fX0(srcOffset) | 701 , fX0(srcOffset) |
| 701 , fSrcWidth(srcWidth) | 702 , fSubsetWidth(subsetWidth) |
| 702 , fDstWidth(srcWidth) | 703 , fDstWidth(subsetWidth) |
| 703 , fSampleX(1) | 704 , fSampleX(1) |
| 704 , fBPP(bpp) | 705 , fBPP(bpp) |
| 705 {} | 706 {} |
| 706 | 707 |
| 707 int SkSwizzler::onSetSampleX(int sampleX) { | 708 int SkSwizzler::onSetSampleX(int sampleX) { |
| 708 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be | 709 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be |
| 709 // way to report failure? | 710 // way to report failure? |
| 710 fSampleX = sampleX; | 711 fSampleX = sampleX; |
| 711 fX0 = get_start_coord(sampleX) + fSrcOffset; | 712 fX0 = get_start_coord(sampleX) + fSrcOffset; |
| 712 fDstWidth = get_scaled_dimension(fSrcWidth, sampleX); | 713 fDstWidth = get_scaled_dimension(fSubsetWidth, sampleX); |
| 713 | 714 |
| 714 // check that fX0 is less than original width | 715 // check that fX0 is valid |
| 715 SkASSERT(fX0 >= 0 && fX0 < fSrcWidth); | 716 SkASSERT(fX0 >= 0); |
| 716 return fDstWidth; | 717 return fDstWidth; |
| 717 } | 718 } |
| 718 | 719 |
| 719 SkSwizzler::ResultAlpha SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRIC
T src) { | 720 SkSwizzler::ResultAlpha SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRIC
T src) { |
| 720 SkASSERT(nullptr != dst && nullptr != src); | 721 SkASSERT(nullptr != dst && nullptr != src); |
| 721 return fRowProc(dst, src, fDstWidth, fBPP, fSampleX * fBPP, fX0 * fBPP, fCol
orTable); | 722 return fRowProc(dst, src, fDstWidth, fBPP, fSampleX * fBPP, fX0 * fBPP, fCol
orTable); |
| 722 } | 723 } |
| OLD | NEW |