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

Unified Diff: gm/drawregionmodes.cpp

Issue 2277053002: Add drawRegion() API to SkCanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added shader to test 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/drawregionmodes.cpp
diff --git a/gm/drawregionmodes.cpp b/gm/drawregionmodes.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..be1c2d20e00471f1dc615dd5604a9ee8a1b7b3bb
--- /dev/null
+++ b/gm/drawregionmodes.cpp
@@ -0,0 +1,78 @@
+/*
+ * 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 "SkBlurMaskFilter.h"
+#include "SkCanvas.h"
+#include "SkDashPathEffect.h"
+#include "SkGradientShader.h"
+#include "SkImageFilter.h"
+
+class DrawRegionModesGM : public skiagm::GM {
+public:
+ DrawRegionModesGM() {}
+
+protected:
+ SkString onShortName() override {
+ return SkString("drawregionmodes");
+ }
+
+ SkISize onISize() override {
+ return SkISize::Make(375, 500);
+ }
+
+ void onOnceBeforeDraw() override {
+ fRegion.op( 50, 50, 100, 100, SkRegion::kUnion_Op);
+ fRegion.op( 50, 100, 150, 150, SkRegion::kUnion_Op);
+ }
+
+ void onDraw(SkCanvas* canvas) override {
+ canvas->clear(SK_ColorGREEN);
+
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(0xFFFF0000);
+ paint.setAntiAlias(true);
+
+ canvas->translate(-50.0f, 75.0f);
+ canvas->rotate(-45.0f);
+ canvas->drawRegion(fRegion, paint);
+
+ canvas->translate(125.0f, 125.0f);
+ paint.setImageFilter(SkImageFilter::MakeBlur(5.0f, 5.0f, nullptr, nullptr));
+ canvas->drawRegion(fRegion, paint);
+
+ canvas->translate(-125.0f, 125.0f);
+ paint.setImageFilter(nullptr);
+ SkRect occluder = SkRect::MakeEmpty();
+ paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 5.0f, occluder, 0));
+ canvas->drawRegion(fRegion, paint);
+
+ canvas->translate(-125.0f, -125.0f);
+ paint.setMaskFilter(nullptr);
+ paint.setStyle(SkPaint::kStroke_Style);
+ float intervals[] = { 5.0f, 5.0f };
+ paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 2.5f));
+ canvas->drawRegion(fRegion, paint);
+
+ canvas->setMatrix(SkMatrix::I());
+ canvas->translate(100, 325);
+ paint.setPathEffect(nullptr);
+ paint.setStyle(SkPaint::kFill_Style);
+ SkPoint points[] = { SkPoint::Make(50.0f, 50.0f), SkPoint::Make(150.0f, 150.0f) };
+ SkColor colors[] = { SK_ColorBLUE, SK_ColorYELLOW };
+ paint.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 2,
+ SkShader::kClamp_TileMode));
+ canvas->drawRegion(fRegion, paint);
+ }
+
+ SkRegion fRegion;
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+DEF_GM( return new DrawRegionModesGM; )
« no previous file with comments | « gm/drawregion.cpp ('k') | include/core/SkCanvas.h » ('j') | include/core/SkCanvas.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698