diff options
author | 2016-10-18 12:58:29 -0400 | |
---|---|---|
committer | 2016-10-18 18:56:37 +0000 | |
commit | 40085e62bae768435ae901ed9e5c681016d36bb0 (patch) | |
tree | bf76b13e5abc8092a088b15f8b1bac4ad2b50ff4 /gm/reveal.cpp | |
parent | 16adfa39330b7b1c6ac16b8127843e55f4233a29 (diff) |
Fix star artifact in SkRRectsGaussianEdgeShader
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3360
Change-Id: I791ae5f44a88ac3e4debdf1d4092c605acdf4969
Reviewed-on: https://skia-review.googlesource.com/3360
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'gm/reveal.cpp')
-rw-r--r-- | gm/reveal.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/gm/reveal.cpp b/gm/reveal.cpp index 3451fa1dac..65bef17a57 100644 --- a/gm/reveal.cpp +++ b/gm/reveal.cpp @@ -19,7 +19,7 @@ constexpr int kNumCols = 2; constexpr int kNumRows = 5; constexpr int kCellSize = 128; constexpr SkScalar kPad = 8.0f; -constexpr SkScalar kBlurRadius = 8.0f; +constexpr SkScalar kInitialBlurRadius = 8.0f; constexpr SkScalar kPeriod = 8.0f; constexpr int kClipOffset = 32; @@ -292,7 +292,11 @@ public: static const int kModeCount = kLast_Mode + 1; - RevealGM() : fFraction(0.5f), fMode(kRRectsGaussianEdge_Mode), fPause(false) { + RevealGM() + : fFraction(0.5f) + , fMode(kRRectsGaussianEdge_Mode) + , fPause(false) + , fBlurRadius(kInitialBlurRadius) { this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); } @@ -349,14 +353,15 @@ protected: SkPaint paint; paint.setAntiAlias(true); // G channel is an F6.2 radius - paint.setColor(SkColorSetARGB(255, 0, (unsigned char)(4*kBlurRadius), 0)); + int iBlurRad = (int)(4.0f * fBlurRadius); + paint.setColor(SkColorSetARGB(255, iBlurRad >> 8, iBlurRad & 0xFF, 0)); paint.setShader(SkGaussianEdgeShader::Make()); drawObj->draw(canvas, paint); canvas->restore(); } else if (kBlurMask_Mode == fMode) { SkPath clippedPath; - SkScalar sigma = kBlurRadius / 4.0f; + SkScalar sigma = fBlurRadius / 4.0f; if (clipObj->contains(drawObj->bounds())) { clippedPath = drawObj->asPath(2.0f*sigma); @@ -383,7 +388,7 @@ protected: if (clipObj->asRRect(&clipRR) && drawObj->asRRect(&drawnRR)) { paint.setShader(SkRRectsGaussianEdgeShader::Make(clipRR, drawnRR, - kBlurRadius)); + fBlurRadius)); } canvas->drawRect(cover, paint); @@ -408,6 +413,12 @@ protected: case 'C': fMode = (Mode)((fMode + 1) % kModeCount); return true; + case '+': + fBlurRadius += 1.0f; + return true; + case '-': + fBlurRadius = SkTMax(1.0f, fBlurRadius - 1.0f); + return true; case 'p': fPause = !fPause; return true; @@ -427,6 +438,7 @@ private: SkScalar fFraction; Mode fMode; bool fPause; + float fBlurRadius; typedef GM INHERITED; }; |