| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrCircleBlurFragmentProcessor.h" | 8 #include "GrCircleBlurFragmentProcessor.h" |
| 9 | 9 |
| 10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // We just want to compute "length(vec) - %s.z + 0.5) * %s.w" but need to re
arrange | 59 // We just want to compute "length(vec) - %s.z + 0.5) * %s.w" but need to re
arrange |
| 60 // for precision | 60 // for precision |
| 61 fragBuilder->codeAppendf("vec2 vec = vec2( (%s.x - %s.x) * %s.w , (%s.y - %s
.y) * %s.w );", | 61 fragBuilder->codeAppendf("vec2 vec = vec2( (%s.x - %s.x) * %s.w , (%s.y - %s
.y) * %s.w );", |
| 62 fragmentPos, dataName, dataName, | 62 fragmentPos, dataName, dataName, |
| 63 fragmentPos, dataName, dataName); | 63 fragmentPos, dataName, dataName); |
| 64 fragBuilder->codeAppendf("float dist = length(vec) + ( 0.5 - %s.z ) * %s.w;"
, | 64 fragBuilder->codeAppendf("float dist = length(vec) + ( 0.5 - %s.z ) * %s.w;"
, |
| 65 dataName, dataName); | 65 dataName, dataName); |
| 66 | 66 |
| 67 fragBuilder->codeAppendf("float intensity = "); | 67 fragBuilder->codeAppendf("float intensity = "); |
| 68 fragBuilder->appendTextureLookup(args.fTexSamplers[0], "vec2(dist, 0.5)"); | 68 fragBuilder->appendTextureLookup(args.fUniformHandler->getSampler(args.fTexS
amplers[0]), |
| 69 "vec2(dist, 0.5)"); |
| 69 fragBuilder->codeAppend(".a;"); | 70 fragBuilder->codeAppend(".a;"); |
| 70 | 71 |
| 71 fragBuilder->codeAppendf("%s = src * intensity;\n", args.fOutputColor ); | 72 fragBuilder->codeAppendf("%s = src * intensity;\n", args.fOutputColor ); |
| 72 } | 73 } |
| 73 | 74 |
| 74 void GrGLCircleBlurFragmentProcessor::onSetData(const GrGLSLProgramDataManager&
pdman, | 75 void GrGLCircleBlurFragmentProcessor::onSetData(const GrGLSLProgramDataManager&
pdman, |
| 75 const GrProcessor& proc) { | 76 const GrProcessor& proc) { |
| 76 const GrCircleBlurFragmentProcessor& cbfp = proc.cast<GrCircleBlurFragmentPr
ocessor>(); | 77 const GrCircleBlurFragmentProcessor& cbfp = proc.cast<GrCircleBlurFragmentPr
ocessor>(); |
| 77 const SkRect& circle = cbfp.circle(); | 78 const SkRect& circle = cbfp.circle(); |
| 78 | 79 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor); | 261 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor); |
| 261 | 262 |
| 262 const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessor
TestData* d) { | 263 const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessor
TestData* d) { |
| 263 SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f); | 264 SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f); |
| 264 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); | 265 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); |
| 265 SkRect circle = SkRect::MakeWH(wh, wh); | 266 SkRect circle = SkRect::MakeWH(wh, wh); |
| 266 return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(),
circle, sigma); | 267 return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(),
circle, sigma); |
| 267 } | 268 } |
| 268 | 269 |
| 269 #endif | 270 #endif |
| OLD | NEW |