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"
14 #include "SkPathOps.h"
15 #include "SkPicture.h"
16 #include "SkPictureRecorder.h"
21 class PathOpsSkpClipGM : public GM {
27 SkString onShortName() SK_OVERRIDE {
28 return SkString("pathopsskpclip");
31 SkISize onISize() SK_OVERRIDE {
32 return SkISize::Make(1200, 900);
35 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
36 SkPictureRecorder recorder;
37 SkCanvas* rec = recorder.beginRecording(1200, 900, NULL, 0);
45 p.addRoundRect(r, SkIntToScalar(50), SkIntToScalar(50));
46 rec->clipPath(p, SkRegion::kIntersect_Op, true);
47 rec->translate(SkIntToScalar(250), SkIntToScalar(250));
48 rec->clipPath(p, SkRegion::kIntersect_Op, true);
49 rec->drawColor(0xffff0000);
50 SkAutoTUnref<SkPicture> pict(recorder.endRecording());
52 canvas->setAllowSimplifyClip(true);
54 canvas->drawPicture(pict);
57 canvas->setAllowSimplifyClip(false);
59 canvas->translate(SkIntToScalar(1200 / 2), 0);
60 canvas->drawPicture(pict);
68 //////////////////////////////////////////////////////////////////////////////
70 static GM* MyFactory(void*) { return new PathOpsSkpClipGM; }
71 static GMRegistry reg(MyFactory);