2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
12 class CircularClipsGM : public skiagm::GM {
13 SkScalar fX1, fX2, fY, fR;
14 SkPath fCircle1, fCircle2;
17 void onOnceBeforeDraw() override {
23 fCircle1.addCircle(fX1, fY, fR, SkPath::kCW_Direction);
24 fCircle2.addCircle(fX2, fY, fR, SkPath::kCW_Direction);
28 bool runAsBench() const override { return true; }
30 SkString onShortName() override {
31 return SkString("circular-clips");
34 SkISize onISize() override {
35 return SkISize::Make(800, 600);
38 void onDraw(SkCanvas* canvas) override {
39 SkRegion::Op ops[] = {
40 SkRegion::kDifference_Op,
41 SkRegion::kIntersect_Op,
44 SkRegion::kReverseDifference_Op,
45 SkRegion::kReplace_Op,
48 SkRect rect = SkRect::MakeLTRB(fX1 - fR, fY - fR, fX2 + fR, fY + fR);
52 for (size_t i = 0; i < 4; i++) {
53 fCircle1.toggleInverseFillType();
55 fCircle2.toggleInverseFillType();
59 for (size_t op = 0; op < SK_ARRAY_COUNT(ops); op++) {
62 canvas->clipPath(fCircle1, SkRegion::kReplace_Op);
63 canvas->clipPath(fCircle2, ops[op]);
65 canvas->drawRect(rect, fillPaint);
68 canvas->translate(0, 2 * fY);
71 canvas->translate(fX1 + fX2, 0);
76 typedef skiagm::GM INHERITED;
79 //////////////////////////////////////////////////////////////////////////////
81 DEF_GM( return new CircularClipsGM; )