| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 * Return a size that approximately supports the desired scale factor. | 43 * Return a size that approximately supports the desired scale factor. |
| 44 * The codec may not be able to scale efficiently to the exact scale | 44 * The codec may not be able to scale efficiently to the exact scale |
| 45 * factor requested, so return a size that approximates that scale. | 45 * factor requested, so return a size that approximates that scale. |
| 46 * | 46 * |
| 47 * FIXME: Move to SkImageGenerator? | 47 * FIXME: Move to SkImageGenerator? |
| 48 */ | 48 */ |
| 49 SkISize getScaledDimensions(float desiredScale) const { | 49 SkISize getScaledDimensions(float desiredScale) const { |
| 50 return this->onGetScaledDimensions(desiredScale); | 50 return this->onGetScaledDimensions(desiredScale); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Helper for codecs |
| 54 const SkImageInfo& getOriginalInfo() { return fInfo; } |
| 55 |
| 53 protected: | 56 protected: |
| 54 SkCodec(const SkImageInfo&, SkStream*); | 57 SkCodec(const SkImageInfo&, SkStream*); |
| 55 | 58 |
| 56 /** | 59 /** |
| 57 * The SkAlphaType is a conservative answer. i.e. it is possible that it | 60 * The SkAlphaType is a conservative answer. i.e. it is possible that it |
| 58 * initially returns a non-opaque answer, but completing the decode | 61 * initially returns a non-opaque answer, but completing the decode |
| 59 * reveals that the image is actually opaque. | 62 * reveals that the image is actually opaque. |
| 60 */ | 63 */ |
| 61 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { | 64 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { |
| 62 *info = fInfo; | 65 *info = fInfo; |
| 63 return true; | 66 return true; |
| 64 } | 67 } |
| 65 | 68 |
| 66 // Helper for subclasses. | |
| 67 const SkImageInfo& getOriginalInfo() { return fInfo; } | |
| 68 | |
| 69 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { | 69 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { |
| 70 // By default, scaling is not supported. | 70 // By default, scaling is not supported. |
| 71 return fInfo.dimensions(); | 71 return fInfo.dimensions(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * If the stream was previously read, attempt to rewind. | 75 * If the stream was previously read, attempt to rewind. |
| 76 * @returns: | 76 * @returns: |
| 77 * true | 77 * true |
| 78 * - if the stream needed to be rewound, and the rewind | 78 * - if the stream needed to be rewound, and the rewind |
| (...skipping 15 matching lines...) Expand all Loading... |
| 94 SkStream* stream() { | 94 SkStream* stream() { |
| 95 return fStream.get(); | 95 return fStream.get(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 const SkImageInfo fInfo; | 99 const SkImageInfo fInfo; |
| 100 SkAutoTDelete<SkStream> fStream; | 100 SkAutoTDelete<SkStream> fStream; |
| 101 bool fNeedsRewind; | 101 bool fNeedsRewind; |
| 102 }; | 102 }; |
| 103 #endif // SkCodec_DEFINED | 103 #endif // SkCodec_DEFINED |
| OLD | NEW |