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

Unified Diff: gm/drawregionrotate.cpp

Issue 2277053002: Add drawRegion() API to SkCanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Convert region to a path in complex case Created 4 years, 4 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
Index: gm/drawregionrotate.cpp
diff --git a/gm/drawregionrotate.cpp b/gm/drawregionrotate.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..59f9a5992de2cf8524376a849f19094308c7f05c
--- /dev/null
+++ b/gm/drawregionrotate.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2016 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 "SkCanvas.h"
+
+class DrawRegionRotateGM : public skiagm::GM {
+public:
+ DrawRegionRotateGM() {}
+
+protected:
+ SkString onShortName() override {
+ return SkString("drawregionrotate");
+ }
+
+ SkISize onISize() override {
+ return SkISize::Make(300, 300);
+ }
+
+ void onOnceBeforeDraw() override {
+ fRegion.op( 50, 50, 100, 100, SkRegion::kUnion_Op);
+ fRegion.op( 50, 100, 100, 150, SkRegion::kUnion_Op);
+ fRegion.op(100, 50, 150, 100, SkRegion::kUnion_Op);
+ fRegion.op(100, 100, 150, 150, SkRegion::kUnion_Op);
+ }
+
+ void onDraw(SkCanvas* canvas) override {
msarett 2016/08/25 13:02:32 I wanted to write a gm that shows interior cracks
msarett 2016/08/25 15:07:35 Problem was that SkRegion was smartly combining al
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(0x70000000);
+ paint.setAntiAlias(true);
+
+ canvas->translate(100, 0);
+ canvas->rotate(45);
+ canvas->drawRegion(fRegion, paint);
+ }
+
+ SkRegion fRegion;
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+DEF_GM( return new DrawRegionRotateGM; )
« no previous file with comments | « gm/drawregion.cpp ('k') | include/core/SkCanvas.h » ('j') | src/core/SkDevice.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698