OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "Resources.h" | 10 #include "Resources.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 : INHERITED(filterQuality), fFilename(filename) | 164 : INHERITED(filterQuality), fFilename(filename) |
165 { | 165 { |
166 fName.printf("downsamplebitmap_image_%s_%s", this->filterQualityToSt
ring(), filename); | 166 fName.printf("downsamplebitmap_image_%s_%s", this->filterQualityToSt
ring(), filename); |
167 } | 167 } |
168 | 168 |
169 protected: | 169 protected: |
170 SkString fFilename; | 170 SkString fFilename; |
171 int fSize; | 171 int fSize; |
172 | 172 |
173 void make_bitmap() override { | 173 void make_bitmap() override { |
174 SkImageDecoder* codec = NULL; | 174 SkImageDecoder* codec = nullptr; |
175 SkString resourcePath = GetResourcePath(fFilename.c_str()); | 175 SkString resourcePath = GetResourcePath(fFilename.c_str()); |
176 SkFILEStream stream(resourcePath.c_str()); | 176 SkFILEStream stream(resourcePath.c_str()); |
177 if (stream.isValid()) { | 177 if (stream.isValid()) { |
178 codec = SkImageDecoder::Factory(&stream); | 178 codec = SkImageDecoder::Factory(&stream); |
179 } | 179 } |
180 if (codec) { | 180 if (codec) { |
181 stream.rewind(); | 181 stream.rewind(); |
182 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe
codePixels_Mode); | 182 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe
codePixels_Mode); |
183 delete codec; | 183 delete codec; |
184 } else { | 184 } else { |
(...skipping 27 matching lines...) Expand all Loading... |
212 return SkString("showmiplevels"); | 212 return SkString("showmiplevels"); |
213 } | 213 } |
214 | 214 |
215 SkISize onISize() override { | 215 SkISize onISize() override { |
216 return SkISize::Make(fBM.width() + 8, 2 * fBM.height() + 80); | 216 return SkISize::Make(fBM.width() + 8, 2 * fBM.height() + 80); |
217 } | 217 } |
218 | 218 |
219 void onDraw(SkCanvas* canvas) override { | 219 void onDraw(SkCanvas* canvas) override { |
220 SkScalar x = 4; | 220 SkScalar x = 4; |
221 SkScalar y = 4; | 221 SkScalar y = 4; |
222 canvas->drawBitmap(fBM, x, y, NULL); | 222 canvas->drawBitmap(fBM, x, y, nullptr); |
223 y += fBM.height() + 4; | 223 y += fBM.height() + 4; |
224 | 224 |
225 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(fBM, NULL)); | 225 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(fBM, nullptr)); |
226 | 226 |
227 SkMipMap::Level level; | 227 SkMipMap::Level level; |
228 SkScalar scale = 0.5f; | 228 SkScalar scale = 0.5f; |
229 while (mm->extractLevel(scale, &level)) { | 229 while (mm->extractLevel(scale, &level)) { |
230 SkImageInfo info = SkImageInfo::MakeN32Premul(level.fWidth, level.fH
eight); | 230 SkImageInfo info = SkImageInfo::MakeN32Premul(level.fWidth, level.fH
eight); |
231 SkBitmap bm; | 231 SkBitmap bm; |
232 bm.installPixels(info, level.fPixels, level.fRowBytes, NULL, | 232 bm.installPixels(info, level.fPixels, level.fRowBytes, nullptr, |
233 &release_mipmap, (void*)(SkRef(mm.get()))); | 233 &release_mipmap, (void*)(SkRef(mm.get()))); |
234 bm.setImmutable(); | 234 bm.setImmutable(); |
235 canvas->drawBitmap(bm, x, y, NULL); | 235 canvas->drawBitmap(bm, x, y, nullptr); |
236 y += bm.height() + 4; | 236 y += bm.height() + 4; |
237 scale /= 2; | 237 scale /= 2; |
238 if (info.width() == 1 || info.height() == 1) { | 238 if (info.width() == 1 || info.height() == 1) { |
239 break; | 239 break; |
240 } | 240 } |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
244 private: | 244 private: |
245 typedef skiagm::GM INHERITED; | 245 typedef skiagm::GM INHERITED; |
(...skipping 18 matching lines...) Expand all Loading... |
264 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kLow_SkFilterQuality)
; ) | 264 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kLow_SkFilterQuality)
; ) |
265 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kLow_SkFilterQual
ity); ) | 265 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kLow_SkFilterQual
ity); ) |
266 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", | 266 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", |
267 kLow_SkFilterQuality); ) | 267 kLow_SkFilterQuality); ) |
268 | 268 |
269 DEF_GM( return new DownsampleBitmapTextGM(72, kNone_SkFilterQuality); ) | 269 DEF_GM( return new DownsampleBitmapTextGM(72, kNone_SkFilterQuality); ) |
270 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kNone_SkFilterQuality
); ) | 270 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kNone_SkFilterQuality
); ) |
271 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kNone_SkFilterQua
lity); ) | 271 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kNone_SkFilterQua
lity); ) |
272 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", | 272 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", |
273 kNone_SkFilterQuality); ) | 273 kNone_SkFilterQuality); ) |
OLD | NEW |