Prevent webp from producing 0 dimensional images
BUG=skia:
Review URL: https://codereview.chromium.org/1196643002
diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp
index b02015c..5ffdd34 100644
--- a/src/codec/SkWebpCodec.cpp
+++ b/src/codec/SkWebpCodec.cpp
@@ -103,8 +103,10 @@
SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const {
SkISize dim = this->getInfo().dimensions();
- dim.fWidth = SkScalarRoundToInt(desiredScale * dim.fWidth);
- dim.fHeight = SkScalarRoundToInt(desiredScale * dim.fHeight);
+ // SkCodec treats zero dimensional images as errors, so the minimum size
+ // that we will recommend is 1x1.
+ dim.fWidth = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fWidth));
+ dim.fHeight = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fHeight));
return dim;
}