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.
11 #include "SkClipStack.h"
13 #include "SkPathOps.h"
14 #include "SkPicture.h"
15 #include "SkPictureRecorder.h"
20 class PathOpsSkpClipGM : public GM {
26 SkString onShortName() override {
27 return SkString("pathopsskpclip");
30 SkISize onISize() override {
31 return SkISize::Make(1200, 900);
34 void onDraw(SkCanvas* canvas) override {
35 SkPictureRecorder recorder;
36 SkCanvas* rec = recorder.beginRecording(1200, 900, nullptr, 0);
44 p.addRoundRect(r, SkIntToScalar(50), SkIntToScalar(50));
45 rec->clipPath(p, true);
46 rec->translate(SkIntToScalar(250), SkIntToScalar(250));
47 rec->clipPath(p, true);
48 rec->drawColor(0xffff0000);
49 sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
51 canvas->setAllowSimplifyClip(true);
53 canvas->drawPicture(pict);
56 canvas->setAllowSimplifyClip(false);
58 canvas->translate(SkIntToScalar(1200 / 2), 0);
59 canvas->drawPicture(pict);
67 //////////////////////////////////////////////////////////////////////////////
69 static GM* MyFactory(void*) { return new PathOpsSkpClipGM; }
70 static GMRegistry reg(MyFactory);