static void draw_90_simple(SkCanvas* canvas, const SkVector& v,
SkScalar dist, const SkPoint& center) {
static const int kLength = 128;
- static const int kWidth = 32;
+ // The width needs to be larger than 2*3*blurRadii+2*cornerRadius for the analytic
+ // RRect blur to kick in
+ static const int kWidth = 47;
SkIRect r;
if (fabs(v.fX) < fabs(v.fY)) {
SkVector::Make(kRoot3Over2, -0.5f), 120, center);
draw_45_simple(canvas, SkVector::Make(-SK_ScalarRoot2Over2, -SK_ScalarRoot2Over2),
- 190, center);
+ 210, center);
draw_45_simple(canvas, SkVector::Make(SK_ScalarRoot2Over2, -SK_ScalarRoot2Over2),
- 190, center);
+ 210, center);
draw_45_simple(canvas, SkVector::Make(SK_ScalarRoot2Over2, SK_ScalarRoot2Over2),
- 190, center);
+ 210, center);
draw_45_simple(canvas, SkVector::Make(-SK_ScalarRoot2Over2, SK_ScalarRoot2Over2),
- 190, center);
+ 210, center);
- draw_90_simple(canvas, SkVector::Make(-1.0f, 0.0f), 150, center);
- draw_90_simple(canvas, SkVector::Make(0.0f, -1.0f), 150, center);
- draw_90_simple(canvas, SkVector::Make(1.0f, 0.0f), 150, center);
- draw_90_simple(canvas, SkVector::Make(0.0f, 1.0f), 150, center);
+ draw_90_simple(canvas, SkVector::Make(-1.0f, 0.0f), 160, center);
+ draw_90_simple(canvas, SkVector::Make(0.0f, -1.0f), 160, center);
+ draw_90_simple(canvas, SkVector::Make(1.0f, 0.0f), 160, center);
+ draw_90_simple(canvas, SkVector::Make(0.0f, 1.0f), 160, center);
}
private:
bool filterRRectMask(SkMask* dstM, const SkRRect& r, const SkMatrix& matrix,
SkIPoint* margin, SkMask::CreateMode createMode) const;
+ bool ignoreXform() const {
+ return SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
+ }
+
private:
// To avoid unseemly allocation requests (esp. for finite platforms like
// handset) we limit the radius so something manageable. (as opposed to
void flatten(SkWriteBuffer&) const override;
SkScalar computeXformedSigma(const SkMatrix& ctm) const {
- bool ignoreTransform = SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
-
- SkScalar xformedSigma = ignoreTransform ? fSigma : ctm.mapRadius(fSigma);
+ SkScalar xformedSigma = this->ignoreXform() ? fSigma : ctm.mapRadius(fSigma);
return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA);
}
if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) {
return nullptr;
}
- if (flags > SkBlurMaskFilter::kAll_BlurFlag) {
- return nullptr;
- }
+ SkASSERT(flags <= SkBlurMaskFilter::kAll_BlurFlag);
+ flags &= SkBlurMaskFilter::kAll_BlurFlag;
+
return sk_sp<SkMaskFilter>(new SkBlurMaskFilterImpl(sigma, style, flags));
}
}
bool SkBlurMaskFilterImpl::asABlur(BlurRec* rec) const {
- if (fBlurFlags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag) {
+ if (this->ignoreXform()) {
return false;
}
}
SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
- float extra=3.f*SkScalarCeilToScalar(xformedSigma-1/6.0f);
-
- SkRect proxyRect = rrect.rect();
- proxyRect.outset(extra, extra);
sk_sp<GrFragmentProcessor> fp(GrRRectBlurEffect::Make(texProvider, xformedSigma, rrect));
if (!fp) {
return false;
}
+ float extra=3.f*SkScalarCeilToScalar(xformedSigma-1/6.0f);
+
+ SkRect proxyRect = rrect.rect();
+ proxyRect.outset(extra, extra);
+
drawContext->fillRectWithLocalMatrix(clip, *grp, SkMatrix::I(), proxyRect, inverse);
return true;
}
///////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
+void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect,
const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext);
// try to hit the fast path for drawing filtered round rects
SkRRect devRRect;
- if (rect.transform(*draw.fMatrix, &devRRect)) {
+ if (rrect.transform(*draw.fMatrix, &devRRect)) {
if (devRRect.allCornersCircular()) {
SkRect maskRect;
if (paint.getMaskFilter()->canFilterMaskGPU(devRRect,
// A path effect will presumably transform this rrect into something else.
SkPath path;
path.setIsVolatile(true);
- path.addRRect(rect);
+ path.addRRect(rrect);
GrBlurUtils::drawPathWithMaskFilter(fContext, fDrawContext.get(),
fClip, path, paint,
*draw.fMatrix, nullptr,
SkASSERT(!style.pathEffect());
- fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rect, style);
+ fDrawContext->drawRRect(fClip, grPaint, *draw.fMatrix, rrect, style);
}
// First see if we can do the draw + mask filter direct to the dst.
SkStrokeRec rec(SkStrokeRec::kFill_InitStyle);
- SkRRect rrect;
- rrect.setRect(clippedDstRect);
if (mf->directFilterRRectMaskGPU(fContext->textureProvider(),
fDrawContext.get(),
&grPaint,
clip,
viewMatrix,
rec,
- rrect)) {
+ SkRRect::MakeRect(clippedDstRect))) {
return;
}
SkPath rectPath;