diff options
author | 2017-01-30 12:26:47 -0500 | |
---|---|---|
committer | 2017-01-30 18:09:23 +0000 | |
commit | 08c5ec71303aa58d6f081914f3e868fa5cce9f4c (patch) | |
tree | 23f08081b94430015e141d4110261648ab566f83 /src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp | |
parent | 861bc3f45d3623e802d98d09c54ba635c64fc716 (diff) |
Make blur utils take GrTextureProxies - take 2
This is a re-land of https://skia-review.googlesource.com/c/7738/ (Make blur utils take GrTextureProxies) with a fix for the Nexus7
Change-Id: I5821a26b1e986daa11d960ae826a1207512cd2a0
Reviewed-on: https://skia-review.googlesource.com/7746
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: 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); } |