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

Unified Diff: src/codec/SkScaledCodec.cpp

Issue 1305123002: Scanline decoding for gifs (Closed) Base URL: https://skia.googlesource.com/skia.git@real-bmp-scan
Patch Set: Created 5 years, 4 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
Index: src/codec/SkScaledCodec.cpp
diff --git a/src/codec/SkScaledCodec.cpp b/src/codec/SkScaledCodec.cpp
index 6db09fb5ceefaea49d0e97ef659d4bc9b8e8e076..89ae08ab8cb98e0f658b76158ff417db4ce8f558 100644
--- a/src/codec/SkScaledCodec.cpp
+++ b/src/codec/SkScaledCodec.cpp
@@ -44,15 +44,6 @@ SkScaledCodec::SkScaledCodec(SkScanlineDecoder* scanlineDecoder)
SkScaledCodec::~SkScaledCodec() {}
-// returns a scaled dimension based on the original dimension and the sampleSize
-// NOTE: we round down here for scaled dimension to match the behavior of SkImageDecoder
-static int get_scaled_dimension(int srcDimension, int sampleSize) {
- if (sampleSize > srcDimension) {
- return 1;
- }
- return srcDimension / sampleSize;
-}
-
static SkISize best_scaled_dimensions(const SkISize& origDims, const SkISize& nativeDims,
const SkISize& scaledCodecDims, float desiredScale) {
if (nativeDims == scaledCodecDims) {
@@ -98,8 +89,8 @@ SkISize SkScaledCodec::onGetScaledDimensions(float desiredScale) const {
// Ex: sampleSize = 2, sample every second pixel in x and y directions
int sampleSize = int(1 / desiredScale);
- int scaledWidth = get_scaled_dimension(this->getInfo().width(), sampleSize);
- int scaledHeight = get_scaled_dimension(this->getInfo().height(), sampleSize);
+ int scaledWidth = SkScaledCodec::GetScaledDimension(this->getInfo().width(), sampleSize);
+ int scaledHeight = SkScaledCodec::GetScaledDimension(this->getInfo().height(), sampleSize);
// Return the calculated output dimensions for the given scale
scaledCodecDimensions = SkISize::Make(scaledWidth, scaledHeight);
@@ -121,11 +112,11 @@ static bool scaling_supported(const SkImageInfo& dstInfo, const SkImageInfo& src
return false;
}
// check that srcWidth is scaled down by an integer value
- if (get_scaled_dimension(srcWidth, *sampleX) != dstWidth) {
+ if (SkScaledCodec::GetScaledDimension(srcWidth, *sampleX) != dstWidth) {
return false;
}
// check that src height is scaled down by an integer value
- if (get_scaled_dimension(srcHeight, *sampleY) != dstHeight) {
+ if (SkScaledCodec::GetScaledDimension(srcHeight, *sampleY) != dstHeight) {
return false;
}
// sampleX and sampleY should be equal unless the original sampleSize requested was larger
@@ -139,6 +130,15 @@ static bool scaling_supported(const SkImageInfo& dstInfo, const SkImageInfo& src
return true;
}
+// returns a scaled dimension based on the original dimension and the sampleSize
+// NOTE: we round down here for scaled dimension to match the behavior of SkImageDecoder
+inline int SkScaledCodec::GetScaledDimension(int srcDimension, int sampleSize) {
+ if (sampleSize > srcDimension) {
+ return 1;
+ }
+ return srcDimension / sampleSize;
+}
+
inline int SkScaledCodec::GetStartCoord(int sampleFactor) {
return sampleFactor / 2;
}
@@ -189,9 +189,9 @@ void SkScaledCodec::ComputeSampleSize(const SkImageInfo& dstInfo, const SkImageI
// dstWidth = 7, dstHeight = 2, sampleX = 79/7 = 11, sampleY = 20/2 = 10
// correct for this rounding by comparing width to sampleY and height to sampleX
- if (get_scaled_dimension(srcWidth, sampleY) == dstWidth) {
+ if (SkScaledCodec::GetScaledDimension(srcWidth, sampleY) == dstWidth) {
sampleX = sampleY;
- } else if (get_scaled_dimension(srcHeight, sampleX) == dstHeight) {
+ } else if (SkScaledCodec::GetScaledDimension(srcHeight, sampleX) == dstHeight) {
sampleY = sampleX;
}
}

Powered by Google App Engine
This is Rietveld 408576698