OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 SkAutoCanvasRestore acr(canvas, true); | 207 SkAutoCanvasRestore acr(canvas, true); |
208 | 208 |
209 canvas->drawImage(image, 0, 0, nullptr); | 209 canvas->drawImage(image, 0, 0, nullptr); |
210 canvas->translate(110, 10); | 210 canvas->translate(110, 10); |
211 | 211 |
212 const SkImageInfo info = SkImageInfo::MakeN32Premul(40, 40); | 212 const SkImageInfo info = SkImageInfo::MakeN32Premul(40, 40); |
213 SkAutoPixmapStorage storage; | 213 SkAutoPixmapStorage storage; |
214 storage.alloc(info); | 214 storage.alloc(info); |
215 | 215 |
216 const SkImage::CachingHint chints[] = { | 216 const SkImage::CachingHint chints[] = { |
217 SkImage::kAllow_CachingHint, // SkImage::kDisallow_CachingHint, | 217 SkImage::kAllow_CachingHint, SkImage::kDisallow_CachingHint, |
218 }; | 218 }; |
219 const SkFilterQuality qualities[] = { | 219 const SkFilterQuality qualities[] = { |
220 kNone_SkFilterQuality, kLow_SkFilterQuality, kMedium_SkFilterQuality, kH
igh_SkFilterQuality, | 220 kNone_SkFilterQuality, kLow_SkFilterQuality, kMedium_SkFilterQuality, kH
igh_SkFilterQuality, |
221 }; | 221 }; |
222 | 222 |
223 for (auto ch : chints) { | 223 for (auto ch : chints) { |
224 canvas->save(); | 224 canvas->save(); |
225 for (auto q : qualities) { | 225 for (auto q : qualities) { |
226 if (image->scalePixels(storage, q, ch)) { | 226 if (image->scalePixels(storage, q, ch)) { |
227 draw_pixmap(canvas, storage); | 227 draw_pixmap(canvas, storage); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 278 } |
279 | 279 |
280 SkISize onISize() override { | 280 SkISize onISize() override { |
281 return SkISize::Make(960, 1200); | 281 return SkISize::Make(960, 1200); |
282 } | 282 } |
283 | 283 |
284 void onDraw(SkCanvas* canvas) override { | 284 void onDraw(SkCanvas* canvas) override { |
285 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); | 285 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
286 | 286 |
287 const ImageMakerProc procs[] = { | 287 const ImageMakerProc procs[] = { |
288 make_raster, make_picture, make_codec, make_gpu, | 288 make_codec, make_raster, make_picture, make_codec, make_gpu, |
289 }; | 289 }; |
290 for (auto& proc : procs) { | 290 for (auto& proc : procs) { |
291 SkAutoTUnref<SkImage> image(proc(info, canvas->getGrContext())); | 291 SkAutoTUnref<SkImage> image(proc(info, canvas->getGrContext())); |
292 if (image) { | 292 if (image) { |
293 show_scaled_pixels(canvas, image); | 293 show_scaled_pixels(canvas, image); |
294 } | 294 } |
295 canvas->translate(0, 120); | 295 canvas->translate(0, 120); |
296 } | 296 } |
297 } | 297 } |
298 | 298 |
299 private: | 299 private: |
300 typedef skiagm::GM INHERITED; | 300 typedef skiagm::GM INHERITED; |
301 }; | 301 }; |
302 DEF_GM( return new ScalePixelsGM; ) | 302 DEF_GM( return new ScalePixelsGM; ) |
OLD | NEW |