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=862cc026601a41a58df49c0b9f0d7777
5 REG_FIDDLE(Clip, 256, 90, false, 0) {
draw(SkCanvas * canvas)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(
22 SkImageFilters::MatrixTransform(matrix, kNone_SkFilterQuality, nullptr));
23 SkCanvas::SaveLayerRec saveLayerRec(
24 nullptr, &scalePaint, SkCanvas::kInitWithPrevious_SaveLayerFlag);
25 canvas->saveLayer(saveLayerRec);
26 canvas->restore();
27 }
28 } // END FIDDLE
29