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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 static SkImage* make_raster_image(int width, int height, SkColor colors[2]) { | 26 static SkImage* make_raster_image(int width, int height, SkColor colors[2]) { |
27 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height)
); | 27 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height)
); |
28 draw(surface->getCanvas(), width, height, colors); | 28 draw(surface->getCanvas(), width, height, colors); |
29 return surface->newImageSnapshot(); | 29 return surface->newImageSnapshot(); |
30 } | 30 } |
31 | 31 |
32 static SkImage* make_picture_image(int width, int height, SkColor colors[2]) { | 32 static SkImage* make_picture_image(int width, int height, SkColor colors[2]) { |
33 SkPictureRecorder recorder; | 33 SkPictureRecorder recorder; |
34 draw(recorder.beginRecording(SkRect::MakeIWH(width, height)), width, height,
colors); | 34 draw(recorder.beginRecording(SkRect::MakeIWH(width, height)), width, height,
colors); |
35 return SkImage::NewFromPicture(recorder.endRecording(), SkISize::Make(width,
height), | 35 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
| 36 return SkImage::NewFromPicture(picture, SkISize::Make(width, height), |
36 nullptr, nullptr); | 37 nullptr, nullptr); |
37 } | 38 } |
38 | 39 |
39 typedef SkImage* (*ImageMakerProc)(int width, int height, SkColor colors[2]); | 40 typedef SkImage* (*ImageMakerProc)(int width, int height, SkColor colors[2]); |
40 | 41 |
41 static void show_image(SkCanvas* canvas, int width, int height, SkColor colors[2
], | 42 static void show_image(SkCanvas* canvas, int width, int height, SkColor colors[2
], |
42 ImageMakerProc proc) { | 43 ImageMakerProc proc) { |
43 SkAutoTUnref<SkImage> image(proc(width, height, colors)); | 44 SkAutoTUnref<SkImage> image(proc(width, height, colors)); |
44 | 45 |
45 SkPaint paint; | 46 SkPaint paint; |
(...skipping 69 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) | 116 // since it has a 64K limit on x,y coordinates... (but gpu should succee
d) |
116 show_image(canvas, veryBig, small, colors, fProc); | 117 show_image(canvas, veryBig, small, colors, fProc); |
117 } | 118 } |
118 | 119 |
119 private: | 120 private: |
120 typedef skiagm::GM INHERITED; | 121 typedef skiagm::GM INHERITED; |
121 }; | 122 }; |
122 DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "bitmap"); ) | 123 DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "bitmap"); ) |
123 DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "_picture_image"); ) | 124 DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "_picture_image"); ) |
124 | 125 |
OLD | NEW |