aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/codec
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2015-08-18 13:22:46 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-18 13:22:46 -0700
commitb32758a72fa582a5e40623ffe145727820343909 (patch)
tree6d73a62d78d18e3a670a019a338ec479f8f24600 /include/codec
parent73caadf277248576c2df101cf2a63c78db8096a5 (diff)
Test scaling for small images
We don't want to test small images on Gold because they are not interested to look at. Instead, I wrote a unit test to verify that scaling small images does not cause crashes. BUG=skia: Review URL: https://codereview.chromium.org/1287863004
Diffstat (limited to 'include/codec')
-rw-r--r--include/codec/SkCodec.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index 3465c1df5b..ae9524b8b7 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -55,6 +55,17 @@ public:
* scale that it can natively support
*/
SkISize getScaledDimensions(float desiredScale) const {
+ // Negative and zero scales are errors.
+ SkASSERT(desiredScale > 0.0f);
+ if (desiredScale <= 0.0f) {
+ return SkISize::Make(0, 0);
+ }
+
+ // Upscaling is not supported. Return the original size if the client
+ // requests an upscale.
+ if (desiredScale >= 1.0f) {
+ return this->getInfo().dimensions();
+ }
return this->onGetScaledDimensions(desiredScale);
}