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

Side by Side Diff: src/gpu/effects/GrConvolutionEffect.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/gpu/effects/GrConvexPolyEffect.cpp ('k') | src/gpu/effects/GrCoverageSetOpXP.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 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "GrConvolutionEffect.h" 8 #include "GrConvolutionEffect.h"
9 #include "gl/GrGLFragmentProcessor.h" 9 #include "gl/GrGLFragmentProcessor.h"
10 #include "gl/GrGLTexture.h" 10 #include "gl/GrGLTexture.h"
11 #include "gl/builders/GrGLProgramBuilder.h" 11 #include "gl/builders/GrGLProgramBuilder.h"
12 #include "glsl/GrGLSLProgramDataManager.h"
12 13
13 // For brevity 14 // For brevity
14 typedef GrGLProgramDataManager::UniformHandle UniformHandle; 15 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
15 16
16 class GrGLConvolutionEffect : public GrGLFragmentProcessor { 17 class GrGLConvolutionEffect : public GrGLFragmentProcessor {
17 public: 18 public:
18 GrGLConvolutionEffect(const GrProcessor&); 19 GrGLConvolutionEffect(const GrProcessor&);
19 20
20 virtual void emitCode(EmitArgs&) override; 21 virtual void emitCode(EmitArgs&) override;
21 22
22 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder*); 23 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder*);
23 24
24 protected: 25 protected:
25 void onSetData(const GrGLProgramDataManager& pdman, const GrProcessor&) over ride; 26 void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor&) ov erride;
26 27
27 private: 28 private:
28 int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); } 29 int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); }
29 bool useBounds() const { return fUseBounds; } 30 bool useBounds() const { return fUseBounds; }
30 Gr1DKernelEffect::Direction direction() const { return fDirection; } 31 Gr1DKernelEffect::Direction direction() const { return fDirection; }
31 32
32 int fRadius; 33 int fRadius;
33 bool fUseBounds; 34 bool fUseBounds;
34 Gr1DKernelEffect::Direction fDirection; 35 Gr1DKernelEffect::Direction fDirection;
35 UniformHandle fKernelUni; 36 UniformHandle fKernelUni;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 fsBuilder->codeAppend("}"); 94 fsBuilder->codeAppend("}");
94 } 95 }
95 fsBuilder->codeAppendf("\t\tcoord += %s;\n", imgInc); 96 fsBuilder->codeAppendf("\t\tcoord += %s;\n", imgInc);
96 } 97 }
97 98
98 SkString modulate; 99 SkString modulate;
99 GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor); 100 GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor);
100 fsBuilder->codeAppend(modulate.c_str()); 101 fsBuilder->codeAppend(modulate.c_str());
101 } 102 }
102 103
103 void GrGLConvolutionEffect::onSetData(const GrGLProgramDataManager& pdman, 104 void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
104 const GrProcessor& processor) { 105 const GrProcessor& processor) {
105 const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>(); 106 const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>();
106 GrTexture& texture = *conv.texture(0); 107 GrTexture& texture = *conv.texture(0);
107 // the code we generated was for a specific kernel radius 108 // the code we generated was for a specific kernel radius
108 SkASSERT(conv.radius() == fRadius); 109 SkASSERT(conv.radius() == fRadius);
109 float imageIncrement[2] = { 0 }; 110 float imageIncrement[2] = { 0 };
110 float ySign = texture.origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f; 111 float ySign = texture.origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
111 switch (conv.direction()) { 112 switch (conv.direction()) {
112 case Gr1DKernelEffect::kX_Direction: 113 case Gr1DKernelEffect::kX_Direction:
113 imageIncrement[0] = 1.0f / texture.width(); 114 imageIncrement[0] = 1.0f / texture.width();
114 break; 115 break;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 231 }
231 232
232 bool useBounds = d->fRandom->nextBool(); 233 bool useBounds = d->fRandom->nextBool();
233 return GrConvolutionEffect::Create(d->fTextures[texIdx], 234 return GrConvolutionEffect::Create(d->fTextures[texIdx],
234 dir, 235 dir,
235 radius, 236 radius,
236 kernel, 237 kernel,
237 useBounds, 238 useBounds,
238 bounds); 239 bounds);
239 } 240 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConvexPolyEffect.cpp ('k') | src/gpu/effects/GrCoverageSetOpXP.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698