aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/drrect.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-21 02:32:36 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-21 02:32:36 +0000
commited9806f5c972513d4141c9d1b5a04ab78b3af4cb (patch)
tree272b3e405ad76024deb5c77b29c0154dafa496a8 /gm/drrect.cpp
parentfe424101036c75548967f952213d041eb7ffca83 (diff)
add SkCanvas::drawDRRect
BUG=skia: R=bsalomon@google.com, robertphillips@google.com, humper@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/174243003 git-svn-id: http://skia.googlecode.com/svn/trunk@13524 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/drrect.cpp')
-rw-r--r--gm/drrect.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/gm/drrect.cpp b/gm/drrect.cpp
new file mode 100644
index 0000000000..5bf4a089c1
--- /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; )