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

Unified Diff: gm/lerpmode.cpp

Issue 15602003: add SkLerpXfermode (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 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/effects.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/lerpmode.cpp
diff --git a/gm/lerpmode.cpp b/gm/lerpmode.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..481af359b264b07f2034880df5f9613eab8ed577
--- /dev/null
+++ b/gm/lerpmode.cpp
@@ -0,0 +1,64 @@
+/*
+ * 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 "SkCanvas.h"
+#include "SkLerpXfermode.h"
+
+static void show_circlelayers(SkCanvas* canvas, SkXfermode* mode) {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkRect r, bounds = { 10, 10, 110, 110 };
+
+ r = bounds;
+ r.fRight = bounds.centerX();
+ canvas->drawRect(r, paint);
+
+ canvas->saveLayer(&bounds, NULL);
+
+ paint.setColor(0x80FF0000);
+ r = bounds;
+ r.inset(20, 0);
+ canvas->drawOval(r, paint);
+
+ paint.setColor(0x800000FF);
+ r = bounds;
+ r.inset(0, 20);
+ paint.setXfermode(mode);
+ canvas->drawOval(r, paint);
+
+ canvas->restore();
+}
+
+class LerpXfermodeGM : public skiagm::GM {
+public:
+ LerpXfermodeGM() {}
+
+protected:
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("lerpmode");
+ }
+
+ virtual SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(240, 120);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ show_circlelayers(canvas, NULL);
+ canvas->translate(150, 0);
+ SkAutoTUnref<SkXfermode> mode(SkLerpXfermode::Create(0.5f));
+ show_circlelayers(canvas, mode.get());
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+DEF_GM( return SkNEW(LerpXfermodeGM); )
+
« no previous file with comments | « no previous file | gyp/effects.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698