| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 // giflib returns an error code if the record type is not known. | 549 // giflib returns an error code if the record type is not known. |
| 574 // We should catch this error immediately. | 550 // We should catch this error immediately. |
| 575 SkASSERT(false); | 551 SkASSERT(false); |
| 576 break; | 552 break; |
| 577 } | 553 } |
| 578 } while (TERMINATE_RECORD_TYPE != recordType); | 554 } while (TERMINATE_RECORD_TYPE != recordType); |
| 579 | 555 |
| 580 return gif_error("Could not find any images to decode in gif file.\n", | 556 return gif_error("Could not find any images to decode in gif file.\n", |
| 581 kInvalidInput); | 557 kInvalidInput); |
| 582 } | 558 } |
| OLD | NEW |