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" |
11 #include "SkPath.h" | 11 #include "SkPath.h" |
12 #include "SkPictureRecorder.h" | 12 #include "SkPictureRecorder.h" |
13 #include "SkSurface.h" | 13 #include "SkSurface.h" |
14 | 14 |
15 static void draw(SkCanvas* canvas, int width, int height, SkColor colors[2]) { | 15 static void draw(SkCanvas* canvas, int width, int height, SkColor colors[2]) { |
16 const SkPoint center = { SkIntToScalar(width)/2, SkIntToScalar(height)/2 }; | 16 const SkPoint center = { SkIntToScalar(width)/2, SkIntToScalar(height)/2 }; |
17 const SkScalar radius = 40; | 17 const SkScalar radius = 40; |
18 SkShader* shader = SkGradientShader::CreateRadial(center, radius, colors, nu
llptr, 2, | |
19 SkShader::kMirror_TileMode
); | |
20 SkPaint paint; | 18 SkPaint paint; |
21 paint.setShader(shader)->unref(); | 19 paint.setShader(SkGradientShader::MakeRadial(center, radius, colors, nullptr
, 2, |
| 20 SkShader::kMirror_TileMode)); |
22 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 21 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
23 canvas->drawPaint(paint); | 22 canvas->drawPaint(paint); |
24 } | 23 } |
25 | 24 |
26 static SkImage* make_raster_image(int width, int height, SkColor colors[2]) { | 25 static SkImage* make_raster_image(int width, int height, SkColor colors[2]) { |
27 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height)
); | 26 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height)
); |
28 draw(surface->getCanvas(), width, height, colors); | 27 draw(surface->getCanvas(), width, height, colors); |
29 return surface->newImageSnapshot(); | 28 return surface->newImageSnapshot(); |
30 } | 29 } |
31 | 30 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // since it has a 64K limit on x,y coordinates... (but gpu should succee
d) | 115 // since it has a 64K limit on x,y coordinates... (but gpu should succee
d) |
117 show_image(canvas, veryBig, small, colors, fProc); | 116 show_image(canvas, veryBig, small, colors, fProc); |
118 } | 117 } |
119 | 118 |
120 private: | 119 private: |
121 typedef skiagm::GM INHERITED; | 120 typedef skiagm::GM INHERITED; |
122 }; | 121 }; |
123 DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "bitmap"); ) | 122 DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "bitmap"); ) |
124 DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "_picture_image"); ) | 123 DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "_picture_image"); ) |
125 | 124 |
OLD | NEW |