Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: src/effects/GrCircleBlurFragmentProcessor.cpp

Issue 1428543003: Create GLSL base class for ProgramDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add space Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkLightingShader.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrTextureProvider.h" 14 #include "GrTextureProvider.h"
15 15
16 #include "gl/GrGLFragmentProcessor.h" 16 #include "gl/GrGLFragmentProcessor.h"
17 #include "gl/builders/GrGLProgramBuilder.h" 17 #include "gl/builders/GrGLProgramBuilder.h"
18 #include "glsl/GrGLSLProgramDataManager.h"
18 19
19 class GrGLCircleBlurFragmentProcessor : public GrGLFragmentProcessor { 20 class GrGLCircleBlurFragmentProcessor : public GrGLFragmentProcessor {
20 public: 21 public:
21 GrGLCircleBlurFragmentProcessor(const GrProcessor&) {} 22 GrGLCircleBlurFragmentProcessor(const GrProcessor&) {}
22 void emitCode(EmitArgs&) override; 23 void emitCode(EmitArgs&) override;
23 24
24 protected: 25 protected:
25 void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; 26 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
26 27
27 private: 28 private:
28 GrGLProgramDataManager::UniformHandle fDataUniform; 29 GrGLSLProgramDataManager::UniformHandle fDataUniform;
29 30
30 typedef GrGLFragmentProcessor INHERITED; 31 typedef GrGLFragmentProcessor INHERITED;
31 }; 32 };
32 33
33 void GrGLCircleBlurFragmentProcessor::emitCode(EmitArgs& args) { 34 void GrGLCircleBlurFragmentProcessor::emitCode(EmitArgs& args) {
34 35
35 const char *dataName; 36 const char *dataName;
36 37
37 // The data is formatted as: 38 // The data is formatted as:
38 // x,y - the center of the circle 39 // x,y - the center of the circle
(...skipping 17 matching lines...) Expand all
56 fsBuilder->codeAppendf("vec2 vec = %s.xy - %s.xy;", fragmentPos, dataName); 57 fsBuilder->codeAppendf("vec2 vec = %s.xy - %s.xy;", fragmentPos, dataName);
57 fsBuilder->codeAppendf("float dist = (length(vec) - %s.z + 0.5) / %s.w;", da taName, dataName); 58 fsBuilder->codeAppendf("float dist = (length(vec) - %s.z + 0.5) / %s.w;", da taName, dataName);
58 59
59 fsBuilder->codeAppendf("float intensity = "); 60 fsBuilder->codeAppendf("float intensity = ");
60 fsBuilder->appendTextureLookup(args.fSamplers[0], "vec2(dist, 0.5)"); 61 fsBuilder->appendTextureLookup(args.fSamplers[0], "vec2(dist, 0.5)");
61 fsBuilder->codeAppend(".a;"); 62 fsBuilder->codeAppend(".a;");
62 63
63 fsBuilder->codeAppendf("%s = src * intensity;\n", args.fOutputColor ); 64 fsBuilder->codeAppendf("%s = src * intensity;\n", args.fOutputColor );
64 } 65 }
65 66
66 void GrGLCircleBlurFragmentProcessor::onSetData(const GrGLProgramDataManager& pd man, 67 void GrGLCircleBlurFragmentProcessor::onSetData(const GrGLSLProgramDataManager& pdman,
67 const GrProcessor& proc) { 68 const GrProcessor& proc) {
68 const GrCircleBlurFragmentProcessor& cbfp = proc.cast<GrCircleBlurFragmentPr ocessor>(); 69 const GrCircleBlurFragmentProcessor& cbfp = proc.cast<GrCircleBlurFragmentPr ocessor>();
69 const SkRect& circle = cbfp.circle(); 70 const SkRect& circle = cbfp.circle();
70 71
71 // The data is formatted as: 72 // The data is formatted as:
72 // x,y - the center of the circle 73 // x,y - the center of the circle
73 // z - the distance at which the intensity starts falling off (e.g., the start of the table) 74 // z - the distance at which the intensity starts falling off (e.g., the start of the table)
74 // w - the size of the profile texture 75 // w - the size of the profile texture
75 pdman.set4f(fDataUniform, circle.centerX(), circle.centerY(), cbfp.offset(), 76 pdman.set4f(fDataUniform, circle.centerX(), circle.centerY(), cbfp.offset(),
76 SkIntToScalar(cbfp.profileSize())); 77 SkIntToScalar(cbfp.profileSize()));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor); 251 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor);
251 252
252 const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessor TestData* d) { 253 const GrFragmentProcessor* GrCircleBlurFragmentProcessor::TestCreate(GrProcessor TestData* d) {
253 SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f); 254 SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f);
254 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); 255 SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
255 SkRect circle = SkRect::MakeWH(wh, wh); 256 SkRect circle = SkRect::MakeWH(wh, wh);
256 return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(), circle, sigma); 257 return GrCircleBlurFragmentProcessor::Create(d->fContext->textureProvider(), circle, sigma);
257 } 258 }
258 259
259 #endif 260 #endif
OLDNEW
« no previous file with comments | « src/core/SkLightingShader.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698