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 "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 SkKTXFile ktxFile(data); | 57 SkKTXFile ktxFile(data); |
58 if (!ktxFile.valid()) { | 58 if (!ktxFile.valid()) { |
59 return kFailure; | 59 return kFailure; |
60 } | 60 } |
61 | 61 |
62 const unsigned short width = ktxFile.width(); | 62 const unsigned short width = ktxFile.width(); |
63 const unsigned short height = ktxFile.height(); | 63 const unsigned short height = ktxFile.height(); |
64 | 64 |
65 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER | |
66 // should we allow the Chooser (if present) to pick a config for us??? | |
67 if (!this->chooseFromOneChoice(kN32_SkColorType, width, height)) { | |
68 return kFailure; | |
69 } | |
70 #endif | |
71 | |
72 // Set a flag if our source is premultiplied alpha | 65 // Set a flag if our source is premultiplied alpha |
73 const SkString premulKey("KTXPremultipliedAlpha"); | 66 const SkString premulKey("KTXPremultipliedAlpha"); |
74 const bool bSrcIsPremul = ktxFile.getValueForKey(premulKey) == SkString("Tru
e"); | 67 const bool bSrcIsPremul = ktxFile.getValueForKey(premulKey) == SkString("Tru
e"); |
75 | 68 |
76 // Setup the sampler... | 69 // Setup the sampler... |
77 SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); | 70 SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); |
78 | 71 |
79 // Determine the alpha of the bitmap... | 72 // Determine the alpha of the bitmap... |
80 SkAlphaType alphaType = kOpaque_SkAlphaType; | 73 SkAlphaType alphaType = kOpaque_SkAlphaType; |
81 if (ktxFile.isRGBA8()) { | 74 if (ktxFile.isRGBA8()) { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 return SkImageDecoder::kUnknown_Format; | 321 return SkImageDecoder::kUnknown_Format; |
329 } | 322 } |
330 | 323 |
331 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { | 324 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { |
332 return (SkImageEncoder::kKTX_Type == t) ? SkNEW(SkKTXImageEncoder) : NULL; | 325 return (SkImageEncoder::kKTX_Type == t) ? SkNEW(SkKTXImageEncoder) : NULL; |
333 } | 326 } |
334 | 327 |
335 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); | 328 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); |
336 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); | 329 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); |
337 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); | 330 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); |
OLD | NEW |