OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 protected: | 27 protected: |
28 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) override; | 28 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) override; |
29 | 29 |
30 private: | 30 private: |
31 typedef SkImageDecoder INHERITED; | 31 typedef SkImageDecoder INHERITED; |
32 }; | 32 }; |
33 | 33 |
34 ////////////////////////////////////////////////////////////////////////////////
///////// | 34 ////////////////////////////////////////////////////////////////////////////////
///////// |
35 | 35 |
36 SkImageDecoder::Result SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* b
m, Mode mode) { | 36 SkImageDecoder::Result SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* b
m, Mode mode) { |
37 SkAutoTUnref<SkData> data(SkCopyStreamToData(stream)); | 37 sk_sp<SkData> data(SkCopyStreamToData(stream)); |
38 if (!data || !data->size()) { | 38 if (!data || !data->size()) { |
39 return kFailure; | 39 return kFailure; |
40 } | 40 } |
41 | 41 |
42 unsigned char* buf = (unsigned char*) data->data(); | 42 unsigned char* buf = (unsigned char*) data->data(); |
43 | 43 |
44 // Make sure original PKM header is there... | 44 // Make sure original PKM header is there... |
45 SkASSERT(etc1_pkm_is_valid(buf)); | 45 SkASSERT(etc1_pkm_is_valid(buf)); |
46 | 46 |
47 const unsigned short width = etc1_pkm_get_width(buf); | 47 const unsigned short width = etc1_pkm_get_width(buf); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 static SkImageDecoder_DecodeReg gReg(sk_libpkm_dfactory); | 119 static SkImageDecoder_DecodeReg gReg(sk_libpkm_dfactory); |
120 | 120 |
121 static SkImageDecoder::Format get_format_pkm(SkStreamRewindable* stream) { | 121 static SkImageDecoder::Format get_format_pkm(SkStreamRewindable* stream) { |
122 if (is_pkm(stream)) { | 122 if (is_pkm(stream)) { |
123 return SkImageDecoder::kPKM_Format; | 123 return SkImageDecoder::kPKM_Format; |
124 } | 124 } |
125 return SkImageDecoder::kUnknown_Format; | 125 return SkImageDecoder::kUnknown_Format; |
126 } | 126 } |
127 | 127 |
128 static SkImageDecoder_FormatReg gFormatReg(get_format_pkm); | 128 static SkImageDecoder_FormatReg gFormatReg(get_format_pkm); |
OLD | NEW |