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

Unified Diff: gm/bigblurs.cpp

Issue 60513013: Start on GM to verify removal of 32767 limit in SkBlurMaskFilter::filterRectsToNine is okay (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Ready for review Created 7 years, 1 month 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 | src/effects/SkBlurMaskFilter.cpp » ('j') | src/effects/SkBlurMaskFilter.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/bigblurs.cpp
===================================================================
--- gm/bigblurs.cpp (revision 0)
+++ gm/bigblurs.cpp (revision 0)
@@ -0,0 +1,119 @@
+
+/*
+ * 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 "SkBlurMask.h"
+#include "SkBlurMaskFilter.h"
+
+namespace skiagm {
+
+// This GM exercises the blurred rect nine-patching special cases when the
+// blurred rect is very large and/or very far from the origin.
+// It creates a large blurred rect/rectori then renders the 4 corners and the
+// middle.
+class BigBlursGM : public GM {
+public:
+ BigBlursGM() {
+ this->setBGColor(0xFFDDDDDD);
+ }
+
+protected:
+ virtual SkString onShortName() {
+ return SkString("bigblurs");
+ }
+
+ virtual SkISize onISize() {
+ return make_isize(kWidth, kHeight);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ SkBlurMaskFilter::BlurStyle blurStyles[] = {
+ SkBlurMaskFilter::kInner_BlurStyle,
+ SkBlurMaskFilter::kNormal_BlurStyle,
+ SkBlurMaskFilter::kSolid_BlurStyle,
+ SkBlurMaskFilter::kOuter_BlurStyle
+ };
+
+ static const SkScalar kBig = 65536;
+ static const SkScalar kSmall = 64;
+ static const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4));
+ static const int kOffset = SkScalarRoundToInt(kSmall + 6 * kSigma);
+
+ const SkRect bigRect = SkRect::MakeWH(kBig, kBig);
+ SkRect insetRect = bigRect;
+ insetRect.inset(20, 20);
+
+ SkPath rectori;
+
+ rectori.addRect(bigRect);
+ rectori.addRect(insetRect, SkPath::kCCW_Direction);
+
+ // UL hand corners of the rendered closeups
+ const SkPoint origins[] = {
+ { -3*kSigma, -3*kSigma, }, // UL
+ { kBig-kSmall-3*kSigma, -3*kSigma }, // UR
+ { kBig-kSmall-3*kSigma, kBig-kSmall-3*kSigma }, // LR
+ { -3*kSigma, kBig-kSmall-3*kSigma }, // LL
+ { kBig/2-kSmall-3*kSigma, kBig/2-kSmall-3*kSigma }, // center
+ };
+
+ SkPaint outlinePaint;
+ outlinePaint.setColor(SK_ColorRED);
+ outlinePaint.setStyle(SkPaint::kStroke_Style);
+
+ SkPaint blurPaint;
+ blurPaint.setAntiAlias(true);
+ blurPaint.setColor(SK_ColorBLACK);
+
+ int desiredX = 0, desiredY = 0;
+
+ for (int i = 0; i < 2; ++i) {
+ for (int j = 0; j < (int)SK_ARRAY_COUNT(blurStyles); ++j) {
+ SkMaskFilter* mf = SkBlurMaskFilter::Create(blurStyles[j], kSigma);
+ blurPaint.setMaskFilter(mf)->unref();
+
+ for (int k = 0; k < (int)SK_ARRAY_COUNT(origins); ++k) {
+ canvas->save();
+
+ SkRect clipRect = SkRect::MakeXYWH(SkIntToScalar(desiredX),
+ SkIntToScalar(desiredY),
+ SkIntToScalar(kOffset),
+ SkIntToScalar(kOffset));
+
+ canvas->clipRect(clipRect, SkRegion::kReplace_Op, false);
+
+ canvas->translate(desiredX-origins[k].fX,
+ desiredY-origins[k].fY);
+
+ if (0 == i) {
+ canvas->drawRect(bigRect, blurPaint);
+ } else {
+ canvas->drawPath(rectori, blurPaint);
+ }
+ canvas->restore();
+ canvas->drawRect(clipRect, outlinePaint);
+
+ desiredX += kOffset;
+ }
+
+ desiredX = 0;
+ desiredY += kOffset;
+ }
+ }
+ }
+
+private:
+ static const int kWidth = 406;
+ static const int kHeight = 649;
+
+ typedef GM INHERITED;
+};
+
+DEF_GM( return SkNEW(BigBlursGM); )
+
+}
Property changes on: gm\bigblurs.cpp
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « no previous file | src/effects/SkBlurMaskFilter.cpp » ('j') | src/effects/SkBlurMaskFilter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698