OLD | NEW |
---|---|
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 | 45 |
46 /** | 46 /** |
47 * Return the ImageInfo associated with this codec. | 47 * Return the ImageInfo associated with this codec. |
48 */ | 48 */ |
49 const SkImageInfo& getInfo() const { return fInfo; } | 49 const SkImageInfo& getInfo() const { return fInfo; } |
50 | 50 |
51 /** | 51 /** |
52 * Return a size that approximately supports the desired scale factor. | 52 * Return a size that approximately supports the desired scale factor. |
53 * The codec may not be able to scale efficiently to the exact scale | 53 * The codec may not be able to scale efficiently to the exact scale |
54 * factor requested, so return a size that approximates that scale. | 54 * factor requested, so return a size that approximates that scale. |
55 * The returned value is the codec's suggestion for the closest valid | |
56 * scale that it can natively support | |
55 */ | 57 */ |
56 SkISize getScaledDimensions(float desiredScale) const { | 58 SkISize getScaledDimensions(float desiredScale) const { |
57 return this->onGetScaledDimensions(desiredScale); | 59 return this->onGetScaledDimensions(desiredScale); |
58 } | 60 } |
59 | 61 |
62 /* | |
63 * Checks if we can patially natively scale to the desiredScale, and partial ly natively scales | |
scroggo
2015/08/04 20:05:21
"partially" is missing r (the first time)
emmaleer
2015/08/05 14:47:51
Acknowledged.
| |
64 * the dimensions if possible. | |
65 * Returns the new sampleSize, which is used to finish scaling to the desire dScale. | |
66 * Ex: desiredScale = 1/6. Natively can scale by 1/2. New sampleSize = 3, as there is still | |
67 * 1/3 scaling left to do, which is done by sampling. | |
68 * Returns -1 if partial native scaling is not supported. | |
69 */ | |
70 int partiallyNativelyScale(float desiredScale) { | |
scroggo
2015/08/04 20:05:21
I'm not a huge fan of this name. I am not sure I h
emmaleer
2015/08/05 14:47:51
Okay, I'll first upload the changes for future ref
| |
71 return this->onPartiallyNativelyScale(desiredScale); | |
72 } | |
73 | |
60 /** | 74 /** |
61 * Return (via desiredSubset) a subset which can decoded from this codec, | 75 * Return (via desiredSubset) a subset which can decoded from this codec, |
62 * or false if this codec cannot decode subsets or anything similar to | 76 * or false if this codec cannot decode subsets or anything similar to |
63 * desiredSubset. | 77 * desiredSubset. |
64 * | 78 * |
65 * @param desiredSubset In/out parameter. As input, a desired subset of | 79 * @param desiredSubset In/out parameter. As input, a desired subset of |
66 * the original bounds (as specified by getInfo). If true is returned, | 80 * the original bounds (as specified by getInfo). If true is returned, |
67 * desiredSubset may have been modified to a subset which is | 81 * desiredSubset may have been modified to a subset which is |
68 * supported. Although a particular change may have been made to | 82 * supported. Although a particular change may have been made to |
69 * desiredSubset to create something supported, it is possible other | 83 * desiredSubset to create something supported, it is possible other |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 } | 259 } |
246 | 260 |
247 protected: | 261 protected: |
248 SkCodec(const SkImageInfo&, SkStream*); | 262 SkCodec(const SkImageInfo&, SkStream*); |
249 | 263 |
250 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { | 264 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { |
251 // By default, scaling is not supported. | 265 // By default, scaling is not supported. |
252 return this->getInfo().dimensions(); | 266 return this->getInfo().dimensions(); |
253 } | 267 } |
254 | 268 |
269 virtual int onPartiallyNativelyScale(float desiredScale) { | |
270 return -1; | |
271 } | |
255 virtual SkEncodedFormat onGetEncodedFormat() const = 0; | 272 virtual SkEncodedFormat onGetEncodedFormat() const = 0; |
256 | 273 |
257 virtual Result onGetPixels(const SkImageInfo& info, | 274 virtual Result onGetPixels(const SkImageInfo& info, |
258 void* pixels, size_t rowBytes, const Options&, | 275 void* pixels, size_t rowBytes, const Options&, |
259 SkPMColor ctable[], int* ctableCount) = 0; | 276 SkPMColor ctable[], int* ctableCount) = 0; |
260 | 277 |
261 virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const { | 278 virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const { |
262 // By default, subsets are not supported. | 279 // By default, subsets are not supported. |
263 return false; | 280 return false; |
264 } | 281 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 SkStream* stream() { | 333 SkStream* stream() { |
317 return fStream.get(); | 334 return fStream.get(); |
318 } | 335 } |
319 | 336 |
320 private: | 337 private: |
321 const SkImageInfo fInfo; | 338 const SkImageInfo fInfo; |
322 SkAutoTDelete<SkStream> fStream; | 339 SkAutoTDelete<SkStream> fStream; |
323 bool fNeedsRewind; | 340 bool fNeedsRewind; |
324 }; | 341 }; |
325 #endif // SkCodec_DEFINED | 342 #endif // SkCodec_DEFINED |
OLD | NEW |