| 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" | 11 #include "SkCodec_libico.h" |
| 12 #include "SkCodec_libpng.h" | 12 #include "SkCodec_libpng.h" |
| 13 #include "SkCodec_wbmp.h" |
| 13 #include "SkStream.h" | 14 #include "SkStream.h" |
| 14 | 15 |
| 15 struct DecoderProc { | 16 struct DecoderProc { |
| 16 bool (*IsFormat)(SkStream*); | 17 bool (*IsFormat)(SkStream*); |
| 17 SkCodec* (*NewFromStream)(SkStream*); | 18 SkCodec* (*NewFromStream)(SkStream*); |
| 18 }; | 19 }; |
| 19 | 20 |
| 20 static const DecoderProc gDecoderProcs[] = { | 21 static const DecoderProc gDecoderProcs[] = { |
| 21 { SkPngCodec::IsPng, SkPngCodec::NewFromStream }, | 22 { SkPngCodec::IsPng, SkPngCodec::NewFromStream }, |
| 22 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, | 23 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, |
| 23 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream } | 24 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream }, |
| 25 { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream } |
| 24 }; | 26 }; |
| 25 | 27 |
| 26 SkCodec* SkCodec::NewFromStream(SkStream* stream) { | 28 SkCodec* SkCodec::NewFromStream(SkStream* stream) { |
| 27 if (!stream) { | 29 if (!stream) { |
| 28 return NULL; | 30 return NULL; |
| 29 } | 31 } |
| 30 for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) { | 32 for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) { |
| 31 DecoderProc proc = gDecoderProcs[i]; | 33 DecoderProc proc = gDecoderProcs[i]; |
| 32 const bool correctFormat = proc.IsFormat(stream); | 34 const bool correctFormat = proc.IsFormat(stream); |
| 33 if (!stream->rewind()) { | 35 if (!stream->rewind()) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 63 } | 65 } |
| 64 | 66 |
| 65 SkScanlineDecoder* SkCodec::getScanlineDecoder(const SkImageInfo& dstInfo) { | 67 SkScanlineDecoder* SkCodec::getScanlineDecoder(const SkImageInfo& dstInfo) { |
| 66 fScanlineDecoder.reset(NULL); | 68 fScanlineDecoder.reset(NULL); |
| 67 if (!rewindIfNeeded()) { | 69 if (!rewindIfNeeded()) { |
| 68 return NULL; | 70 return NULL; |
| 69 } | 71 } |
| 70 fScanlineDecoder.reset(this->onGetScanlineDecoder(dstInfo)); | 72 fScanlineDecoder.reset(this->onGetScanlineDecoder(dstInfo)); |
| 71 return fScanlineDecoder.get(); | 73 return fScanlineDecoder.get(); |
| 72 } | 74 } |
| OLD | NEW |