OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkColorMatrixFilter.h" | 10 #include "SkColorMatrixFilter.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 #include "SkRRect.h" | 115 #include "SkRRect.h" |
116 | 116 |
117 static void draw_set(SkCanvas* canvas, sk_sp<SkImageFilter> filters[], int count
) { | 117 static void draw_set(SkCanvas* canvas, sk_sp<SkImageFilter> filters[], int count
) { |
118 const SkRect r = SkRect::MakeXYWH(30, 30, 200, 200); | 118 const SkRect r = SkRect::MakeXYWH(30, 30, 200, 200); |
119 const SkScalar offset = 250; | 119 const SkScalar offset = 250; |
120 SkScalar dx = 0, dy = 0; | 120 SkScalar dx = 0, dy = 0; |
121 | 121 |
122 for (int i = 0; i < count; ++i) { | 122 for (int i = 0; i < count; ++i) { |
123 canvas->save(); | 123 canvas->save(); |
124 SkRRect rr = SkRRect::MakeRectXY(r.makeOffset(dx, dy), 20, 20); | 124 SkRRect rr = SkRRect::MakeRectXY(r.makeOffset(dx, dy), 20, 20); |
125 canvas->clipRRect(rr, SkCanvas::kIntersect_Op, true); | 125 canvas->clipRRect(rr, true); |
126 canvas->saveLayer({ &rr.getBounds(), nullptr, filters[i].get(), 0 }); | 126 canvas->saveLayer({ &rr.getBounds(), nullptr, filters[i].get(), 0 }); |
127 canvas->drawColor(0x40FFFFFF); | 127 canvas->drawColor(0x40FFFFFF); |
128 canvas->restore(); | 128 canvas->restore(); |
129 canvas->restore(); | 129 canvas->restore(); |
130 | 130 |
131 if (0 == dx) { | 131 if (0 == dx) { |
132 dx = offset; | 132 dx = offset; |
133 } else { | 133 } else { |
134 dx = 0; | 134 dx = 0; |
135 dy = offset; | 135 dy = offset; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 canvas->translate(20, 20); | 168 canvas->translate(20, 20); |
169 for (const auto& xform : xforms) { | 169 for (const auto& xform : xforms) { |
170 canvas->save(); | 170 canvas->save(); |
171 canvas->translate(xform.fTx, xform.fTy); | 171 canvas->translate(xform.fTx, xform.fTy); |
172 canvas->scale(xform.fSx, xform.fSy); | 172 canvas->scale(xform.fSx, xform.fSy); |
173 canvas->drawImage(image, 0, 0, &paint); | 173 canvas->drawImage(image, 0, 0, &paint); |
174 draw_set(canvas, filters, SK_ARRAY_COUNT(filters)); | 174 draw_set(canvas, filters, SK_ARRAY_COUNT(filters)); |
175 canvas->restore(); | 175 canvas->restore(); |
176 } | 176 } |
177 } | 177 } |
OLD | NEW |