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

Unified Diff: gm/avoidxfermode2.cpp

Issue 1658623002: Add gpu implementation of SkAvoidXfermode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 4 years, 11 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 | « gm/avoidxfermode.cpp ('k') | include/client/android/SkAvoidXfermode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/avoidxfermode2.cpp
diff --git a/gm/avoidxfermode2.cpp b/gm/avoidxfermode2.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..039ed4017b15904416b3037a590b42cea0044055
--- /dev/null
+++ b/gm/avoidxfermode2.cpp
@@ -0,0 +1,84 @@
+/*
+ * 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 "SkAvoidXfermode.h"
+
+class AvoidXfermode2GM : public skiagm::GM {
+public:
+ AvoidXfermode2GM() { }
+
+protected:
+ SkString onShortName() override {
+ return SkString("avoidxfermode2");
+ }
+
+ SkISize onISize() override { return SkISize::Make(128, 128); }
+
+ void onDraw(SkCanvas* canvas) override {
+ canvas->drawARGB(255, 0, 0, 0);
+
+ SkRect r = SkRect::MakeXYWH(32, 32, 64, 64);
+
+ SkPaint p0;
+ p0.setColor(SK_ColorGREEN);
+ p0.setAntiAlias(false);
+
+ canvas->drawRect(r, p0);
+
+ r = SkRect::MakeIWH(64, 64);
+
+ // UL corner: replace the green with a tight tolerance
+ SkPaint p1;
+ p1.setColor(SK_ColorRED);
+ p1.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN,
+ 55,
+ SkAvoidXfermode::kTargetColor_Mode))->unref();
+
+ canvas->drawRect(r, p1);
+
+ r.offsetTo(64, 0.0f);
+
+ // UR corner: avoid the green with a tight tolerance
+ SkPaint p2;
+ p2.setColor(SK_ColorRED);
+ p2.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN,
+ 200,
+ SkAvoidXfermode::kAvoidColor_Mode))->unref();
+
+ canvas->drawRect(r, p2);
+
+ r.offsetTo(0.0f, 64);
+
+ // LL corner: replace the green with a loose tolerance
+ SkPaint p3;
+ p3.setColor(SK_ColorRED);
+ p3.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN,
+ 200,
+ SkAvoidXfermode::kTargetColor_Mode))->unref();
+
+ canvas->drawRect(r, p3);
+
+ r.offsetTo(64, 64);
+
+ // LR corner: avoid the green with a loose tolerance
+ SkPaint p4;
+ p4.setColor(SK_ColorRED);
+ p4.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN,
+ 55,
+ SkAvoidXfermode::kAvoidColor_Mode))->unref();
+
+ canvas->drawRect(r, p4);
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+DEF_GM(return new AvoidXfermode2GM;)
« no previous file with comments | « gm/avoidxfermode.cpp ('k') | include/client/android/SkAvoidXfermode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698