Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 1 | // Copyright 2019 Google LLC. |
| 2 | // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 3 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 4 | // HASH=862cc026601a41a58df49c0b9f0d7777 |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Clip, 256, 90, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | SkPaint redPaint, scalePaint; |
| 8 | redPaint.setAntiAlias(true); |
| 9 | redPaint.setColor(SK_ColorRED); |
| 10 | canvas->save(); |
| 11 | for (bool antialias : { false, true } ) { |
| 12 | canvas->save(); |
| 13 | canvas->clipRect(SkRect::MakeWH(19.5f, 11.5f), antialias); |
| 14 | canvas->drawCircle(17, 11, 8, redPaint); |
| 15 | canvas->restore(); |
| 16 | canvas->translate(16, 0); |
| 17 | } |
| 18 | canvas->restore(); |
| 19 | SkMatrix matrix; |
| 20 | matrix.setScale(6, 6); |
| 21 | scalePaint.setImageFilter( |
Mike Reed | 9223665 | 2021-02-01 13:07:32 -0500 | [diff] [blame] | 22 | SkImageFilters::MatrixTransform(matrix, SkSamplingOptions(), nullptr)); |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 23 | SkCanvas::SaveLayerRec saveLayerRec( |
| 24 | nullptr, &scalePaint, SkCanvas::kInitWithPrevious_SaveLayerFlag); |
| 25 | canvas->saveLayer(saveLayerRec); |
| 26 | canvas->restore(); |
| 27 | } |
| 28 | } // END FIDDLE |