| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 * those of getInfo, this implies a scale. | 128 * those of getInfo, this implies a scale. |
| 129 * @return New SkScanlineDecoder on success, NULL otherwise. The SkCodec | 129 * @return New SkScanlineDecoder on success, NULL otherwise. The SkCodec |
| 130 * will take ownership of the returned scanline decoder. | 130 * will take ownership of the returned scanline decoder. |
| 131 */ | 131 */ |
| 132 virtual SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo)
{ | 132 virtual SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo)
{ |
| 133 return NULL; | 133 return NULL; |
| 134 } | 134 } |
| 135 | 135 |
| 136 virtual bool onReallyHasAlpha() const { return false; } | 136 virtual bool onReallyHasAlpha() const { return false; } |
| 137 | 137 |
| 138 enum RewindState { |
| 139 kRewound_RewindState, |
| 140 kNoRewindNecessary_RewindState, |
| 141 kCouldNotRewind_RewindState |
| 142 }; |
| 138 /** | 143 /** |
| 139 * If the stream was previously read, attempt to rewind. | 144 * If the stream was previously read, attempt to rewind. |
| 140 * @returns: | 145 * @returns: |
| 141 * true | 146 * kRewound if the stream needed to be rewound, and the |
| 142 * - if the stream needed to be rewound, and the rewind | 147 * rewind succeeded. |
| 143 * succeeded. | 148 * kNoRewindNecessary if the stream did not need to be |
| 144 * - if the stream did not need to be rewound. | 149 * rewound. |
| 145 * false | 150 * kCouldNotRewind if the stream needed to be rewound, and |
| 146 * - if the stream needed to be rewound, and rewind failed. | 151 * rewind failed. |
| 152 * |
| 147 * Subclasses MUST call this function before reading the stream (e.g. in | 153 * Subclasses MUST call this function before reading the stream (e.g. in |
| 148 * onGetPixels). If it returns false, onGetPixels should return | 154 * onGetPixels). If it returns false, onGetPixels should return |
| 149 * kCouldNotRewind. | 155 * kCouldNotRewind. |
| 150 */ | 156 */ |
| 151 bool SK_WARN_UNUSED_RESULT rewindIfNeeded(); | 157 RewindState SK_WARN_UNUSED_RESULT rewindIfNeeded(); |
| 152 | 158 |
| 153 /* | 159 /* |
| 154 * | 160 * |
| 155 * Get method for the input stream | 161 * Get method for the input stream |
| 156 * | 162 * |
| 157 */ | 163 */ |
| 158 SkStream* stream() { | 164 SkStream* stream() { |
| 159 return fStream.get(); | 165 return fStream.get(); |
| 160 } | 166 } |
| 161 | 167 |
| 162 private: | 168 private: |
| 163 #ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO | 169 #ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO |
| 164 const SkImageInfo fInfo; | 170 const SkImageInfo fInfo; |
| 165 #endif // SK_SUPPORT_LEGACY_BOOL_ONGETINFO | 171 #endif // SK_SUPPORT_LEGACY_BOOL_ONGETINFO |
| 166 SkAutoTDelete<SkStream> fStream; | 172 SkAutoTDelete<SkStream> fStream; |
| 167 bool fNeedsRewind; | 173 bool fNeedsRewind; |
| 168 SkAutoTDelete<SkScanlineDecoder> fScanlineDecoder; | 174 SkAutoTDelete<SkScanlineDecoder> fScanlineDecoder; |
| 169 | 175 |
| 170 typedef SkImageGenerator INHERITED; | 176 typedef SkImageGenerator INHERITED; |
| 171 }; | 177 }; |
| 172 #endif // SkCodec_DEFINED | 178 #endif // SkCodec_DEFINED |
| OLD | NEW |