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

Side by Side Diff: include/codec/SkCodec.h

Issue 1287863004: Test scaling for small images (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed comment 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 unified diff | Download patch
« no previous file with comments | « dm/DMSrcSink.cpp ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkCodec_DEFINED 8 #ifndef SkCodec_DEFINED
9 #define SkCodec_DEFINED 9 #define SkCodec_DEFINED
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 const SkImageInfo& getInfo() const { return fInfo; } 48 const SkImageInfo& getInfo() const { return fInfo; }
49 49
50 /** 50 /**
51 * Return a size that approximately supports the desired scale factor. 51 * Return a size that approximately supports the desired scale factor.
52 * The codec may not be able to scale efficiently to the exact scale 52 * The codec may not be able to scale efficiently to the exact scale
53 * factor requested, so return a size that approximates that scale. 53 * factor requested, so return a size that approximates that scale.
54 * The returned value is the codec's suggestion for the closest valid 54 * The returned value is the codec's suggestion for the closest valid
55 * scale that it can natively support 55 * scale that it can natively support
56 */ 56 */
57 SkISize getScaledDimensions(float desiredScale) const { 57 SkISize getScaledDimensions(float desiredScale) const {
58 // Negative and zero scales are errors.
59 SkASSERT(desiredScale > 0.0f);
60 if (desiredScale <= 0.0f) {
61 return SkISize::Make(0, 0);
62 }
63
64 // Upscaling is not supported. Return the original size if the client
65 // requests an upscale.
66 if (desiredScale >= 1.0f) {
67 return this->getInfo().dimensions();
68 }
58 return this->onGetScaledDimensions(desiredScale); 69 return this->onGetScaledDimensions(desiredScale);
59 } 70 }
60 71
61 /** 72 /**
62 * Return (via desiredSubset) a subset which can decoded from this codec, 73 * Return (via desiredSubset) a subset which can decoded from this codec,
63 * or false if this codec cannot decode subsets or anything similar to 74 * or false if this codec cannot decode subsets or anything similar to
64 * desiredSubset. 75 * desiredSubset.
65 * 76 *
66 * @param desiredSubset In/out parameter. As input, a desired subset of 77 * @param desiredSubset In/out parameter. As input, a desired subset of
67 * the original bounds (as specified by getInfo). If true is returned, 78 * the original bounds (as specified by getInfo). If true is returned,
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 SkStream* stream() { 274 SkStream* stream() {
264 return fStream.get(); 275 return fStream.get();
265 } 276 }
266 277
267 private: 278 private:
268 const SkImageInfo fInfo; 279 const SkImageInfo fInfo;
269 SkAutoTDelete<SkStream> fStream; 280 SkAutoTDelete<SkStream> fStream;
270 bool fNeedsRewind; 281 bool fNeedsRewind;
271 }; 282 };
272 #endif // SkCodec_DEFINED 283 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « dm/DMSrcSink.cpp ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698