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

Unified Diff: src/codec/SkSwizzler.cpp

Issue 1390213002: Add subsetting to SkScanlineDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@fill-refactor
Patch Set: Response to comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | src/codec/SkWebpCodec.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkSwizzler.cpp
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp
index 8d13e56bd25a44e221c7f4bc290e51cf4922449f..95ed1d7b962f58f96836a66be01389853591105b 100644
--- a/src/codec/SkSwizzler.cpp
+++ b/src/codec/SkSwizzler.cpp
@@ -230,9 +230,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.
- SkASSERT(0 == offset);
memcpy(dst, src, dstWidth);
for (int x = 0; x < dstWidth; x++) {
UPDATE_RESULT_ALPHA(ctable[src[x]] >> SK_A32_SHIFT);
@@ -514,8 +511,8 @@ static bool swizzle_rgba_to_n32_unpremul_skipZ(void* SK_RESTRICT dstRow,
SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc,
const SkPMColor* ctable,
- const SkImageInfo& dstInfo,
- SkCodec::ZeroInitialized zeroInit) {
+ const SkImageInfo& dstInfo,
+ const SkCodec::Options& options) {
if (dstInfo.colorType() == kUnknown_SkColorType || kUnknown == sc) {
return nullptr;
}
@@ -524,7 +521,7 @@ SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc,
return nullptr;
}
RowProc proc = nullptr;
-
+ SkCodec::ZeroInitialized zeroInit = options.fZeroInitialized;
switch (sc) {
case kBit:
switch (dstInfo.colorType()) {
@@ -683,28 +680,35 @@ 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);
+
+ int srcOffset = 0;
+ int srcWidth = dstInfo.width();
+ if (options.fSubset) {
+ srcOffset = options.fSubset->left();
+ srcWidth = options.fSubset->width();
+ }
- return new SkSwizzler(proc, ctable, deltaSrc, dstInfo.width());
+ return new SkSwizzler(proc, ctable, srcOffset, srcWidth, bpp);
}
-SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable,
- int deltaSrc, int srcWidth)
+SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcOffset, int srcWidth, int bpp)
: fRowProc(proc)
, fColorTable(ctable)
- , fDeltaSrc(deltaSrc)
+ , fSrcOffset(srcOffset)
+ , fX0(srcOffset)
, fSrcWidth(srcWidth)
, fDstWidth(srcWidth)
+ , fBPP(bpp)
, fSampleX(1)
- , fX0(0)
{}
int SkSwizzler::onSetSampleX(int sampleX) {
SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be
// way to report failure?
fSampleX = sampleX;
- fX0 = get_start_coord(sampleX);
+ fX0 = get_start_coord(sampleX) + fSrcOffset;
fDstWidth = get_scaled_dimension(fSrcWidth, sampleX);
// check that fX0 is less than original width
@@ -714,6 +718,5 @@ int SkSwizzler::onSetSampleX(int sampleX) {
SkSwizzler::ResultAlpha SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) {
SkASSERT(nullptr != dst && nullptr != src);
- return fRowProc(dst, src, fDstWidth, fDeltaSrc, fSampleX * fDeltaSrc,
- fX0 * fDeltaSrc, fColorTable);
+ return fRowProc(dst, src, fDstWidth, fBPP, fSampleX * fBPP, fX0 * fBPP, fColorTable);
}
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | src/codec/SkWebpCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698