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

Side by Side Diff: src/gpu/effects/GrConvolutionEffect.cpp

Issue 1109863004: Use GLSLCaps for creating processor keys and GLSL-specific programs (Closed) Base URL: https://chromium.googlesource.com/skia@master
Patch Set: Created 5 years, 7 months 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/GrConvolutionEffect.h ('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/GrGLProcessor.h" 9 #include "gl/GrGLProcessor.h"
10 #include "gl/GrGLSL.h" 10 #include "gl/GrGLSL.h"
11 #include "gl/GrGLTexture.h" 11 #include "gl/GrGLTexture.h"
12 #include "gl/builders/GrGLProgramBuilder.h" 12 #include "gl/builders/GrGLProgramBuilder.h"
13 13
14 // For brevity 14 // For brevity
15 typedef GrGLProgramDataManager::UniformHandle UniformHandle; 15 typedef GrGLProgramDataManager::UniformHandle UniformHandle;
16 16
17 class GrGLConvolutionEffect : public GrGLFragmentProcessor { 17 class GrGLConvolutionEffect : public GrGLFragmentProcessor {
18 public: 18 public:
19 GrGLConvolutionEffect(const GrProcessor&); 19 GrGLConvolutionEffect(const GrProcessor&);
20 20
21 virtual void emitCode(GrGLFPBuilder*, 21 virtual void emitCode(GrGLFPBuilder*,
22 const GrFragmentProcessor&, 22 const GrFragmentProcessor&,
23 const char* outputColor, 23 const char* outputColor,
24 const char* inputColor, 24 const char* inputColor,
25 const TransformedCoordsArray&, 25 const TransformedCoordsArray&,
26 const TextureSamplerArray&) override; 26 const TextureSamplerArray&) override;
27 27
28 void setData(const GrGLProgramDataManager& pdman, const GrProcessor&) overri de; 28 void setData(const GrGLProgramDataManager& pdman, const GrProcessor&) overri de;
29 29
30 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe yBuilder*); 30 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder*);
31 31
32 private: 32 private:
33 int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); } 33 int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); }
34 bool useBounds() const { return fUseBounds; } 34 bool useBounds() const { return fUseBounds; }
35 Gr1DKernelEffect::Direction direction() const { return fDirection; } 35 Gr1DKernelEffect::Direction direction() const { return fDirection; }
36 36
37 int fRadius; 37 int fRadius;
38 bool fUseBounds; 38 bool fUseBounds;
39 Gr1DKernelEffect::Direction fDirection; 39 Gr1DKernelEffect::Direction fDirection;
40 UniformHandle fKernelUni; 40 UniformHandle fKernelUni;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 if (Gr1DKernelEffect::kY_Direction == conv.direction() && 127 if (Gr1DKernelEffect::kY_Direction == conv.direction() &&
128 texture.origin() != kTopLeft_GrSurfaceOrigin) { 128 texture.origin() != kTopLeft_GrSurfaceOrigin) {
129 pdman.set2f(fBoundsUni, 1.0f - bounds[1], 1.0f - bounds[0]); 129 pdman.set2f(fBoundsUni, 1.0f - bounds[1], 1.0f - bounds[0]);
130 } else { 130 } else {
131 pdman.set2f(fBoundsUni, bounds[0], bounds[1]); 131 pdman.set2f(fBoundsUni, bounds[0], bounds[1]);
132 } 132 }
133 } 133 }
134 pdman.set1fv(fKernelUni, this->width(), conv.kernel()); 134 pdman.set1fv(fKernelUni, this->width(), conv.kernel());
135 } 135 }
136 136
137 void GrGLConvolutionEffect::GenKey(const GrProcessor& processor, const GrGLCaps& , 137 void GrGLConvolutionEffect::GenKey(const GrProcessor& processor, const GrGLSLCap s&,
138 GrProcessorKeyBuilder* b) { 138 GrProcessorKeyBuilder* b) {
139 const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>(); 139 const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>();
140 uint32_t key = conv.radius(); 140 uint32_t key = conv.radius();
141 key <<= 2; 141 key <<= 2;
142 if (conv.useBounds()) { 142 if (conv.useBounds()) {
143 key |= 0x2; 143 key |= 0x2;
144 key |= GrConvolutionEffect::kY_Direction == conv.direction() ? 0x1 : 0x0 ; 144 key |= GrConvolutionEffect::kY_Direction == conv.direction() ? 0x1 : 0x0 ;
145 } 145 }
146 b->add32(key); 146 b->add32(key);
147 } 147 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 float scale = 1.0f / sum; 189 float scale = 1.0f / sum;
190 for (int i = 0; i < width; ++i) { 190 for (int i = 0; i < width; ++i) {
191 fKernel[i] *= scale; 191 fKernel[i] *= scale;
192 } 192 }
193 memcpy(fBounds, bounds, sizeof(fBounds)); 193 memcpy(fBounds, bounds, sizeof(fBounds));
194 } 194 }
195 195
196 GrConvolutionEffect::~GrConvolutionEffect() { 196 GrConvolutionEffect::~GrConvolutionEffect() {
197 } 197 }
198 198
199 void GrConvolutionEffect::getGLProcessorKey(const GrGLCaps& caps, 199 void GrConvolutionEffect::getGLProcessorKey(const GrGLSLCaps& caps,
200 GrProcessorKeyBuilder* b) const { 200 GrProcessorKeyBuilder* b) const {
201 GrGLConvolutionEffect::GenKey(*this, caps, b); 201 GrGLConvolutionEffect::GenKey(*this, caps, b);
202 } 202 }
203 203
204 GrGLFragmentProcessor* GrConvolutionEffect::createGLInstance() const { 204 GrGLFragmentProcessor* GrConvolutionEffect::createGLInstance() const {
205 return SkNEW_ARGS(GrGLConvolutionEffect, (*this)); 205 return SkNEW_ARGS(GrGLConvolutionEffect, (*this));
206 } 206 }
207 207
208 bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 208 bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
209 const GrConvolutionEffect& s = sBase.cast<GrConvolutionEffect>(); 209 const GrConvolutionEffect& s = sBase.cast<GrConvolutionEffect>();
(...skipping 26 matching lines...) Expand all
236 } 236 }
237 237
238 bool useBounds = random->nextBool(); 238 bool useBounds = random->nextBool();
239 return GrConvolutionEffect::Create(textures[texIdx], 239 return GrConvolutionEffect::Create(textures[texIdx],
240 dir, 240 dir,
241 radius, 241 radius,
242 kernel, 242 kernel,
243 useBounds, 243 useBounds,
244 bounds); 244 bounds);
245 } 245 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConvolutionEffect.h ('k') | src/gpu/effects/GrCoverageSetOpXP.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698