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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 SkScalar x = SkIntToScalar(width / 2); | 61 SkScalar x = SkIntToScalar(width / 2); |
62 SkScalar y = SkIntToScalar(height / 2); | 62 SkScalar y = SkIntToScalar(height / 2); |
63 SkScalar radius = SkMinScalar(x, y) * 0.8f; | 63 SkScalar radius = SkMinScalar(x, y) * 0.8f; |
64 bitmap->allocN32Pixels(width, height); | 64 bitmap->allocN32Pixels(width, height); |
65 SkCanvas canvas(*bitmap); | 65 SkCanvas canvas(*bitmap); |
66 canvas.clear(0x00000000); | 66 canvas.clear(0x00000000); |
67 SkColor colors[2]; | 67 SkColor colors[2]; |
68 colors[0] = SK_ColorWHITE; | 68 colors[0] = SK_ColorWHITE; |
69 colors[1] = SK_ColorBLACK; | 69 colors[1] = SK_ColorBLACK; |
70 SkAutoTUnref<SkShader> shader( | 70 SkAutoTUnref<SkShader> shader( |
71 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors,
NULL, 2, | 71 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors,
nullptr, 2, |
72 SkShader::kClamp_TileMode) | 72 SkShader::kClamp_TileMode) |
73 ); | 73 ); |
74 SkPaint paint; | 74 SkPaint paint; |
75 paint.setShader(shader); | 75 paint.setShader(shader); |
76 canvas.drawCircle(x, y, radius, paint); | 76 canvas.drawCircle(x, y, radius, paint); |
77 } | 77 } |
78 | 78 |
79 static void draw(SkCanvas* canvas, const SkBitmap& bitmap, const SkRect& rec
t, SkImageFilter* filter) { | 79 static void draw(SkCanvas* canvas, const SkBitmap& bitmap, const SkRect& rec
t, SkImageFilter* filter) { |
80 SkPaint paint; | 80 SkPaint paint; |
81 paint.setImageFilter(filter)->unref(); | 81 paint.setImageFilter(filter)->unref(); |
(...skipping 16 matching lines...) Expand all Loading... |
98 SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)), | 98 SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)), |
99 SkImageFilter::CropRect::kHasAll_CropEdge); | 99 SkImageFilter::CropRect::kHasAll_CropEdge); |
100 | 100 |
101 SkBitmap gradient_circle, checkerboard; | 101 SkBitmap gradient_circle, checkerboard; |
102 make_gradient_circle(64, 64, &gradient_circle); | 102 make_gradient_circle(64, 64, &gradient_circle); |
103 make_checkerboard(&checkerboard); | 103 make_checkerboard(&checkerboard); |
104 | 104 |
105 SkAutoTUnref<SkImageFilter> gradient_circle_source( | 105 SkAutoTUnref<SkImageFilter> gradient_circle_source( |
106 SkBitmapSource::Create(gradient_circle)); | 106 SkBitmapSource::Create(gradient_circle)); |
107 SkAutoTUnref<SkImageFilter> noop_cropped( | 107 SkAutoTUnref<SkImageFilter> noop_cropped( |
108 SkOffsetImageFilter::Create(0, 0, NULL, &crop_rect)); | 108 SkOffsetImageFilter::Create(0, 0, nullptr, &crop_rect)); |
109 SkScalar sk255 = SkIntToScalar(255); | 109 SkScalar sk255 = SkIntToScalar(255); |
110 SkScalar matrix[20] = { 1, 0, 0, 0, 0, | 110 SkScalar matrix[20] = { 1, 0, 0, 0, 0, |
111 0, 1, 0, 0, sk255, | 111 0, 1, 0, 0, sk255, |
112 0, 0, 1, 0, 0, | 112 0, 0, 1, 0, 0, |
113 0, 0, 0, 0, sk255 }; | 113 0, 0, 0, 0, sk255 }; |
114 SkAutoTUnref<SkColorFilter> cf_alpha_trans(SkColorMatrixFilter::Create(m
atrix)); | 114 SkAutoTUnref<SkColorFilter> cf_alpha_trans(SkColorMatrixFilter::Create(m
atrix)); |
115 | 115 |
116 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); | 116 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); |
117 SkScalar MARGIN = SkIntToScalar(12); | 117 SkScalar MARGIN = SkIntToScalar(12); |
118 | 118 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 162 } |
163 | 163 |
164 private: | 164 private: |
165 typedef GM INHERITED; | 165 typedef GM INHERITED; |
166 }; | 166 }; |
167 | 167 |
168 /////////////////////////////////////////////////////////////////////////////// | 168 /////////////////////////////////////////////////////////////////////////////// |
169 | 169 |
170 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCropExpandGM; } | 170 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCropExpandGM; } |
171 static skiagm::GMRegistry reg(MyFactory); | 171 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |