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 "SkScaledBitmapSampler.h" | 10 #include "SkScaledBitmapSampler.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 unsigned char* buf = (unsigned char*)autoMal.get(); | 41 unsigned char* buf = (unsigned char*)autoMal.get(); |
42 | 42 |
43 // Make sure original PKM header is there... | 43 // Make sure original PKM header is there... |
44 SkASSERT(etc1_pkm_is_valid(buf)); | 44 SkASSERT(etc1_pkm_is_valid(buf)); |
45 | 45 |
46 const unsigned short width = etc1_pkm_get_width(buf); | 46 const unsigned short width = etc1_pkm_get_width(buf); |
47 const unsigned short height = etc1_pkm_get_height(buf); | 47 const unsigned short height = etc1_pkm_get_height(buf); |
48 | 48 |
49 // should we allow the Chooser (if present) to pick a config for us??? | 49 // should we allow the Chooser (if present) to pick a config for us??? |
50 if (!this->chooseFromOneChoice(SkBitmap::kARGB_8888_Config, width, height))
{ | 50 if (!this->chooseFromOneChoice(kN32_SkColorType, width, height)) { |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 // Setup the sampler... | 54 // Setup the sampler... |
55 SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); | 55 SkScaledBitmapSampler sampler(width, height, this->getSampleSize()); |
56 | 56 |
57 // Set the config... | 57 // Set the config... |
58 bm->setConfig(SkBitmap::kARGB_8888_Config, sampler.scaledWidth(), sampler.sc
aledHeight(), | 58 bm->setInfo(SkImageInfo::MakeN32(sampler.scaledWidth(), sampler.scaledHeight
(), |
59 0, kOpaque_SkAlphaType); | 59 kOpaque_SkAlphaType)); |
60 if (SkImageDecoder::kDecodeBounds_Mode == mode) { | 60 if (SkImageDecoder::kDecodeBounds_Mode == mode) { |
61 return true; | 61 return true; |
62 } | 62 } |
63 | 63 |
64 if (!this->allocPixelRef(bm, NULL)) { | 64 if (!this->allocPixelRef(bm, NULL)) { |
65 return false; | 65 return false; |
66 } | 66 } |
67 | 67 |
68 // Lock the pixels, since we're about to write to them... | 68 // Lock the pixels, since we're about to write to them... |
69 SkAutoLockPixels alp(*bm); | 69 SkAutoLockPixels alp(*bm); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 static SkImageDecoder_DecodeReg gReg(sk_libpkm_dfactory); | 122 static SkImageDecoder_DecodeReg gReg(sk_libpkm_dfactory); |
123 | 123 |
124 static SkImageDecoder::Format get_format_pkm(SkStreamRewindable* stream) { | 124 static SkImageDecoder::Format get_format_pkm(SkStreamRewindable* stream) { |
125 if (is_pkm(stream)) { | 125 if (is_pkm(stream)) { |
126 return SkImageDecoder::kPKM_Format; | 126 return SkImageDecoder::kPKM_Format; |
127 } | 127 } |
128 return SkImageDecoder::kUnknown_Format; | 128 return SkImageDecoder::kUnknown_Format; |
129 } | 129 } |
130 | 130 |
131 static SkImageDecoder_FormatReg gFormatReg(get_format_pkm); | 131 static SkImageDecoder_FormatReg gFormatReg(get_format_pkm); |
OLD | NEW |