| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 static sk_sp<SkImage> make_raster_image(int width, int height, SkColor colors[2]
) { | 25 static sk_sp<SkImage> make_raster_image(int width, int height, SkColor colors[2]
) { |
| 26 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height)
); | 26 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height)
); |
| 27 draw(surface->getCanvas(), width, height, colors); | 27 draw(surface->getCanvas(), width, height, colors); |
| 28 return surface->makeImageSnapshot(); | 28 return surface->makeImageSnapshot(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 static sk_sp<SkImage> make_picture_image(int width, int height, SkColor colors[2
]) { | 31 static sk_sp<SkImage> make_picture_image(int width, int height, SkColor colors[2
]) { |
| 32 SkPictureRecorder recorder; | 32 SkPictureRecorder recorder; |
| 33 draw(recorder.beginRecording(SkRect::MakeIWH(width, height)), width, height,
colors); | 33 draw(recorder.beginRecording(SkRect::MakeIWH(width, height)), width, height,
colors); |
| 34 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 34 return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(), |
| 35 return SkImage::MakeFromPicture(sk_ref_sp(picture.get()), SkISize::Make(widt
h, height), | 35 SkISize::Make(width, height), nullptr, nullp
tr); |
| 36 nullptr, nullptr); | |
| 37 } | 36 } |
| 38 | 37 |
| 39 typedef sk_sp<SkImage> (*ImageMakerProc)(int width, int height, SkColor colors[2
]); | 38 typedef sk_sp<SkImage> (*ImageMakerProc)(int width, int height, SkColor colors[2
]); |
| 40 | 39 |
| 41 static void show_image(SkCanvas* canvas, int width, int height, SkColor colors[2
], | 40 static void show_image(SkCanvas* canvas, int width, int height, SkColor colors[2
], |
| 42 ImageMakerProc proc) { | 41 ImageMakerProc proc) { |
| 43 sk_sp<SkImage> image(proc(width, height, colors)); | 42 sk_sp<SkImage> image(proc(width, height, colors)); |
| 44 | 43 |
| 45 SkPaint paint; | 44 SkPaint paint; |
| 46 SkRect r; | 45 SkRect r; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // since it has a 64K limit on x,y coordinates... (but gpu should succee
d) | 114 // since it has a 64K limit on x,y coordinates... (but gpu should succee
d) |
| 116 show_image(canvas, veryBig, small, colors, fProc); | 115 show_image(canvas, veryBig, small, colors, fProc); |
| 117 } | 116 } |
| 118 | 117 |
| 119 private: | 118 private: |
| 120 typedef skiagm::GM INHERITED; | 119 typedef skiagm::GM INHERITED; |
| 121 }; | 120 }; |
| 122 DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "bitmap"); ) | 121 DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "bitmap"); ) |
| 123 DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "_picture_image"); ) | 122 DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "_picture_image"); ) |
| 124 | 123 |
| OLD | NEW |