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 "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
10 #include "SkImageGenerator.h" | 10 #include "SkImageGenerator.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 protected: | 44 protected: |
45 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) override; | 45 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) override; |
46 | 46 |
47 private: | 47 private: |
48 typedef SkImageDecoder INHERITED; | 48 typedef SkImageDecoder INHERITED; |
49 }; | 49 }; |
50 | 50 |
51 SkImageDecoder::Result SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* b
m, Mode mode) { | 51 SkImageDecoder::Result SkKTXImageDecoder::onDecode(SkStream* stream, SkBitmap* b
m, Mode mode) { |
52 // TODO: Implement SkStream::copyToData() that's cheap for memory and file s
treams | 52 // TODO: Implement SkStream::copyToData() that's cheap for memory and file s
treams |
53 SkAutoDataUnref data(SkCopyStreamToData(stream)); | 53 auto data = SkCopyStreamToData(stream); |
54 if (nullptr == data) { | 54 if (nullptr == data) { |
55 return kFailure; | 55 return kFailure; |
56 } | 56 } |
57 | 57 |
58 SkKTXFile ktxFile(data); | 58 SkKTXFile ktxFile(data.get()); |
59 if (!ktxFile.valid()) { | 59 if (!ktxFile.valid()) { |
60 return kFailure; | 60 return kFailure; |
61 } | 61 } |
62 | 62 |
63 const unsigned short width = ktxFile.width(); | 63 const unsigned short width = ktxFile.width(); |
64 const unsigned short height = ktxFile.height(); | 64 const unsigned short height = ktxFile.height(); |
65 | 65 |
66 // Set a flag if our source is premultiplied alpha | 66 // Set a flag if our source is premultiplied alpha |
67 const SkString premulKey("KTXPremultipliedAlpha"); | 67 const SkString premulKey("KTXPremultipliedAlpha"); |
68 const bool bSrcIsPremul = ktxFile.getValueForKey(premulKey) == SkString("Tru
e"); | 68 const bool bSrcIsPremul = ktxFile.getValueForKey(premulKey) == SkString("Tru
e"); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 return SkImageDecoder::kUnknown_Format; | 322 return SkImageDecoder::kUnknown_Format; |
323 } | 323 } |
324 | 324 |
325 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { | 325 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { |
326 return (SkImageEncoder::kKTX_Type == t) ? new SkKTXImageEncoder : nullptr; | 326 return (SkImageEncoder::kKTX_Type == t) ? new SkKTXImageEncoder : nullptr; |
327 } | 327 } |
328 | 328 |
329 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); | 329 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); |
330 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); | 330 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); |
331 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); | 331 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); |
OLD | NEW |