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 #include "SkCodec_libgif.h" | 8 #include "SkCodec_libgif.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 203 } |
204 return NULL; | 204 return NULL; |
205 } | 205 } |
206 | 206 |
207 SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, | 207 SkGifCodec::SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, |
208 GifFileType* gif) | 208 GifFileType* gif) |
209 : INHERITED(srcInfo, stream) | 209 : INHERITED(srcInfo, stream) |
210 , fGif(gif) | 210 , fGif(gif) |
211 {} | 211 {} |
212 | 212 |
213 /* | |
214 * Checks if the conversion between the input image and the requested output | |
215 * image has been implemented | |
216 */ | |
217 static bool conversion_possible(const SkImageInfo& dst, | |
218 const SkImageInfo& src) { | |
219 // Ensure that the profile type is unchanged | |
220 if (dst.profileType() != src.profileType()) { | |
221 return false; | |
222 } | |
223 | |
224 // Check for supported color and alpha types | |
225 switch (dst.colorType()) { | |
226 case kN32_SkColorType: | |
227 return kPremul_SkAlphaType == dst.alphaType() || | |
228 kUnpremul_SkAlphaType == dst.alphaType(); | |
229 case kIndex_8_SkColorType: | |
230 return kPremul_SkAlphaType == dst.alphaType() || | |
231 kUnpremul_SkAlphaType == dst.alphaType(); | |
232 default: | |
233 return false; | |
234 } | |
235 } | |
236 | |
237 bool SkGifCodec::onRewind() { | 213 bool SkGifCodec::onRewind() { |
238 GifFileType* gifOut = NULL; | 214 GifFileType* gifOut = NULL; |
239 if (!ReadHeader(this->stream(), NULL, &gifOut)) { | 215 if (!ReadHeader(this->stream(), NULL, &gifOut)) { |
240 return false; | 216 return false; |
241 } | 217 } |
242 | 218 |
243 SkASSERT(NULL != gifOut); | 219 SkASSERT(NULL != gifOut); |
244 fGif.reset(gifOut); | 220 fGif.reset(gifOut); |
245 return true; | 221 return true; |
246 } | 222 } |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 // giflib returns an error code if the record type is not known. | 550 // giflib returns an error code if the record type is not known. |
575 // We should catch this error immediately. | 551 // We should catch this error immediately. |
576 SkASSERT(false); | 552 SkASSERT(false); |
577 break; | 553 break; |
578 } | 554 } |
579 } while (TERMINATE_RECORD_TYPE != recordType); | 555 } while (TERMINATE_RECORD_TYPE != recordType); |
580 | 556 |
581 return gif_error("Could not find any images to decode in gif file.\n", | 557 return gif_error("Could not find any images to decode in gif file.\n", |
582 kInvalidInput); | 558 kInvalidInput); |
583 } | 559 } |
OLD | NEW |