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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 SkBitmap checkerboard; | 48 SkBitmap checkerboard; |
49 MakeCheckerboard(&checkerboard); | 49 MakeCheckerboard(&checkerboard); |
50 | 50 |
51 sk_sp<SkImageFilter> gradientCircleSource(SkImageSource::Make(std::move(
gradientCircle))); | 51 sk_sp<SkImageFilter> gradientCircleSource(SkImageSource::Make(std::move(
gradientCircle))); |
52 sk_sp<SkImageFilter> noopCropped(SkOffsetImageFilter::Make(0, 0, nullptr
, &cropRect)); | 52 sk_sp<SkImageFilter> noopCropped(SkOffsetImageFilter::Make(0, 0, nullptr
, &cropRect)); |
53 SkScalar sk255 = SkIntToScalar(255); | 53 SkScalar sk255 = SkIntToScalar(255); |
54 SkScalar matrix[20] = { 1, 0, 0, 0, 0, | 54 SkScalar matrix[20] = { 1, 0, 0, 0, 0, |
55 0, 1, 0, 0, sk255, | 55 0, 1, 0, 0, sk255, |
56 0, 0, 1, 0, 0, | 56 0, 0, 1, 0, 0, |
57 0, 0, 0, 0, sk255 }; | 57 0, 0, 0, 0, sk255 }; |
58 auto cfAlphaTrans(SkColorFilter::MakeMatrixFilterRowMajor255(matrix)); | 58 sk_sp<SkColorFilter> cfAlphaTrans(SkColorFilter::MakeMatrixFilterRowMajo
r255(matrix)); |
59 | 59 |
60 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); | 60 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); |
61 SkScalar MARGIN = SkIntToScalar(12); | 61 SkScalar MARGIN = SkIntToScalar(12); |
62 | 62 |
63 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10)); | 63 SkPoint3 pointLocation = SkPoint3::Make(0, 0, SkIntToScalar(10)); |
64 SkScalar kd = SkIntToScalar(2); | 64 SkScalar kd = SkIntToScalar(2); |
65 SkScalar surfaceScale = SkIntToScalar(1); | 65 SkScalar surfaceScale = SkIntToScalar(1); |
66 SkIRect bounds; | 66 SkIRect bounds; |
67 r.roundOut(&bounds); | 67 r.roundOut(&bounds); |
68 | 68 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 gradientCircleSource.get(), | 114 gradientCircleSource.get(), |
115 noopCropped.get(), | 115 noopCropped.get(), |
116 &bigRect))); | 116 &bigRect))); |
117 | 117 |
118 Draw(canvas, checkerboard, rect, | 118 Draw(canvas, checkerboard, rect, |
119 SkOffsetImageFilter::Make(SkIntToScalar(-8), SkIntToScalar(16), | 119 SkOffsetImageFilter::Make(SkIntToScalar(-8), SkIntToScalar(16), |
120 noopCropped, | 120 noopCropped, |
121 &bigRect)); | 121 &bigRect)); |
122 | 122 |
123 Draw(canvas, checkerboard, rect, | 123 Draw(canvas, checkerboard, rect, |
124 sk_sp<SkImageFilter>(SkLightingImageFilter::CreatePointLitDiffu
se(pointLocation, | 124 SkLightingImageFilter::MakePointLitDiffuse(pointLocation, |
125
SK_ColorWHITE, | 125 SK_ColorWHITE, |
126
surfaceScale, | 126 surfaceScale, |
127
kd, | 127 kd, |
128
noopCropped.get(), | 128 noopCropped, |
129
&bigRect))); | 129 &bigRect)); |
130 | 130 |
131 canvas->restore(); | 131 canvas->restore(); |
132 canvas->translate(0, SkIntToScalar(80)); | 132 canvas->translate(0, SkIntToScalar(80)); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 private: | 136 private: |
137 static void MakeCheckerboard(SkBitmap* bitmap) { | 137 static void MakeCheckerboard(SkBitmap* bitmap) { |
138 bitmap->allocN32Pixels(64, 64); | 138 bitmap->allocN32Pixels(64, 64); |
139 SkCanvas canvas(*bitmap); | 139 SkCanvas canvas(*bitmap); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 canvas->translate(SkIntToScalar(80), 0); | 189 canvas->translate(SkIntToScalar(80), 0); |
190 } | 190 } |
191 | 191 |
192 typedef GM INHERITED; | 192 typedef GM INHERITED; |
193 }; | 193 }; |
194 | 194 |
195 /////////////////////////////////////////////////////////////////////////////// | 195 /////////////////////////////////////////////////////////////////////////////// |
196 | 196 |
197 DEF_GM( return new ImageFiltersCropExpandGM; ) | 197 DEF_GM( return new ImageFiltersCropExpandGM; ) |
OLD | NEW |