blob: f8cab546344e7765d8ae7cb305c228f4e7170f5c [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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 Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=ee8c0b120234e27364f8c9a786cf8f89
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Canvas_SaveLayerRec, 256, 160, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void 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 Ludwiga8611062019-08-01 16:38:24 -040015 auto scaler = SkImageFilters::MatrixTransform(matrix, kNone_SkFilterQuality, nullptr);
Hal Canary87515122019-03-15 14:22:51 -040016 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