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

Unified Diff: gm/drrect.cpp

Issue 174243003: add SkCanvas::drawDRRect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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/gmslides.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/drrect.cpp
diff --git a/gm/drrect.cpp b/gm/drrect.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5bf4a089c1cb1cf34561b3a36eda11d2458fdfea
--- /dev/null
+++ b/gm/drrect.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2014 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 "SkRRect.h"
+#include "SkPath.h"
+
+class DRRectGM : public skiagm::GM {
+public:
+ DRRectGM() {}
+
+protected:
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("drrect");
+ }
+
+ virtual SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(640, 480);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+
+ SkRRect outers[4];
+ // like squares/circles, to exercise fast-cases in GPU
+ SkRect r = { 0, 0, 100, 100 };
+ SkVector radii[4] = {
+ { 0, 0 }, { 30, 1 }, { 10, 40 }, { 40, 40 }
+ };
+
+ const SkScalar dx = r.width() + 16;
+ const SkScalar dy = r.height() + 16;
+
+ outers[0].setRect(r);
+ outers[1].setOval(r);
+ outers[2].setRectXY(r, 20, 20);
+ outers[3].setRectRadii(r, radii);
+
+ SkRRect inners[5];
+ r.inset(25, 25);
+
+ inners[0].setEmpty();
+ inners[1].setRect(r);
+ inners[2].setOval(r);
+ inners[3].setRectXY(r, 20, 20);
+ inners[4].setRectRadii(r, radii);
+
+ canvas->translate(16, 16);
+ for (size_t j = 0; j < SK_ARRAY_COUNT(inners); ++j) {
+ for (size_t i = 0; i < SK_ARRAY_COUNT(outers); ++i) {
+ canvas->save();
+ canvas->translate(dx * j, dy * i);
+ canvas->drawDRRect(outers[i], inners[j], paint);
+ canvas->restore();
+ }
+ }
+ }
+
+private:
+ typedef GM INHERITED;
+};
+
+DEF_GM( return new DRRectGM; )
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698