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 "SkEndian.h" | 8 #include "SkEndian.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 alphaType = kPremul_SkAlphaType; | 128 alphaType = kPremul_SkAlphaType; |
129 } | 129 } |
130 | 130 |
131 // Set the config... | 131 // Set the config... |
132 bm->setInfo(SkImageInfo::MakeN32(sampler.scaledWidth(), sampler.scaledHeight
(), alphaType)); | 132 bm->setInfo(SkImageInfo::MakeN32(sampler.scaledWidth(), sampler.scaledHeight
(), alphaType)); |
133 | 133 |
134 if (SkImageDecoder::kDecodeBounds_Mode == mode) { | 134 if (SkImageDecoder::kDecodeBounds_Mode == mode) { |
135 return kSuccess; | 135 return kSuccess; |
136 } | 136 } |
137 | 137 |
138 if (!this->allocPixelRef(bm, NULL)) { | 138 if (!this->allocPixelRef(bm, nullptr)) { |
139 return kFailure; | 139 return kFailure; |
140 } | 140 } |
141 | 141 |
142 // Lock the pixels, since we're about to write to them... | 142 // Lock the pixels, since we're about to write to them... |
143 SkAutoLockPixels alp(*bm); | 143 SkAutoLockPixels alp(*bm); |
144 | 144 |
145 if (!sampler.begin(bm, SkScaledBitmapSampler::kRGBA, *this)) { | 145 if (!sampler.begin(bm, SkScaledBitmapSampler::kRGBA, *this)) { |
146 return kFailure; | 146 return kFailure; |
147 } | 147 } |
148 | 148 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 return false; | 181 return false; |
182 } | 182 } |
183 | 183 |
184 return kASTCMagicNumber == SkEndian_SwapLE32(magic); | 184 return kASTCMagicNumber == SkEndian_SwapLE32(magic); |
185 } | 185 } |
186 | 186 |
187 static SkImageDecoder* sk_libastc_dfactory(SkStreamRewindable* stream) { | 187 static SkImageDecoder* sk_libastc_dfactory(SkStreamRewindable* stream) { |
188 if (is_astc(stream)) { | 188 if (is_astc(stream)) { |
189 return new SkASTCImageDecoder; | 189 return new SkASTCImageDecoder; |
190 } | 190 } |
191 return NULL; | 191 return nullptr; |
192 } | 192 } |
193 | 193 |
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 |