| 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_libpng.h" | 10 #include "SkCodec_libbmp.h" |
| 11 #include "SkStream.h" | 11 #include "SkStream.h" |
| 12 | 12 |
| 13 SkCodec* SkCodec::NewFromStream(SkStream* stream) { | 13 SkCodec* SkCodec::NewFromStream(SkStream* stream) { |
| 14 if (!stream) { | 14 if (!stream) { |
| 15 return NULL; | 15 return NULL; |
| 16 } | 16 } |
| 17 SkAutoTDelete<SkStream> streamDeleter(stream); | 17 SkAutoTDelete<SkStream> streamDeleter(stream); |
| 18 const bool isPng = SkPngCodec::IsPng(stream); | 18 const bool isBmp = SkBmpCodec::IsBmp(stream); |
| 19 if (!stream->rewind()) { | 19 if (!stream->rewind()) { |
| 20 return NULL; | 20 return NULL; |
| 21 } | 21 } |
| 22 if (isPng) { | 22 if (isBmp) { |
| 23 streamDeleter.detach(); | 23 streamDeleter.detach(); |
| 24 return SkPngCodec::NewFromStream(stream); | 24 return SkBmpCodec::NewFromStream(stream); |
| 25 } | 25 } |
| 26 // TODO: Check other image types. | 26 // TODO: Check other image types. |
| 27 return NULL; | 27 return NULL; |
| 28 } | 28 } |
| 29 | 29 |
| 30 SkCodec* SkCodec::NewFromData(SkData* data) { | 30 SkCodec* SkCodec::NewFromData(SkData* data) { |
| 31 if (!data) { | 31 if (!data) { |
| 32 return NULL; | 32 return NULL; |
| 33 } | 33 } |
| 34 return NewFromStream(SkNEW_ARGS(SkMemoryStream, (data))); | 34 return NewFromStream(SkNEW_ARGS(SkMemoryStream, (data))); |
| 35 } | 35 } |
| 36 | 36 |
| 37 SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream) | 37 SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream) |
| 38 : fInfo(info) | 38 : fInfo(info) |
| 39 , fStream(stream) | 39 , fStream(stream) |
| 40 {} | 40 {} |
| OLD | NEW |