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

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

Issue 648463003: FPs now use the correct builder types(just a rename) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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/GrDitherEffect.cpp ('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 "gl/builders/GrGLProgramBuilder.h" 7 #include "gl/builders/GrGLProgramBuilder.h"
8 #include "GrMatrixConvolutionEffect.h" 8 #include "GrMatrixConvolutionEffect.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 "GrTBackendProcessorFactory.h" 12 #include "GrTBackendProcessorFactory.h"
13 13
14 class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor { 14 class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor {
15 public: 15 public:
16 GrGLMatrixConvolutionEffect(const GrBackendProcessorFactory& factory, 16 GrGLMatrixConvolutionEffect(const GrBackendProcessorFactory& factory,
17 const GrProcessor&); 17 const GrProcessor&);
18 virtual void emitCode(GrGLProgramBuilder*, 18 virtual void emitCode(GrGLFPBuilder*,
19 const GrFragmentProcessor&, 19 const GrFragmentProcessor&,
20 const GrProcessorKey&, 20 const GrProcessorKey&,
21 const char* outputColor, 21 const char* outputColor,
22 const char* inputColor, 22 const char* inputColor,
23 const TransformedCoordsArray&, 23 const TransformedCoordsArray&,
24 const TextureSamplerArray&) SK_OVERRIDE; 24 const TextureSamplerArray&) SK_OVERRIDE;
25 25
26 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe yBuilder*); 26 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe yBuilder*);
27 27
28 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE; 28 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE;
(...skipping 15 matching lines...) Expand all
44 }; 44 };
45 45
46 GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendProcesso rFactory& factory, 46 GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendProcesso rFactory& factory,
47 const GrProcessor& proc essor) 47 const GrProcessor& proc essor)
48 : INHERITED(factory) { 48 : INHERITED(factory) {
49 const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffec t>(); 49 const GrMatrixConvolutionEffect& m = processor.cast<GrMatrixConvolutionEffec t>();
50 fKernelSize = m.kernelSize(); 50 fKernelSize = m.kernelSize();
51 fConvolveAlpha = m.convolveAlpha(); 51 fConvolveAlpha = m.convolveAlpha();
52 } 52 }
53 53
54 void GrGLMatrixConvolutionEffect::emitCode(GrGLProgramBuilder* builder, 54 void GrGLMatrixConvolutionEffect::emitCode(GrGLFPBuilder* builder,
55 const GrFragmentProcessor& fp, 55 const GrFragmentProcessor& fp,
56 const GrProcessorKey& key, 56 const GrProcessorKey& key,
57 const char* outputColor, 57 const char* outputColor,
58 const char* inputColor, 58 const char* inputColor,
59 const TransformedCoordsArray& coords, 59 const TransformedCoordsArray& coords,
60 const TextureSamplerArray& samplers) { 60 const TextureSamplerArray& samplers) {
61 sk_ignore_unused_variable(inputColor); 61 sk_ignore_unused_variable(inputColor);
62 const GrTextureDomain& domain = fp.cast<GrMatrixConvolutionEffect>().domain( ); 62 const GrTextureDomain& domain = fp.cast<GrMatrixConvolutionEffect>().domain( );
63 63
64 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 64 fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
(...skipping 12 matching lines...) Expand all
77 kFloat_GrSLType, "Bias"); 77 kFloat_GrSLType, "Bias");
78 78
79 const char* kernelOffset = builder->getUniformCStr(fKernelOffsetUni); 79 const char* kernelOffset = builder->getUniformCStr(fKernelOffsetUni);
80 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); 80 const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
81 const char* kernel = builder->getUniformCStr(fKernelUni); 81 const char* kernel = builder->getUniformCStr(fKernelUni);
82 const char* gain = builder->getUniformCStr(fGainUni); 82 const char* gain = builder->getUniformCStr(fGainUni);
83 const char* bias = builder->getUniformCStr(fBiasUni); 83 const char* bias = builder->getUniformCStr(fBiasUni);
84 int kWidth = fKernelSize.width(); 84 int kWidth = fKernelSize.width();
85 int kHeight = fKernelSize.height(); 85 int kHeight = fKernelSize.height();
86 86
87 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 87 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
88 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); 88 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0);
89 fsBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);"); 89 fsBuilder->codeAppend("vec4 sum = vec4(0, 0, 0, 0);");
90 fsBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), kerne lOffset, 90 fsBuilder->codeAppendf("vec2 coord = %s - %s * %s;", coords2D.c_str(), kerne lOffset,
91 imgInc); 91 imgInc);
92 fsBuilder->codeAppend("vec4 c;"); 92 fsBuilder->codeAppend("vec4 c;");
93 93
94 for (int y = 0; y < kHeight; y++) { 94 for (int y = 0; y < kHeight; y++) {
95 for (int x = 0; x < kWidth; x++) { 95 for (int x = 0; x < kWidth; x++) {
96 GrGLShaderBuilder::ShaderBlock block(fsBuilder); 96 GrGLShaderBuilder::ShaderBlock block(fsBuilder);
97 fsBuilder->codeAppendf("float k = %s[%d * %d + %d];", kernel, y, kWi dth, x); 97 fsBuilder->codeAppendf("float k = %s[%d * %d + %d];", kernel, y, kWi dth, x);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 return GrMatrixConvolutionEffect::Create(textures[texIdx], 267 return GrMatrixConvolutionEffect::Create(textures[texIdx],
268 bounds, 268 bounds,
269 kernelSize, 269 kernelSize,
270 kernel.get(), 270 kernel.get(),
271 gain, 271 gain,
272 bias, 272 bias,
273 kernelOffset, 273 kernelOffset,
274 tileMode, 274 tileMode,
275 convolveAlpha); 275 convolveAlpha);
276 } 276 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDitherEffect.cpp ('k') | src/gpu/effects/GrOvalEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698