Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: gm/pathopsskpclip.cpp

Issue 14474002: path ops : make it real (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/core.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/pathopsskpclip.cpp
===================================================================
--- gm/pathopsskpclip.cpp (revision 0)
+++ gm/pathopsskpclip.cpp (revision 0)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "SkBitmap.h"
+#include "SkCanvas.h"
+#include "SkClipStack.h"
+#include "SkDevice.h"
+#include "SkPath.h"
+#include "SkPathOps.h"
+#include "SkPicture.h"
+#include "SkRect.h"
+
+namespace skiagm {
+
+class PathOpsSkpClipGM : public GM {
+public:
+ PathOpsSkpClipGM() {
+ }
+
+protected:
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("pathopsskpclip");
+ }
+
+ virtual SkISize onISize() SK_OVERRIDE {
+ return make_isize(1200, 900);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPicture* pict = SkNEW(SkPicture);
+ SkCanvas* rec = pict->beginRecording(1200, 900);
+ SkPath p;
+ SkRect r = {
+ SkIntToScalar(100),
+ SkIntToScalar(200),
+ SkIntToScalar(400),
+ SkIntToScalar(700)
+ };
+ p.addRoundRect(r, SkIntToScalar(50), SkIntToScalar(50));
+ rec->clipPath(p, SkRegion::kIntersect_Op, true);
+ rec->translate(SkIntToScalar(250), SkIntToScalar(250));
+ rec->clipPath(p, SkRegion::kIntersect_Op, true);
+ rec->drawColor(0xffff0000);
+ pict->endRecording();
+
+ canvas->setAllowSimplifyClip(true);
+ canvas->save();
+ canvas->drawPicture(*pict);
+ canvas->restore();
+
+ canvas->setAllowSimplifyClip(false);
+ canvas->save();
+ canvas->translate(SkIntToScalar(1200 / 2), 0);
+ canvas->drawPicture(*pict);
+ canvas->restore();
+ SkSafeUnref(pict);
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static GM* MyFactory(void*) { return new PathOpsSkpClipGM; }
+static GMRegistry reg(MyFactory);
+
+}
« no previous file with comments | « no previous file | gyp/core.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698