diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBlurPriv.h | 37 | ||||
-rw-r--r-- | src/effects/SkBlurMaskFilter.cpp | 21 | ||||
-rw-r--r-- | src/gpu/effects/GrRRectBlurEffect.cpp | 4 | ||||
-rw-r--r-- | src/gpu/effects/GrRRectBlurEffect.fp | 19 | ||||
-rw-r--r-- | src/gpu/effects/GrRRectBlurEffect.h | 1 |
5 files changed, 61 insertions, 21 deletions
diff --git a/src/core/SkBlurPriv.h b/src/core/SkBlurPriv.h new file mode 100644 index 0000000000..d7a5c05b96 --- /dev/null +++ b/src/core/SkBlurPriv.h @@ -0,0 +1,37 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkBlurPriv_DEFINED +#define SkBlurPriv_DEFINED + +#include "SkRRect.h" +#include "SkSize.h" + +static const int kSkBlurRRectMaxDivisions = 6; + +// This method computes all the parameters for drawing a partially occluded nine-patched +// blurred rrect mask: +// rrectToDraw - the integerized rrect to draw in the mask +// widthHeight - how large to make the mask (rrectToDraw will be centered in this coord sys) +// rectXs, rectYs - the x & y coordinates of the covering geometry lattice +// texXs, texYs - the texture coordinate at each point in rectXs & rectYs +// numXs, numYs - number of coordinates in the x & y directions +// skipMask - bit mask that contains a 1-bit whenever one of the cells is occluded +// It returns true if 'devRRect' is nine-patchable +bool SkComputeBlurredRRectParams(const SkRRect& srcRRect, const SkRRect& devRRect, + const SkRect& occluder, + SkScalar sigma, SkScalar xformedSigma, + SkRRect* rrectToDraw, + SkISize* widthHeight, + SkScalar rectXs[kSkBlurRRectMaxDivisions], + SkScalar rectYs[kSkBlurRRectMaxDivisions], + SkScalar texXs[kSkBlurRRectMaxDivisions], + SkScalar texYs[kSkBlurRRectMaxDivisions], + int* numXs, int* numYs, uint32_t* skipMask); + + +#endif diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 9d7df43d62..302d16e67b 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -7,6 +7,7 @@ #include "SkBlurMaskFilter.h" #include "SkBlurMask.h" +#include "SkBlurPriv.h" #include "SkGpuBlurUtils.h" #include "SkMaskFilterBase.h" #include "SkReadBuffer.h" @@ -195,16 +196,16 @@ static uint32_t insert_into_arrays(SkScalar* array1, SkScalar* array2, return skipMask; } -bool SkBlurMaskFilter::ComputeBlurredRRectParams(const SkRRect& srcRRect, const SkRRect& devRRect, - const SkRect& occluder, - SkScalar sigma, SkScalar xformedSigma, - SkRRect* rrectToDraw, - SkISize* widthHeight, - SkScalar rectXs[kMaxDivisions], - SkScalar rectYs[kMaxDivisions], - SkScalar texXs[kMaxDivisions], - SkScalar texYs[kMaxDivisions], - int* numXs, int* numYs, uint32_t* skipMask) { +bool SkComputeBlurredRRectParams(const SkRRect& srcRRect, const SkRRect& devRRect, + const SkRect& occluder, + SkScalar sigma, SkScalar xformedSigma, + SkRRect* rrectToDraw, + SkISize* widthHeight, + SkScalar rectXs[kSkBlurRRectMaxDivisions], + SkScalar rectYs[kSkBlurRRectMaxDivisions], + SkScalar texXs[kSkBlurRRectMaxDivisions], + SkScalar texYs[kSkBlurRRectMaxDivisions], + int* numXs, int* numYs, uint32_t* skipMask) { unsigned int devBlurRadius = 3*SkScalarCeilToInt(xformedSigma-1/6.0f); SkScalar srcBlurRadius = 3.0f * sigma; diff --git a/src/gpu/effects/GrRRectBlurEffect.cpp b/src/gpu/effects/GrRRectBlurEffect.cpp index b307946d0c..efb168a565 100644 --- a/src/gpu/effects/GrRRectBlurEffect.cpp +++ b/src/gpu/effects/GrRRectBlurEffect.cpp @@ -28,11 +28,11 @@ std::unique_ptr<GrFragmentProcessor> GrRRectBlurEffect::Make(GrContext* context, // width (and height) of the rrect. SkRRect rrectToDraw; SkISize size; - SkScalar ignored[SkBlurMaskFilter::kMaxDivisions]; + SkScalar ignored[kSkBlurRRectMaxDivisions]; int ignoredSize; uint32_t ignored32; - bool ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams( + bool ninePatchable = SkComputeBlurredRRectParams( srcRRect, devRRect, SkRect::MakeEmpty(), sigma, xformedSigma, &rrectToDraw, &size, ignored, ignored, ignored, ignored, &ignoredSize, &ignoredSize, &ignored32); if (!ninePatchable) { diff --git a/src/gpu/effects/GrRRectBlurEffect.fp b/src/gpu/effects/GrRRectBlurEffect.fp index 5015cd07b4..c9e70bbba8 100644 --- a/src/gpu/effects/GrRRectBlurEffect.fp +++ b/src/gpu/effects/GrRRectBlurEffect.fp @@ -21,6 +21,7 @@ uniform half blurRadius; #include "GrRenderTargetContext.h" #include "GrStyle.h" #include "SkBlurMaskFilter.h" + #include "SkBlurPriv.h" #include "SkGpuBlurUtils.h" #include "SkRRectPriv.h" } @@ -121,18 +122,18 @@ uniform half blurRadius; // width (and height) of the rrect. SkRRect rrectToDraw; SkISize size; - SkScalar ignored[SkBlurMaskFilter::kMaxDivisions]; + SkScalar ignored[kSkBlurRRectMaxDivisions]; int ignoredSize; uint32_t ignored32; - bool ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(srcRRect, devRRect, - SkRect::MakeEmpty(), - sigma, xformedSigma, - &rrectToDraw, &size, - ignored, ignored, - ignored, ignored, - &ignoredSize, &ignoredSize, - &ignored32); + bool ninePatchable = SkComputeBlurredRRectParams(srcRRect, devRRect, + SkRect::MakeEmpty(), + sigma, xformedSigma, + &rrectToDraw, &size, + ignored, ignored, + ignored, ignored, + &ignoredSize, &ignoredSize, + &ignored32); if (!ninePatchable) { return nullptr; } diff --git a/src/gpu/effects/GrRRectBlurEffect.h b/src/gpu/effects/GrRRectBlurEffect.h index 0e63a92c9e..4aa0ac19db 100644 --- a/src/gpu/effects/GrRRectBlurEffect.h +++ b/src/gpu/effects/GrRRectBlurEffect.h @@ -21,6 +21,7 @@ #include "GrRenderTargetContext.h" #include "GrStyle.h" #include "SkBlurMaskFilter.h" +#include "SkBlurPriv.h" #include "SkGpuBlurUtils.h" #include "SkRRectPriv.h" #include "GrFragmentProcessor.h" |