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=ee8c0b120234e27364f8c9a786cf8f89 |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Canvas_SaveLayerRec, 256, 160, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | SkPaint redPaint, bluePaint; |
| 8 | redPaint.setAntiAlias(true); |
| 9 | redPaint.setColor(SK_ColorRED); |
| 10 | canvas->drawCircle(21, 21, 8, redPaint); |
| 11 | bluePaint.setColor(SK_ColorBLUE); |
| 12 | canvas->drawCircle(31, 21, 8, bluePaint); |
| 13 | SkMatrix matrix; |
| 14 | matrix.setScale(4, 4); |
Michael Ludwig | a861106 | 2019-08-01 16:38:24 -0400 | [diff] [blame] | 15 | auto scaler = SkImageFilters::MatrixTransform(matrix, kNone_SkFilterQuality, nullptr); |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 16 | SkCanvas::SaveLayerRec saveLayerRec(nullptr, nullptr, scaler.get(), 0); |
| 17 | canvas->saveLayer(saveLayerRec); |
| 18 | canvas->drawCircle(125, 85, 8, redPaint); |
| 19 | canvas->restore(); |
| 20 | } |
| 21 | } // END FIDDLE |