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

Unified Diff: src/codec/SkCodec_libico.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/SkCodec_libico.h ('k') | src/codec/SkCodec_libpng.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec_libico.cpp
diff --git a/src/codec/SkCodec_libico.cpp b/src/codec/SkCodec_libico.cpp
index 798169d82b344902571d996d34c127818b3576e7..8b38148adff6e72872c4e642a44eba1d4c4ab5a7 100644
--- a/src/codec/SkCodec_libico.cpp
+++ b/src/codec/SkCodec_libico.cpp
@@ -206,10 +206,6 @@ SkISize SkIcoCodec::onGetScaledDimensions(float desiredScale) const {
// We set the dimensions to the largest candidate image by default.
// Regardless of the scale request, this is the largest image that we
// will decode.
- if (desiredScale >= 1.0) {
- return this->getInfo().dimensions();
- }
-
int origWidth = this->getInfo().width();
int origHeight = this->getInfo().height();
float desiredSize = desiredScale * origWidth * origHeight;
@@ -230,6 +226,17 @@ SkISize SkIcoCodec::onGetScaledDimensions(float desiredScale) const {
return fEmbeddedCodecs->operator[](minIndex)->getInfo().dimensions();
}
+bool SkIcoCodec::onDimensionsSupported(const SkISize& dim) {
+ // FIXME: Cache the index from onGetScaledDimensions?
+ for (int32_t i = 0; i < fEmbeddedCodecs->count(); i++) {
+ if (fEmbeddedCodecs->operator[](i)->getInfo().dimensions() == dim) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
/*
* Initiates the Ico decode
*/
@@ -286,6 +293,9 @@ SkCodec::Result SkIcoCodec::onGetPixels(const SkImageInfo& dstInfo,
}
}
+ // This should never be reached, since onDimensionsSupported should have rejected the
+ // dimensions sooner.
+ SkASSERT(false);
SkCodecPrintf("Error: No matching candidate image in ico.\n");
return result;
}
« no previous file with comments | « src/codec/SkCodec_libico.h ('k') | src/codec/SkCodec_libpng.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698