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

Side by Side Diff: src/gpu/effects/GrMatrixConvolutionEffect.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/GrMatrixConvolutionEffect.h ('k') | src/gpu/effects/GrOvalEffect.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 2014 Google Inc. 2 * Copyright 2014 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 #include "GrMatrixConvolutionEffect.h" 7 #include "GrMatrixConvolutionEffect.h"
8 #include "gl/GrGLProcessor.h" 8 #include "gl/GrGLProcessor.h"
9 #include "gl/GrGLSL.h" 9 #include "gl/GrGLSL.h"
10 #include "gl/GrGLTexture.h" 10 #include "gl/GrGLTexture.h"
11 #include "gl/builders/GrGLProgramBuilder.h" 11 #include "gl/builders/GrGLProgramBuilder.h"
12 12
13 class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor { 13 class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor {
14 public: 14 public:
15 GrGLMatrixConvolutionEffect(const GrProcessor&); 15 GrGLMatrixConvolutionEffect(const GrProcessor&);
16 virtual void emitCode(GrGLFPBuilder*, 16 virtual void emitCode(GrGLFPBuilder*,
17 const GrFragmentProcessor&, 17 const GrFragmentProcessor&,
18 const char* outputColor, 18 const char* outputColor,
19 const char* inputColor, 19 const char* inputColor,
20 const TransformedCoordsArray&, 20 const TransformedCoordsArray&,
21 const TextureSamplerArray&) override; 21 const TextureSamplerArray&) override;
22 22
23 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe yBuilder*); 23 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor KeyBuilder*);
24 24
25 void setData(const GrGLProgramDataManager&, const GrProcessor&) override; 25 void setData(const GrGLProgramDataManager&, const GrProcessor&) override;
26 26
27 private: 27 private:
28 typedef GrGLProgramDataManager::UniformHandle UniformHandle; 28 typedef GrGLProgramDataManager::UniformHandle UniformHandle;
29 SkISize fKernelSize; 29 SkISize fKernelSize;
30 bool fConvolveAlpha; 30 bool fConvolveAlpha;
31 31
32 UniformHandle fKernelUni; 32 UniformHandle fKernelUni;
33 UniformHandle fImageIncrementUni; 33 UniformHandle fImageIncrementUni;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 fsBuilder->codeAppendf("%s.rgb = sum.rgb * %s + %s;", outputColor, gain, bias); 105 fsBuilder->codeAppendf("%s.rgb = sum.rgb * %s + %s;", outputColor, gain, bias);
106 fsBuilder->codeAppendf("%s.rgb *= %s.a;", outputColor, outputColor); 106 fsBuilder->codeAppendf("%s.rgb *= %s.a;", outputColor, outputColor);
107 } 107 }
108 108
109 SkString modulate; 109 SkString modulate;
110 GrGLSLMulVarBy4f(&modulate, outputColor, inputColor); 110 GrGLSLMulVarBy4f(&modulate, outputColor, inputColor);
111 fsBuilder->codeAppend(modulate.c_str()); 111 fsBuilder->codeAppend(modulate.c_str());
112 } 112 }
113 113
114 void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor, 114 void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor,
115 const GrGLCaps&, GrProcessorKeyBuilder* b) { 115 const GrGLSLCaps&, GrProcessorKeyBuilde r* b) {
116 const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffec t>(); 116 const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffec t>();
117 SkASSERT(m.kernelSize().width() <= 0x7FFF && m.kernelSize().height() <= 0xFF FF); 117 SkASSERT(m.kernelSize().width() <= 0x7FFF && m.kernelSize().height() <= 0xFF FF);
118 uint32_t key = m.kernelSize().width() << 16 | m.kernelSize().height(); 118 uint32_t key = m.kernelSize().width() << 16 | m.kernelSize().height();
119 key |= m.convolveAlpha() ? 1 << 31 : 0; 119 key |= m.convolveAlpha() ? 1 << 31 : 0;
120 b->add32(key); 120 b->add32(key);
121 b->add32(GrTextureDomain::GLDomain::DomainKey(m.domain())); 121 b->add32(GrTextureDomain::GLDomain::DomainKey(m.domain()));
122 } 122 }
123 123
124 void GrGLMatrixConvolutionEffect::setData(const GrGLProgramDataManager& pdman, 124 void GrGLMatrixConvolutionEffect::setData(const GrGLProgramDataManager& pdman,
125 const GrProcessor& processor) { 125 const GrProcessor& processor) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) { 158 for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) {
159 fKernel[i] = SkScalarToFloat(kernel[i]); 159 fKernel[i] = SkScalarToFloat(kernel[i]);
160 } 160 }
161 fKernelOffset[0] = static_cast<float>(kernelOffset.x()); 161 fKernelOffset[0] = static_cast<float>(kernelOffset.x());
162 fKernelOffset[1] = static_cast<float>(kernelOffset.y()); 162 fKernelOffset[1] = static_cast<float>(kernelOffset.y());
163 } 163 }
164 164
165 GrMatrixConvolutionEffect::~GrMatrixConvolutionEffect() { 165 GrMatrixConvolutionEffect::~GrMatrixConvolutionEffect() {
166 } 166 }
167 167
168 void GrMatrixConvolutionEffect::getGLProcessorKey(const GrGLCaps& caps, 168 void GrMatrixConvolutionEffect::getGLProcessorKey(const GrGLSLCaps& caps,
169 GrProcessorKeyBuilder* b) cons t { 169 GrProcessorKeyBuilder* b) cons t {
170 GrGLMatrixConvolutionEffect::GenKey(*this, caps, b); 170 GrGLMatrixConvolutionEffect::GenKey(*this, caps, b);
171 } 171 }
172 172
173 GrGLFragmentProcessor* GrMatrixConvolutionEffect::createGLInstance() const { 173 GrGLFragmentProcessor* GrMatrixConvolutionEffect::createGLInstance() const {
174 return SkNEW_ARGS(GrGLMatrixConvolutionEffect, (*this)); 174 return SkNEW_ARGS(GrGLMatrixConvolutionEffect, (*this));
175 } 175 }
176 176
177 bool GrMatrixConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) cons t { 177 bool GrMatrixConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) cons t {
178 const GrMatrixConvolutionEffect& s = sBase.cast<GrMatrixConvolutionEffect>() ; 178 const GrMatrixConvolutionEffect& s = sBase.cast<GrMatrixConvolutionEffect>() ;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 return GrMatrixConvolutionEffect::Create(textures[texIdx], 263 return GrMatrixConvolutionEffect::Create(textures[texIdx],
264 bounds, 264 bounds,
265 kernelSize, 265 kernelSize,
266 kernel.get(), 266 kernel.get(),
267 gain, 267 gain,
268 bias, 268 bias,
269 kernelOffset, 269 kernelOffset,
270 tileMode, 270 tileMode,
271 convolveAlpha); 271 convolveAlpha);
272 } 272 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrMatrixConvolutionEffect.h ('k') | src/gpu/effects/GrOvalEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698