OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 static SkImage* MakeGradientCircle(int width, int height) { | 138 static SkImage* MakeGradientCircle(int width, int height) { |
139 SkScalar x = SkIntToScalar(width / 2); | 139 SkScalar x = SkIntToScalar(width / 2); |
140 SkScalar y = SkIntToScalar(height / 2); | 140 SkScalar y = SkIntToScalar(height / 2); |
141 SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIn
tToScalar(5)); | 141 SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIn
tToScalar(5)); |
142 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, hei
ght)); | 142 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, hei
ght)); |
143 SkCanvas* canvas = surface->getCanvas(); | 143 SkCanvas* canvas = surface->getCanvas(); |
144 canvas->clear(0x00000000); | 144 canvas->clear(0x00000000); |
145 SkColor colors[2]; | 145 SkColor colors[2]; |
146 colors[0] = SK_ColorWHITE; | 146 colors[0] = SK_ColorWHITE; |
147 colors[1] = SK_ColorBLACK; | 147 colors[1] = SK_ColorBLACK; |
| 148 SkAutoTUnref<SkShader> shader( |
| 149 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors,
nullptr, 2, |
| 150 SkShader::kClamp_TileMode) |
| 151 ); |
148 SkPaint paint; | 152 SkPaint paint; |
149 paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(x, y), radius
, colors, nullptr, | 153 paint.setShader(shader); |
150 2, SkShader::kClamp_TileMod
e)); | |
151 canvas->drawCircle(x, y, radius, paint); | 154 canvas->drawCircle(x, y, radius, paint); |
152 | 155 |
153 return surface->newImageSnapshot(); | 156 return surface->newImageSnapshot(); |
154 } | 157 } |
155 | 158 |
156 SkAutoTUnref<SkImage> fCheckerboard, fGradientCircle; | 159 SkAutoTUnref<SkImage> fCheckerboard, fGradientCircle; |
157 | 160 |
158 typedef GM INHERITED; | 161 typedef GM INHERITED; |
159 }; | 162 }; |
160 | 163 |
161 ////////////////////////////////////////////////////////////////////////////// | 164 ////////////////////////////////////////////////////////////////////////////// |
162 | 165 |
163 DEF_GM(return new ImageFiltersScaledGM;) | 166 DEF_GM(return new ImageFiltersScaledGM;) |
164 } | 167 } |
OLD | NEW |