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 "gm.h" | 8 #include "gm.h" |
9 #include "SkColor.h" | 9 #include "SkColor.h" |
10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 virtual SkString onShortName() { | 28 virtual SkString onShortName() { |
29 return SkString("imagefiltersscaled"); | 29 return SkString("imagefiltersscaled"); |
30 } | 30 } |
31 | 31 |
32 virtual SkISize onISize() { | 32 virtual SkISize onISize() { |
33 return make_isize(860, 500); | 33 return make_isize(860, 500); |
34 } | 34 } |
35 | 35 |
36 void make_checkerboard() { | 36 void make_checkerboard() { |
37 fCheckerboard.allocN32Pixels(64, 64); | 37 fCheckerboard.allocN32Pixels(64, 64); |
38 SkCanvas canvas(fCheckerboard); | 38 SkBitmapDevice device(fCheckerboard); |
| 39 SkCanvas canvas(&device); |
39 canvas.clear(0x00000000); | 40 canvas.clear(0x00000000); |
40 SkPaint darkPaint; | 41 SkPaint darkPaint; |
41 darkPaint.setColor(0xFF404040); | 42 darkPaint.setColor(0xFF404040); |
42 SkPaint lightPaint; | 43 SkPaint lightPaint; |
43 lightPaint.setColor(0xFFA0A0A0); | 44 lightPaint.setColor(0xFFA0A0A0); |
44 for (int y = 0; y < 64; y += 16) { | 45 for (int y = 0; y < 64; y += 16) { |
45 for (int x = 0; x < 64; x += 16) { | 46 for (int x = 0; x < 64; x += 16) { |
46 canvas.save(); | 47 canvas.save(); |
47 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); | 48 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); |
48 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); | 49 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); |
49 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint); | 50 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint); |
50 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint); | 51 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint); |
51 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); | 52 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); |
52 canvas.restore(); | 53 canvas.restore(); |
53 } | 54 } |
54 } | 55 } |
55 } | 56 } |
56 | 57 |
57 void make_gradient_circle(int width, int height) { | 58 void make_gradient_circle(int width, int height) { |
58 SkScalar x = SkIntToScalar(width / 2); | 59 SkScalar x = SkIntToScalar(width / 2); |
59 SkScalar y = SkIntToScalar(height / 2); | 60 SkScalar y = SkIntToScalar(height / 2); |
60 SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIn
tToScalar(5)); | 61 SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIn
tToScalar(5)); |
61 fGradientCircle.allocN32Pixels(width, height); | 62 fGradientCircle.allocN32Pixels(width, height); |
62 SkCanvas canvas(fGradientCircle); | 63 SkBitmapDevice device(fGradientCircle); |
| 64 SkCanvas canvas(&device); |
63 canvas.clear(0x00000000); | 65 canvas.clear(0x00000000); |
64 SkColor colors[2]; | 66 SkColor colors[2]; |
65 colors[0] = SK_ColorWHITE; | 67 colors[0] = SK_ColorWHITE; |
66 colors[1] = SK_ColorBLACK; | 68 colors[1] = SK_ColorBLACK; |
67 SkAutoTUnref<SkShader> shader( | 69 SkAutoTUnref<SkShader> shader( |
68 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors,
NULL, 2, | 70 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors,
NULL, 2, |
69 SkShader::kClamp_TileMode) | 71 SkShader::kClamp_TileMode) |
70 ); | 72 ); |
71 SkPaint paint; | 73 SkPaint paint; |
72 paint.setShader(shader); | 74 paint.setShader(shader); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 SkBitmap fGradientCircle; | 145 SkBitmap fGradientCircle; |
144 typedef GM INHERITED; | 146 typedef GM INHERITED; |
145 }; | 147 }; |
146 | 148 |
147 ////////////////////////////////////////////////////////////////////////////// | 149 ////////////////////////////////////////////////////////////////////////////// |
148 | 150 |
149 static GM* MyFactory(void*) { return new ImageFiltersScaledGM; } | 151 static GM* MyFactory(void*) { return new ImageFiltersScaledGM; } |
150 static GMRegistry reg(MyFactory); | 152 static GMRegistry reg(MyFactory); |
151 | 153 |
152 } | 154 } |
OLD | NEW |