aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-03-05 16:56:52 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-06 15:12:16 +0000
commit28d47731a1488009eed98c3ddfff2df2c95753c8 (patch)
tree8a7ac87f37f5df95ba67bb78c50a00891ae066b1
parent0c4b7b1f2f1dd37204d401a6993119e5431942a6 (diff)
make compute helper for blurs private
Precursor for moving blurmaskfilter into core, since it is referenced by core code for drawShadow. Bug: skia: Change-Id: I900c6e10523115c75f45d2c410eb6a5ca56a6e4d Reviewed-on: https://skia-review.googlesource.com/112301 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Mike Reed <reed@google.com>
-rw-r--r--include/effects/SkBlurMaskFilter.h22
-rw-r--r--src/core/SkBlurPriv.h37
-rw-r--r--src/effects/SkBlurMaskFilter.cpp21
-rw-r--r--src/gpu/effects/GrRRectBlurEffect.cpp4
-rw-r--r--src/gpu/effects/GrRRectBlurEffect.fp19
-rw-r--r--src/gpu/effects/GrRRectBlurEffect.h1
-rw-r--r--tests/BlurTest.cpp40
7 files changed, 82 insertions, 62 deletions
diff --git a/include/effects/SkBlurMaskFilter.h b/include/effects/SkBlurMaskFilter.h
index af074ffff3..c861f648ab 100644
--- a/include/effects/SkBlurMaskFilter.h
+++ b/include/effects/SkBlurMaskFilter.h
@@ -64,28 +64,6 @@ public:
SkScalar ambient, SkScalar specular);
#endif
- static const int kMaxDivisions = 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
- static bool 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);
-
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
private:
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"
diff --git a/tests/BlurTest.cpp b/tests/BlurTest.cpp
index 29c44d7886..b84fb4ca14 100644
--- a/tests/BlurTest.cpp
+++ b/tests/BlurTest.cpp
@@ -8,6 +8,7 @@
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkBlurDrawLooper.h"
+#include "SkBlurPriv.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkColorPriv.h"
@@ -522,8 +523,10 @@ DEF_TEST(BlurredRRectNinePatchComputation, reporter) {
bool ninePatchable;
SkRRect rrectToDraw;
SkISize size;
- SkScalar rectXs[SkBlurMaskFilter::kMaxDivisions], rectYs[SkBlurMaskFilter::kMaxDivisions];
- SkScalar texXs[SkBlurMaskFilter::kMaxDivisions], texYs[SkBlurMaskFilter::kMaxDivisions];
+ SkScalar rectXs[kSkBlurRRectMaxDivisions],
+ rectYs[kSkBlurRRectMaxDivisions];
+ SkScalar texXs[kSkBlurRRectMaxDivisions],
+ texYs[kSkBlurRRectMaxDivisions];
int numX, numY;
uint32_t skipMask;
@@ -534,11 +537,11 @@ DEF_TEST(BlurredRRectNinePatchComputation, reporter) {
SkRRect rr;
rr.setRectRadii(r, radii);
- ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, rr, SkRect::MakeEmpty(),
- kBlurRad, kBlurRad,
- &rrectToDraw, &size,
- rectXs, rectYs, texXs, texYs,
- &numX, &numY, &skipMask);
+ ninePatchable = SkComputeBlurredRRectParams(rr, rr, SkRect::MakeEmpty(),
+ kBlurRad, kBlurRad,
+ &rrectToDraw, &size,
+ rectXs, rectYs, texXs, texYs,
+ &numX, &numY, &skipMask);
REPORTER_ASSERT(reporter, !ninePatchable);
}
@@ -548,11 +551,11 @@ DEF_TEST(BlurredRRectNinePatchComputation, reporter) {
SkRRect rr;
rr.setRectXY(r, kCornerRad, kCornerRad);
- ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, rr, SkRect::MakeEmpty(),
- kBlurRad, kBlurRad,
- &rrectToDraw, &size,
- rectXs, rectYs, texXs, texYs,
- &numX, &numY, &skipMask);
+ ninePatchable = SkComputeBlurredRRectParams(rr, rr, SkRect::MakeEmpty(),
+ kBlurRad, kBlurRad,
+ &rrectToDraw, &size,
+ rectXs, rectYs, texXs, texYs,
+ &numX, &numY, &skipMask);
static const SkScalar kAns = 12.0f * kBlurRad + 2.0f * kCornerRad + 1.0f;
REPORTER_ASSERT(reporter, ninePatchable);
@@ -569,11 +572,11 @@ DEF_TEST(BlurredRRectNinePatchComputation, reporter) {
SkRRect rr;
rr.setRectXY(r, kXCornerRad, kYCornerRad);
- ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, rr, SkRect::MakeEmpty(),
- kBlurRad, kBlurRad,
- &rrectToDraw, &size,
- rectXs, rectYs, texXs, texYs,
- &numX, &numY, &skipMask);
+ ninePatchable = SkComputeBlurredRRectParams(rr, rr, SkRect::MakeEmpty(),
+ kBlurRad, kBlurRad,
+ &rrectToDraw, &size,
+ rectXs, rectYs, texXs, texYs,
+ &numX, &numY, &skipMask);
static const SkScalar kXAns = 12.0f * kBlurRad + 2.0f * kXCornerRad + 1.0f;
static const SkScalar kYAns = 12.0f * kBlurRad + 2.0f * kYCornerRad + 1.0f;
@@ -614,8 +617,7 @@ DEF_TEST(BlurredRRectNinePatchComputation, reporter) {
continue;
}
- ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(
- rr, rr, occluder,
+ ninePatchable = SkComputeBlurredRRectParams(rr, rr, occluder,
kBlurRad, kBlurRad,
&rrectToDraw, &size,
rectXs, rectYs, texXs, texYs,