OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrCircleBlurFragmentProcessor.h" | 9 #include "GrCircleBlurFragmentProcessor.h" |
10 | 10 |
11 #if SK_SUPPORT_GPU | 11 #if SK_SUPPORT_GPU |
12 | 12 |
13 #include "GrContext.h" | 13 #include "GrContext.h" |
| 14 #include "GrInvariantOutput.h" |
14 #include "GrTextureProvider.h" | 15 #include "GrTextureProvider.h" |
15 | 16 |
16 #include "glsl/GrGLSLFragmentProcessor.h" | 17 #include "glsl/GrGLSLFragmentProcessor.h" |
17 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 18 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
18 #include "glsl/GrGLSLProgramBuilder.h" | |
19 #include "glsl/GrGLSLProgramDataManager.h" | 19 #include "glsl/GrGLSLProgramDataManager.h" |
| 20 #include "glsl/GrGLSLUniformHandler.h" |
20 | 21 |
21 class GrGLCircleBlurFragmentProcessor : public GrGLSLFragmentProcessor { | 22 class GrGLCircleBlurFragmentProcessor : public GrGLSLFragmentProcessor { |
22 public: | 23 public: |
23 GrGLCircleBlurFragmentProcessor(const GrProcessor&) {} | 24 GrGLCircleBlurFragmentProcessor(const GrProcessor&) {} |
24 void emitCode(EmitArgs&) override; | 25 void emitCode(EmitArgs&) override; |
25 | 26 |
26 protected: | 27 protected: |
27 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; | 28 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; |
28 | 29 |
29 private: | 30 private: |
30 GrGLSLProgramDataManager::UniformHandle fDataUniform; | 31 GrGLSLProgramDataManager::UniformHandle fDataUniform; |
31 | 32 |
32 typedef GrGLSLFragmentProcessor INHERITED; | 33 typedef GrGLSLFragmentProcessor INHERITED; |
33 }; | 34 }; |
34 | 35 |
35 void GrGLCircleBlurFragmentProcessor::emitCode(EmitArgs& args) { | 36 void GrGLCircleBlurFragmentProcessor::emitCode(EmitArgs& args) { |
36 | 37 |
37 const char *dataName; | 38 const char *dataName; |
38 | 39 |
39 // The data is formatted as: | 40 // The data is formatted as: |
40 // x,y - the center of the circle | 41 // x,y - the center of the circle |
41 // z - the distance at which the intensity starts falling off (e.g., the
start of the table) | 42 // z - the distance at which the intensity starts falling off (e.g., the
start of the table) |
42 // w - the size of the profile texture | 43 // w - the size of the profile texture |
43 fDataUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Vis
ibility, | 44 fDataUniform = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragm
ent_Visibility, |
44 kVec4f_GrSLType, | 45 kVec4f_GrSLType, |
45 kDefault_GrSLPrecision, | 46 kDefault_GrSLPrecision, |
46 "data", | 47 "data", |
47 &dataName); | 48 &dataName); |
48 | 49 |
49 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 50 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
50 const char *fragmentPos = fragBuilder->fragmentPosition(); | 51 const char *fragmentPos = fragBuilder->fragmentPosition(); |
51 | 52 |
52 if (args.fInputColor) { | 53 if (args.fInputColor) { |
53 fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor); | 54 fragBuilder->codeAppendf("vec4 src=%s;", args.fInputColor); |
54 } else { | 55 } else { |
55 fragBuilder->codeAppendf("vec4 src=vec4(1);"); | 56 fragBuilder->codeAppendf("vec4 src=vec4(1);"); |
56 } | 57 } |
57 | 58 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor); | 253 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor); |
253 | 254 |
254 const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessor
TestData* d) { | 255 const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessor
TestData* d) { |
255 SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f); | 256 SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f); |
256 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); | 257 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); |
257 SkRect circle = SkRect::MakeWH(wh, wh); | 258 SkRect circle = SkRect::MakeWH(wh, wh); |
258 return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(),
circle, sigma); | 259 return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(),
circle, sigma); |
259 } | 260 } |
260 | 261 |
261 #endif | 262 #endif |
OLD | NEW |