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

Side by Side Diff: src/gpu/GrFragmentProcessor.cpp

Issue 1438003003: Move all ShaderBuilder files to GLSL (Closed) Base URL: https://skia.googlesource.com/skia.git@glslProgBuild
Patch Set: nits 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/GrDefaultGeoProcFactory.cpp ('k') | src/gpu/GrOvalRenderer.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 "GrFragmentProcessor.h" 9 #include "GrFragmentProcessor.h"
10 #include "GrCoordTransform.h" 10 #include "GrCoordTransform.h"
11 #include "gl/GrGLFragmentProcessor.h" 11 #include "gl/GrGLFragmentProcessor.h"
12 #include "gl/builders/GrGLProgramBuilder.h" 12 #include "glsl/GrGLSLFragmentShaderBuilder.h"
13 #include "glsl/GrGLSLProgramBuilder.h"
13 #include "glsl/GrGLSLProgramDataManager.h" 14 #include "glsl/GrGLSLProgramDataManager.h"
14 #include "effects/GrConstColorProcessor.h" 15 #include "effects/GrConstColorProcessor.h"
15 #include "effects/GrXfermodeFragmentProcessor.h" 16 #include "effects/GrXfermodeFragmentProcessor.h"
16 17
17 GrFragmentProcessor::~GrFragmentProcessor() { 18 GrFragmentProcessor::~GrFragmentProcessor() {
18 // If we got here then our ref count must have reached zero, so we will have converted refs 19 // If we got here then our ref count must have reached zero, so we will have converted refs
19 // to pending executions for all children. 20 // to pending executions for all children.
20 for (int i = 0; i < fChildProcessors.count(); ++i) { 21 for (int i = 0; i < fChildProcessors.count(); ++i) {
21 fChildProcessors[i]->completedExecution(); 22 fChildProcessors[i]->completedExecution();
22 } 23 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 146
146 const char* name() const override { return "Premultiply"; } 147 const char* name() const override { return "Premultiply"; }
147 148
148 private: 149 private:
149 GrGLFragmentProcessor* onCreateGLInstance() const override { 150 GrGLFragmentProcessor* onCreateGLInstance() const override {
150 class GLFP : public GrGLFragmentProcessor { 151 class GLFP : public GrGLFragmentProcessor {
151 public: 152 public:
152 GLFP() {} 153 GLFP() {}
153 154
154 void emitCode(EmitArgs& args) override { 155 void emitCode(EmitArgs& args) override {
155 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentS haderBuilder(); 156 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmen tShaderBuilder();
156 this->emitChild(0, nullptr, args); 157 this->emitChild(0, nullptr, args);
157 fsBuilder->codeAppendf("%s.rgb *= %s.rgb;", args.fOutputColo r, 158 fsBuilder->codeAppendf("%s.rgb *= %s.rgb;", args.fOutputColo r,
158 args.fInputColor ); 159 args.fInputColor );
159 fsBuilder->codeAppendf("%s *= %s.a;", args.fOutputColor, arg s.fInputColor); 160 fsBuilder->codeAppendf("%s *= %s.a;", args.fOutputColor, arg s.fInputColor);
160 } 161 }
161 }; 162 };
162 return new GLFP; 163 return new GLFP;
163 } 164 }
164 165
165 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) cons t override {} 166 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) cons t override {}
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 219 }
219 220
220 const char* name() const override { return "Replace Color"; } 221 const char* name() const override { return "Replace Color"; }
221 222
222 GrGLFragmentProcessor* onCreateGLInstance() const override { 223 GrGLFragmentProcessor* onCreateGLInstance() const override {
223 class GLFP : public GrGLFragmentProcessor { 224 class GLFP : public GrGLFragmentProcessor {
224 public: 225 public:
225 GLFP() : fHaveSetColor(false) {} 226 GLFP() : fHaveSetColor(false) {}
226 void emitCode(EmitArgs& args) override { 227 void emitCode(EmitArgs& args) override {
227 const char* colorName; 228 const char* colorName;
228 fColorUni = args.fBuilder->addUniform(GrGLProgramBuilder::kF ragment_Visibility, 229 fColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder:: kFragment_Visibility,
229 kVec4f_GrSLType, kDefa ult_GrSLPrecision, 230 kVec4f_GrSLType, kDefa ult_GrSLPrecision,
230 "Color", &colorName); 231 "Color", &colorName);
231 this->emitChild(0, colorName, args); 232 this->emitChild(0, colorName, args);
232 } 233 }
233 234
234 private: 235 private:
235 void onSetData(const GrGLSLProgramDataManager& pdman, 236 void onSetData(const GrGLSLProgramDataManager& pdman,
236 const GrProcessor& fp) override { 237 const GrProcessor& fp) override {
237 GrColor color = fp.cast<ReplaceInputFragmentProcessor>().fCo lor; 238 GrColor color = fp.cast<ReplaceInputFragmentProcessor>().fCo lor;
238 if (!fHaveSetColor || color != fPreviousColor) { 239 if (!fHaveSetColor || color != fPreviousColor) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 368 }
368 } 369 }
369 370
370 if (1 == cnt) { 371 if (1 == cnt) {
371 return SkRef(series[0]); 372 return SkRef(series[0]);
372 } else { 373 } else {
373 return new SeriesFragmentProcessor(series, cnt); 374 return new SeriesFragmentProcessor(series, cnt);
374 } 375 }
375 } 376 }
376 377
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.cpp ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698