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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 SkKTXFile ktxFile(data); | 57 SkKTXFile ktxFile(data); |
58 if (!ktxFile.valid()) { | 58 if (!ktxFile.valid()) { |
59 return false; | 59 return false; |
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 // should we allow the Chooser (if present) to pick a config for us??? | 65 // should we allow the Chooser (if present) to pick a config for us??? |
66 if (!this->chooseFromOneChoice(SkBitmap::kARGB_8888_Config, width, height))
{ | 66 if (!this->chooseFromOneChoice(kN32_SkColorType, width, height)) { |
67 return false; | 67 return false; |
68 } | 68 } |
69 | 69 |
70 // Setup the sampler... | 70 // Setup the sampler... |
71 SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); | 71 SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); |
72 | 72 |
73 // Set the config... | 73 // Set the config... |
74 bm->setConfig(SkBitmap::kARGB_8888_Config, | 74 bm->setInfo(SkImageInfo::MakeN32(sampler.scaledWidth(), sampler.scaledHeight
(), |
75 sampler.scaledWidth(), sampler.scaledHeight(), | 75 ktxFile.isRGBA8()? kPremul_SkAlphaType : kO
paque_SkAlphaType)); |
76 0, | |
77 ktxFile.isRGBA8()? kPremul_SkAlphaType : kOpaque_SkAlphaType); | |
78 if (SkImageDecoder::kDecodeBounds_Mode == mode) { | 76 if (SkImageDecoder::kDecodeBounds_Mode == mode) { |
79 return true; | 77 return true; |
80 } | 78 } |
81 | 79 |
82 // If we've made it this far, then we know how to grok the data. | 80 // If we've made it this far, then we know how to grok the data. |
83 if (!this->allocPixelRef(bm, NULL)) { | 81 if (!this->allocPixelRef(bm, NULL)) { |
84 return false; | 82 return false; |
85 } | 83 } |
86 | 84 |
87 // Lock the pixels, since we're about to write to them... | 85 // Lock the pixels, since we're about to write to them... |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 return SkImageDecoder::kUnknown_Format; | 251 return SkImageDecoder::kUnknown_Format; |
254 } | 252 } |
255 | 253 |
256 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { | 254 SkImageEncoder* sk_libktx_efactory(SkImageEncoder::Type t) { |
257 return (SkImageEncoder::kKTX_Type == t) ? SkNEW(SkKTXImageEncoder) : NULL; | 255 return (SkImageEncoder::kKTX_Type == t) ? SkNEW(SkKTXImageEncoder) : NULL; |
258 } | 256 } |
259 | 257 |
260 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); | 258 static SkImageDecoder_DecodeReg gReg(sk_libktx_dfactory); |
261 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); | 259 static SkImageDecoder_FormatReg gFormatReg(get_format_ktx); |
262 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); | 260 static SkImageEncoder_EncodeReg gEReg(sk_libktx_efactory); |
OLD | NEW |