diff options
author | 2017-01-30 09:14:04 -0500 | |
---|---|---|
committer | 2017-01-30 14:51:30 +0000 | |
commit | d0dc05b98b71af43b44f13beba1292db52b75539 (patch) | |
tree | 8f99420762c16a6416857d6a9fc3f49436736013 /src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp | |
parent | b53f4fa0824613bf0a8eb2d712a9e918327e5bc4 (diff) |
Make blur utils take GrTextureProxies
Change-Id: I1c5054de6d9827eece2f73c4c78818b4db0bc611
Reviewed-on: https://skia-review.googlesource.com/7738
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp')
-rw-r--r-- | src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp index c5f554fc69..66aba13438 100644 --- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp +++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp @@ -115,12 +115,17 @@ void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman, } pdman.set2fv(fImageIncrementUni, 1, imageIncrement); if (conv.useBounds()) { - const float* bounds = conv.bounds(); - if (Gr1DKernelEffect::kY_Direction == conv.direction() && - texture.origin() != kTopLeft_GrSurfaceOrigin) { - pdman.set2f(fBoundsUni, 1.0f - bounds[1], 1.0f - bounds[0]); + const int* bounds = conv.bounds(); + if (Gr1DKernelEffect::kX_Direction == conv.direction()) { + SkScalar inv = SkScalarInvert(SkIntToScalar(texture.width())); + pdman.set2f(fBoundsUni, inv * bounds[0], inv * bounds[1]); } else { - pdman.set2f(fBoundsUni, bounds[0], bounds[1]); + SkScalar inv = SkScalarInvert(SkIntToScalar(texture.height())); + if (texture.origin() != kTopLeft_GrSurfaceOrigin) { + pdman.set2f(fBoundsUni, 1.0f - (inv * bounds[1]), 1.0f - (inv * bounds[0])); + } else { + pdman.set2f(fBoundsUni, inv * bounds[1], inv * bounds[0]); + } } } int width = Gr1DKernelEffect::WidthFromRadius(conv.radius()); @@ -144,8 +149,6 @@ void GrGLConvolutionEffect::GenKey(const GrProcessor& processor, const GrShaderC } /////////////////////////////////////////////////////////////////////////////// - - static void fill_in_1D_guassian_kernel(float* kernel, int width, float gaussianSigma, int radius) { const float denom = 1.0f / (2.0f * gaussianSigma * gaussianSigma); @@ -169,7 +172,7 @@ GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor(G int radius, float gaussianSigma, bool useBounds, - float bounds[2]) + int bounds[2]) : INHERITED(texture, direction, radius, ModulationFlags(texture->config())) , fUseBounds(useBounds) { this->initClassID<GrGaussianConvolutionFragmentProcessor>(); @@ -187,7 +190,7 @@ GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor( int radius, float gaussianSigma, bool useBounds, - float bounds[2]) + int bounds[2]) : INHERITED{context, ModulationFlags(proxy->config()), GR_PROXY_MOVE(proxy), @@ -230,16 +233,25 @@ sk_sp<GrFragmentProcessor> GrGaussianConvolutionFragmentProcessor::TestCreate( GrProcessorTestData* d) { int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : GrProcessorUnitTest::kAlphaTextureIdx; - Direction dir = d->fRandom->nextBool() ? kX_Direction : kY_Direction; - int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius); + sk_sp<GrTextureProxy> proxy = d->textureProxy(texIdx); bool useBounds = d->fRandom->nextBool(); - float bounds[2]; - for (size_t i = 0; i < SK_ARRAY_COUNT(bounds); ++i) { - bounds[i] = d->fRandom->nextF(); + int bounds[2]; + + Direction dir; + if (d->fRandom->nextBool()) { + dir = kX_Direction; + bounds[0] = d->fRandom->nextRangeU(0, proxy->width()-1); + bounds[1] = d->fRandom->nextRangeU(bounds[0], proxy->width()-1); + } else { + dir = kY_Direction; + bounds[0] = d->fRandom->nextRangeU(0, proxy->height()-1); + bounds[1] = d->fRandom->nextRangeU(bounds[0], proxy->height()-1); } + int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius); float sigma = radius / 3.f; + return GrGaussianConvolutionFragmentProcessor::Make( d->context(), d->textureProxy(texIdx), dir, radius, sigma, useBounds, bounds); } |