Index: src/codec/SkSwizzler.cpp |
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp |
index 8fcd18e8be499a0dd07e06acd4f860091f7e6f60..648f021ef7c31a18f340942730eed9cb68c92199 100644 |
--- a/src/codec/SkSwizzler.cpp |
+++ b/src/codec/SkSwizzler.cpp |
@@ -231,9 +231,6 @@ static SkSwizzler::ResultAlpha swizzle_index_to_index( |
// SkScaledBitmap sampler just guesses that it is opaque. This is dangerous |
// and probably wrong since gif and bmp (rarely) may have alpha. |
if (1 == deltaSrc) { |
- // A non-zero offset is only used when sampling, meaning that deltaSrc will be |
- // greater than 1. The below loop relies on the fact that src remains unchanged. |
scroggo
2015/10/02 18:27:03
Does the below loop not need to be updated to take
msarett
2015/10/06 23:01:27
Don't think so...
scroggo
2015/10/07 17:49:39
Can you help me understand why that is? I thought
|
- SkASSERT(0 == offset); |
memcpy(dst, src, dstWidth); |
for (int x = 0; x < dstWidth; x++) { |
UPDATE_RESULT_ALPHA(ctable[src[x]] >> SK_A32_SHIFT); |
@@ -517,7 +514,8 @@ SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc, |
const SkPMColor* ctable, |
const SkImageInfo& dstInfo, |
SkCodec::ZeroInitialized zeroInit, |
- const SkImageInfo& srcInfo) { |
+ const SkImageInfo& srcInfo, |
+ int subsetLeft, int subsetWidth) { |
if (dstInfo.colorType() == kUnknown_SkColorType || kUnknown == sc) { |
return nullptr; |
} |
@@ -685,33 +683,30 @@ SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc, |
return nullptr; |
} |
- // Store deltaSrc in bytes if it is an even multiple, otherwise use bits |
- int deltaSrc = SkIsAlign8(BitsPerPixel(sc)) ? BytesPerPixel(sc) : BitsPerPixel(sc); |
+ // Store bpp in bytes if it is an even multiple, otherwise use bits |
+ int bpp = SkIsAlign8(BitsPerPixel(sc)) ? BytesPerPixel(sc) : BitsPerPixel(sc); |
// get sampleX based on srcInfo and dstInfo dimensions |
int sampleX; |
- SkScaledCodec::ComputeSampleSize(dstInfo, srcInfo, &sampleX, nullptr); |
- |
- return new SkSwizzler(proc, ctable, deltaSrc, dstInfo, sampleX); |
+ SkScaledCodec::ComputeSampleSize(dstInfo.dimensions(), srcInfo.dimensions(), &sampleX, nullptr); |
+ int x0 = get_start_coord(sampleX) + subsetLeft; |
+ |
+ return new SkSwizzler(proc, ctable, x0 * bpp, subsetWidth, bpp, sampleX * bpp); |
} |
SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable, |
- int deltaSrc, const SkImageInfo& info, int sampleX) |
+ int left, int width, int bpp, int deltaSrc) |
: fRowProc(proc) |
, fColorTable(ctable) |
+ , fLeft(left) |
+ , fWidth(width) |
+ , fBPP(bpp) |
, fDeltaSrc(deltaSrc) |
- , fDstInfo(info) |
- , fSampleX(sampleX) |
- , fX0(get_start_coord(sampleX)) |
-{ |
- // check that fX0 is less than original width |
- SkASSERT(fX0 >= 0 && fX0 < fDstInfo.width() * fSampleX); |
-} |
+{} |
SkSwizzler::ResultAlpha SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) { |
SkASSERT(nullptr != dst && nullptr != src); |
- return fRowProc(dst, src, fDstInfo.width(), fDeltaSrc, fSampleX * fDeltaSrc, |
- fX0 * fDeltaSrc, fColorTable); |
+ return fRowProc(dst, src, fWidth, fBPP, fDeltaSrc, fLeft, fColorTable); |
} |
void SkSwizzler::Fill(void* fillDst, const SkImageInfo& fillInfo, size_t rowBytes, |