| 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.h" | 8 #include "SkCodec.h" |
| 9 #include "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkCodec_libbmp.h" | 10 #include "SkCodec_libbmp.h" |
| 11 #include "SkCodec_libico.h" | |
| 12 #include "SkCodec_libpng.h" | 11 #include "SkCodec_libpng.h" |
| 13 #include "SkStream.h" | 12 #include "SkStream.h" |
| 14 | 13 |
| 15 struct DecoderProc { | 14 struct DecoderProc { |
| 16 bool (*IsFormat)(SkStream*); | 15 bool (*IsFormat)(SkStream*); |
| 17 SkCodec* (*NewFromStream)(SkStream*); | 16 SkCodec* (*NewFromStream)(SkStream*); |
| 18 }; | 17 }; |
| 19 | 18 |
| 20 static const DecoderProc gDecoderProcs[] = { | 19 static const DecoderProc gDecoderProcs[] = { |
| 21 { SkPngCodec::IsPng, SkPngCodec::NewFromStream }, | 20 { SkPngCodec::IsPng, SkPngCodec::NewFromStream }, |
| 22 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, | |
| 23 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream } | 21 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream } |
| 24 }; | 22 }; |
| 25 | 23 |
| 26 SkCodec* SkCodec::NewFromStream(SkStream* stream) { | 24 SkCodec* SkCodec::NewFromStream(SkStream* stream) { |
| 27 if (!stream) { | 25 if (!stream) { |
| 28 return NULL; | 26 return NULL; |
| 29 } | 27 } |
| 30 for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) { | 28 for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) { |
| 31 DecoderProc proc = gDecoderProcs[i]; | 29 DecoderProc proc = gDecoderProcs[i]; |
| 32 const bool correctFormat = proc.IsFormat(stream); | 30 const bool correctFormat = proc.IsFormat(stream); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 54 , fNeedsRewind(false) | 52 , fNeedsRewind(false) |
| 55 {} | 53 {} |
| 56 | 54 |
| 57 bool SkCodec::rewindIfNeeded() { | 55 bool SkCodec::rewindIfNeeded() { |
| 58 // Store the value of fNeedsRewind so we can update it. Next read will | 56 // Store the value of fNeedsRewind so we can update it. Next read will |
| 59 // require a rewind. | 57 // require a rewind. |
| 60 const bool neededRewind = fNeedsRewind; | 58 const bool neededRewind = fNeedsRewind; |
| 61 fNeedsRewind = true; | 59 fNeedsRewind = true; |
| 62 return !neededRewind || fStream->rewind(); | 60 return !neededRewind || fStream->rewind(); |
| 63 } | 61 } |
| OLD | NEW |