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 "SkData.h" | 8 #include "SkData.h" |
9 #include "SkEndian.h" | 9 #include "SkEndian.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 static inline int read_24bit(const uint8_t* buf) { | 38 static inline int read_24bit(const uint8_t* buf) { |
39 // Assume everything is little endian... | 39 // Assume everything is little endian... |
40 return | 40 return |
41 static_cast<int>(buf[0]) | | 41 static_cast<int>(buf[0]) | |
42 (static_cast<int>(buf[1]) << 8) | | 42 (static_cast<int>(buf[1]) << 8) | |
43 (static_cast<int>(buf[2]) << 16); | 43 (static_cast<int>(buf[2]) << 16); |
44 } | 44 } |
45 | 45 |
46 SkImageDecoder::Result SkASTCImageDecoder::onDecode(SkStream* stream, SkBitmap*
bm, Mode mode) { | 46 SkImageDecoder::Result SkASTCImageDecoder::onDecode(SkStream* stream, SkBitmap*
bm, Mode mode) { |
47 SkAutoTUnref<SkData> data(SkCopyStreamToData(stream)); | 47 auto data = SkCopyStreamToData(stream); |
48 if (!data || !data->size()) { | 48 if (!data || !data->size()) { |
49 return kFailure; | 49 return kFailure; |
50 } | 50 } |
51 | 51 |
52 unsigned char* buf = (unsigned char*) data->data(); | 52 unsigned char* buf = (unsigned char*) data->data(); |
53 | 53 |
54 // Make sure that the magic header is there... | 54 // Make sure that the magic header is there... |
55 SkASSERT(SkEndian_SwapLE32(*(reinterpret_cast<uint32_t*>(buf))) == kASTCMagi
cNumber); | 55 SkASSERT(SkEndian_SwapLE32(*(reinterpret_cast<uint32_t*>(buf))) == kASTCMagi
cNumber); |
56 | 56 |
57 // Advance past the magic header | 57 // Advance past the magic header |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 static SkImageDecoder_DecodeReg gReg(sk_libastc_dfactory); | 194 static SkImageDecoder_DecodeReg gReg(sk_libastc_dfactory); |
195 | 195 |
196 static SkImageDecoder::Format get_format_astc(SkStreamRewindable* stream) { | 196 static SkImageDecoder::Format get_format_astc(SkStreamRewindable* stream) { |
197 if (is_astc(stream)) { | 197 if (is_astc(stream)) { |
198 return SkImageDecoder::kASTC_Format; | 198 return SkImageDecoder::kASTC_Format; |
199 } | 199 } |
200 return SkImageDecoder::kUnknown_Format; | 200 return SkImageDecoder::kUnknown_Format; |
201 } | 201 } |
202 | 202 |
203 static SkImageDecoder_FormatReg gFormatReg(get_format_astc); | 203 static SkImageDecoder_FormatReg gFormatReg(get_format_astc); |
OLD | NEW |