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

Unified Diff: src/images/SkScaledBitmapSampler.cpp

Issue 25354004: Allow sampling GIF images during decode. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Switch back to using kIndex8 Created 7 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/images/SkScaledBitmapSampler.h ('k') | tools/skimage_main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkScaledBitmapSampler.cpp
diff --git a/src/images/SkScaledBitmapSampler.cpp b/src/images/SkScaledBitmapSampler.cpp
index cad97ead270765a130ef3f70f493f587de04c98d..825f9d5268fb64485abd5219d86903ebc1ba3b15 100644
--- a/src/images/SkScaledBitmapSampler.cpp
+++ b/src/images/SkScaledBitmapSampler.cpp
@@ -576,6 +576,8 @@ SkScaledBitmapSampler::SkScaledBitmapSampler(int width, int height,
sk_throw();
}
+ SkDEBUGCODE(fSampleMode = kUninitialized_SampleMode);
+
if (sampleSize <= 1) {
fScaledWidth = width;
fScaledHeight = height;
@@ -711,6 +713,8 @@ bool SkScaledBitmapSampler::begin(SkBitmap* dst, SrcConfig sc,
}
bool SkScaledBitmapSampler::next(const uint8_t* SK_RESTRICT src) {
+ SkASSERT(kInterlaced_SampleMode != fSampleMode);
+ SkDEBUGCODE(fSampleMode = kConsecutive_SampleMode);
SkASSERT((unsigned)fCurrY < (unsigned)fScaledHeight);
bool hadAlpha = fRowProc(fDstRow, src + fX0 * fSrcPixelSize, fScaledWidth,
@@ -720,6 +724,29 @@ bool SkScaledBitmapSampler::next(const uint8_t* SK_RESTRICT src) {
return hadAlpha;
}
+bool SkScaledBitmapSampler::sampleInterlaced(const uint8_t* SK_RESTRICT src, int srcY) {
+ SkASSERT(kConsecutive_SampleMode != fSampleMode);
+ SkDEBUGCODE(fSampleMode = kInterlaced_SampleMode);
+ // Any line that should be a part of the destination can be created by the formula:
+ // fY0 + (some multiplier) * fDY
+ // so if srcY - fY0 is not an integer multiple of fDY that srcY will be skipped.
+ const int srcYMinusY0 = srcY - fY0;
+ if (srcYMinusY0 % fDY != 0) {
+ // This line is not part of the output, so return false for alpha, since we have
+ // not added an alpha to the output.
+ return false;
+ }
+ // Unlike in next(), where the data is used sequentially, this function skips around,
+ // so fDstRow and fCurrY are never updated. fDstRow must always be the starting point
+ // of the destination bitmap's pixels, which is used to calculate the destination row
+ // each time this function is called.
+ const int dstY = srcYMinusY0 / fDY;
+ SkASSERT(dstY < fScaledHeight);
+ char* dstRow = fDstRow + dstY * fDstRowBytes;
+ return fRowProc(dstRow, src + fX0 * fSrcPixelSize, fScaledWidth,
+ fDX * fSrcPixelSize, dstY, fCTable);
+}
+
#ifdef SK_DEBUG
// The following code is for a test to ensure that changing the method to get the right row proc
// did not change the row proc unintentionally. Tested by ImageDecodingTest.cpp
« no previous file with comments | « src/images/SkScaledBitmapSampler.h ('k') | tools/skimage_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698