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.
3 #include "tools/fiddle/examples.h"
4 // HASH=ee8c0b120234e27364f8c9a786cf8f89
5 REG_FIDDLE(Canvas_SaveLayerRec, 256, 160, false, 0) {
draw(SkCanvas * canvas)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);
15 auto scaler = SkImageFilters::MatrixTransform(matrix, SkSamplingOptions(), nullptr);
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
22