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; |
} |