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

Unified Diff: src/codec/SkSwizzler.cpp

Issue 1372973002: Move all knowledge of X sampling into SkScaledCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@codecSDmerge
Patch Set: Attempt to fix RLE overflow 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.h » ('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 a3f14881713250203e865c7eb10c9cb194d82773..214655b85b04f7de452ae36822ca517558f2e314 100644
--- a/src/codec/SkSwizzler.cpp
+++ b/src/codec/SkSwizzler.cpp
@@ -516,8 +516,7 @@ 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& srcInfo) {
+ SkCodec::ZeroInitialized zeroInit) {
if (dstInfo.colorType() == kUnknown_SkColorType || kUnknown == sc) {
return nullptr;
}
@@ -688,29 +687,35 @@ SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc,
// Store deltaSrc in bytes if it is an even multiple, otherwise use bits
int deltaSrc = 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);
+ return new SkSwizzler(proc, ctable, deltaSrc, dstInfo.width());
}
SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable,
- int deltaSrc, const SkImageInfo& info, int sampleX)
+ int deltaSrc, int srcWidth)
: fRowProc(proc)
, fColorTable(ctable)
, fDeltaSrc(deltaSrc)
- , fDstInfo(info)
- , fSampleX(sampleX)
- , fX0(get_start_coord(sampleX))
-{
+ , fSrcWidth(srcWidth)
+ , fDstWidth(srcWidth)
+ , 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);
+ fDstWidth = get_scaled_dimension(fSrcWidth, sampleX);
+
// check that fX0 is less than original width
- SkASSERT(fX0 >= 0 && fX0 < fDstInfo.width() * fSampleX);
+ SkASSERT(fX0 >= 0 && fX0 < fSrcWidth);
+ return fDstWidth;
}
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,
+ return fRowProc(dst, src, fDstWidth, fDeltaSrc, fSampleX * fDeltaSrc,
fX0 * fDeltaSrc, fColorTable);
}
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | src/codec/SkWebpCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698