aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-11-14 08:27:40 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-14 08:27:40 -0800
commit36e6e266b882b7687fb526dc13eeb23ffbc2b85e (patch)
tree5bcfe888b933a6e4e283a877e1200945eb73423d /gm
parentf04713d9c8f2af15f97984b47587358488e2594e (diff)
add gm for 2-rects and blur
BUG=skia: TBR= Review URL: https://codereview.chromium.org/728863002
Diffstat (limited to 'gm')
-rw-r--r--gm/blurs.cpp49
1 files changed, 40 insertions, 9 deletions
diff --git a/gm/blurs.cpp b/gm/blurs.cpp
index ad363e425d..2ca1193e22 100644
--- a/gm/blurs.cpp
+++ b/gm/blurs.cpp
@@ -1,17 +1,15 @@
-
/*
* Copyright 2011 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 "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
-namespace skiagm {
-
-class BlursGM : public GM {
+class BlursGM : public skiagm::GM {
public:
BlursGM() {
this->setBGColor(0xFFDDDDDD);
@@ -92,12 +90,45 @@ protected:
}
private:
- typedef GM INHERITED;
+ typedef skiagm::GM INHERITED;
};
+DEF_GM( return new BlursGM; )
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+// exercise a special-case of blurs, which is two nested rects. These are drawn specially,
+// and possibly cached.
+//
+// in particular, we want to notice that the 2nd rect draws slightly differently, since it
+// is translated a fractional amount.
+//
+class Blur2RectsGM : public skiagm::GM {
+public:
+ SkString onShortName() SK_OVERRIDE {
+ return SkString("blur2rects");
+ }
-//////////////////////////////////////////////////////////////////////////////
+ SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(700, 500);
+ }
+
+ void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
-static GM* MyFactory(void*) { return new BlursGM; }
-static GMRegistry reg(MyFactory);
+ paint.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
+ 2.3f))->unref();
-}
+ SkRect outer = SkRect::MakeXYWH(10.125f, 10.125f, 100, 100);
+ SkRect inner = SkRect::MakeXYWH(20, 20, 80, 80);
+ SkPath path;
+ path.addRect(outer, SkPath::kCW_Direction);
+ path.addRect(inner, SkPath::kCCW_Direction);
+
+ canvas->drawPath(path, paint);
+ // important to translate by a factional amount (.25) to exercise a different "phase"
+ // of the same path w.r.t. the pixel grid
+ canvas->translate(SkScalarRoundToScalar(path.getBounds().width()) + 14 + 0.25f, 0);
+ canvas->drawPath(path, paint);
+ }
+};
+DEF_GM( return new Blur2RectsGM; )