aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/codec/SkMaskSwizzler.cpp12
-rw-r--r--src/codec/SkMaskSwizzler.h4
-rw-r--r--src/codec/SkSwizzler.cpp13
-rw-r--r--src/codec/SkSwizzler.h4
-rw-r--r--tests/CodexTest.cpp20
5 files changed, 37 insertions, 16 deletions
diff --git a/src/codec/SkMaskSwizzler.cpp b/src/codec/SkMaskSwizzler.cpp
index 72dca28057..958df61cc7 100644
--- a/src/codec/SkMaskSwizzler.cpp
+++ b/src/codec/SkMaskSwizzler.cpp
@@ -367,11 +367,11 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
* Constructor for mask swizzler
*
*/
-SkMaskSwizzler::SkMaskSwizzler(SkMasks* masks, RowProc proc, int srcOffset, int srcWidth)
+SkMaskSwizzler::SkMaskSwizzler(SkMasks* masks, RowProc proc, int srcOffset, int subsetWidth)
: fMasks(masks)
, fRowProc(proc)
- , fSrcWidth(srcWidth)
- , fDstWidth(srcWidth)
+ , fSubsetWidth(subsetWidth)
+ , fDstWidth(subsetWidth)
, fSampleX(1)
, fSrcOffset(srcOffset)
, fX0(srcOffset)
@@ -383,10 +383,10 @@ int SkMaskSwizzler::onSetSampleX(int sampleX) {
// way to report failure?
fSampleX = sampleX;
fX0 = get_start_coord(sampleX) + fSrcOffset;
- fDstWidth = get_scaled_dimension(fSrcWidth, sampleX);
+ fDstWidth = get_scaled_dimension(fSubsetWidth, sampleX);
- // check that fX0 is less than original width
- SkASSERT(fX0 >= 0 && fX0 < fSrcWidth);
+ // check that fX0 is valid
+ SkASSERT(fX0 >= 0);
return fDstWidth;
}
diff --git a/src/codec/SkMaskSwizzler.h b/src/codec/SkMaskSwizzler.h
index 9aea5d8d70..e5da723ca5 100644
--- a/src/codec/SkMaskSwizzler.h
+++ b/src/codec/SkMaskSwizzler.h
@@ -53,7 +53,7 @@ private:
typedef SkSwizzler::ResultAlpha (*RowProc)(void* dstRow, const uint8_t* srcRow, int width,
SkMasks* masks, uint32_t startX, uint32_t sampleX);
- SkMaskSwizzler(SkMasks* masks, RowProc proc, int srcWidth, int srcOffset);
+ SkMaskSwizzler(SkMasks* masks, RowProc proc, int subsetWidth, int srcOffset);
int onSetSampleX(int) override;
@@ -61,7 +61,7 @@ private:
const RowProc fRowProc;
// FIXME: Can this class share more with SkSwizzler? These variables are all the same.
- const int fSrcWidth; // Width of the source - i.e. before any sampling.
+ const int fSubsetWidth; // Width of the subset of source before any sampling.
int fDstWidth; // Width of dst, which may differ with sampling.
int fSampleX;
int fSrcOffset;
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp
index ce2c946f18..de69124340 100644
--- a/src/codec/SkSwizzler.cpp
+++ b/src/codec/SkSwizzler.cpp
@@ -693,13 +693,14 @@ SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc,
return new SkSwizzler(proc, ctable, srcOffset, srcWidth, bpp);
}
-SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcOffset, int srcWidth, int bpp)
+SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcOffset, int subsetWidth,
+ int bpp)
: fRowProc(proc)
, fColorTable(ctable)
, fSrcOffset(srcOffset)
, fX0(srcOffset)
- , fSrcWidth(srcWidth)
- , fDstWidth(srcWidth)
+ , fSubsetWidth(subsetWidth)
+ , fDstWidth(subsetWidth)
, fSampleX(1)
, fBPP(bpp)
{}
@@ -709,10 +710,10 @@ int SkSwizzler::onSetSampleX(int sampleX) {
// way to report failure?
fSampleX = sampleX;
fX0 = get_start_coord(sampleX) + fSrcOffset;
- fDstWidth = get_scaled_dimension(fSrcWidth, sampleX);
+ fDstWidth = get_scaled_dimension(fSubsetWidth, sampleX);
- // check that fX0 is less than original width
- SkASSERT(fX0 >= 0 && fX0 < fSrcWidth);
+ // check that fX0 is valid
+ SkASSERT(fX0 >= 0);
return fDstWidth;
}
diff --git a/src/codec/SkSwizzler.h b/src/codec/SkSwizzler.h
index 058044e420..fd205880f8 100644
--- a/src/codec/SkSwizzler.h
+++ b/src/codec/SkSwizzler.h
@@ -178,7 +178,7 @@ private:
// scanline decodes.
int fX0; // Start coordinate for the src, may be different than
// fSrcOffset if we are sampling.
- const int fSrcWidth; // Width of the source - i.e. before any sampling.
+ const int fSubsetWidth; // Width of the subset of the source before any sampling.
int fDstWidth; // Width of dst, which may differ with sampling.
int fSampleX; // step between X samples
const int fBPP; // if bitsPerPixel % 8 == 0
@@ -186,7 +186,7 @@ private:
// else
// fBPP is bitsPerPixel
- SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcOffset, int srcWidth, int bpp);
+ SkSwizzler(RowProc proc, const SkPMColor* ctable, int srcOffset, int subsetWidth, int bpp);
int onSetSampleX(int) override;
diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp
index 91fb6897b5..5ef1f8a86e 100644
--- a/tests/CodexTest.cpp
+++ b/tests/CodexTest.cpp
@@ -220,6 +220,26 @@ static void check(skiatest::Reporter* r,
== 0);
REPORTER_ASSERT(r, codec->skipScanlines(1)
== 0);
+
+ // Test partial scanline decodes
+ if (supports_scaled_codec(path) && info.width() >= 3) {
+ SkCodec::Options options;
+ int width = info.width();
+ int height = info.height();
+ SkIRect subset = SkIRect::MakeXYWH(2 * (width / 3), 0, width / 3, height);
+ options.fSubset = &subset;
+
+ const SkCodec::Result partialStartResult = codec->startScanlineDecode(info, &options,
+ nullptr, nullptr);
+ REPORTER_ASSERT(r, partialStartResult == SkCodec::kSuccess);
+
+ for (int y = 0; y < height; y++) {
+ const int lines = codec->getScanlines(bm.getAddr(0, y), 1, 0);
+ if (!isIncomplete) {
+ REPORTER_ASSERT(r, 1 == lines);
+ }
+ }
+ }
} else {
REPORTER_ASSERT(r, startResult == SkCodec::kUnimplemented);
}