aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-05-11 16:11:45 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-14 12:01:59 +0000
commit5140f9a8e424985c4c354c40c41ca6b0a9b8772a (patch)
tree059552b642da7800f59886b593ec2391b5795ca1 /src/gpu/effects
parentb06a1eb4e5793b5053981cc76c72c497650c0e1a (diff)
Minor refactoring to image filters
This pulls the boring parts out of: https://skia-review.googlesource.com/c/skia/+/127338 (Fix srcBounds computation in SkMatrixConvolutionImageFilter) TBR=bsalomon@google.com Change-Id: Iade788fcc96c4c16989d13e7592030a6a1d3f170 Reviewed-on: https://skia-review.googlesource.com/127573 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.cpp20
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.h18
2 files changed, 21 insertions, 17 deletions
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index f7e6675c80..cd1ef1a623 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -144,8 +144,8 @@ void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdma
fDomain.setData(pdman, conv.domain(), proxy);
}
-GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy,
- const SkIRect& bounds,
+GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> srcProxy,
+ const SkIRect& srcBounds,
const SkISize& kernelSize,
const SkScalar* kernel,
SkScalar gain,
@@ -156,9 +156,11 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy
// To advertise either the modulation or opaqueness optimizations we'd have to examine the
// parameters.
: INHERITED(kGrMatrixConvolutionEffect_ClassID, kNone_OptimizationFlags)
- , fCoordTransform(proxy.get())
- , fDomain(proxy.get(), GrTextureDomain::MakeTexelDomainForMode(bounds, tileMode), tileMode)
- , fTextureSampler(std::move(proxy))
+ , fCoordTransform(srcProxy.get())
+ , fDomain(srcProxy.get(),
+ GrTextureDomain::MakeTexelDomainForMode(srcBounds, tileMode),
+ tileMode)
+ , fTextureSampler(std::move(srcProxy))
, fKernelSize(kernelSize)
, fGain(SkScalarToFloat(gain))
, fBias(SkScalarToFloat(bias) / 255.0f)
@@ -255,8 +257,8 @@ static void fill_in_2D_gaussian_kernel(float* kernel, int width, int height,
// Static function to create a 2D convolution
std::unique_ptr<GrFragmentProcessor> GrMatrixConvolutionEffect::MakeGaussian(
- sk_sp<GrTextureProxy> proxy,
- const SkIRect& bounds,
+ sk_sp<GrTextureProxy> srcProxy,
+ const SkIRect& srcBounds,
const SkISize& kernelSize,
SkScalar gain,
SkScalar bias,
@@ -270,8 +272,8 @@ std::unique_ptr<GrFragmentProcessor> GrMatrixConvolutionEffect::MakeGaussian(
fill_in_2D_gaussian_kernel(kernel, kernelSize.width(), kernelSize.height(), sigmaX, sigmaY);
return std::unique_ptr<GrFragmentProcessor>(
- new GrMatrixConvolutionEffect(std::move(proxy), bounds, kernelSize, kernel, gain, bias,
- kernelOffset, tileMode, convolveAlpha));
+ new GrMatrixConvolutionEffect(std::move(srcProxy), srcBounds, kernelSize, kernel,
+ gain, bias, kernelOffset, tileMode, convolveAlpha));
}
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMatrixConvolutionEffect);
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h
index 2e859b1cdd..844f721864 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.h
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.h
@@ -16,8 +16,8 @@
class GrMatrixConvolutionEffect : public GrFragmentProcessor {
public:
- static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- const SkIRect& bounds,
+ static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> srcProxy,
+ const SkIRect& srcBounds,
const SkISize& kernelSize,
const SkScalar* kernel,
SkScalar gain,
@@ -26,12 +26,12 @@ public:
GrTextureDomain::Mode tileMode,
bool convolveAlpha) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrMatrixConvolutionEffect(std::move(proxy), bounds, kernelSize, kernel, gain,
- bias, kernelOffset, tileMode, convolveAlpha));
+ new GrMatrixConvolutionEffect(std::move(srcProxy), srcBounds, kernelSize, kernel,
+ gain, bias, kernelOffset, tileMode, convolveAlpha));
}
- static std::unique_ptr<GrFragmentProcessor> MakeGaussian(sk_sp<GrTextureProxy> proxy,
- const SkIRect& bounds,
+ static std::unique_ptr<GrFragmentProcessor> MakeGaussian(sk_sp<GrTextureProxy> srcProxy,
+ const SkIRect& srcBounds,
const SkISize& kernelSize,
SkScalar gain,
SkScalar bias,
@@ -55,8 +55,10 @@ public:
std::unique_ptr<GrFragmentProcessor> clone() const override;
private:
- GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy,
- const SkIRect& bounds,
+ // srcProxy is the texture that is going to be convolved
+ // srcBounds is the subset of 'srcProxy' that will be used (e.g., for clamp mode)
+ GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> srcProxy,
+ const SkIRect& srcBounds,
const SkISize& kernelSize,
const SkScalar* kernel,
SkScalar gain,