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

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

Issue 1434313002: Make all GrFragmentProcessors GL independent. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 "glsl/GrGLSLFragmentProcessor.h"
12 #include "glsl/GrGLSLFragmentShaderBuilder.h" 12 #include "glsl/GrGLSLFragmentShaderBuilder.h"
13 #include "glsl/GrGLSLProgramBuilder.h" 13 #include "glsl/GrGLSLProgramBuilder.h"
14 #include "glsl/GrGLSLProgramDataManager.h" 14 #include "glsl/GrGLSLProgramDataManager.h"
15 #include "effects/GrConstColorProcessor.h" 15 #include "effects/GrConstColorProcessor.h"
16 #include "effects/GrXfermodeFragmentProcessor.h" 16 #include "effects/GrXfermodeFragmentProcessor.h"
17 17
18 GrFragmentProcessor::~GrFragmentProcessor() { 18 GrFragmentProcessor::~GrFragmentProcessor() {
19 // 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
20 // to pending executions for all children. 20 // to pending executions for all children.
21 for (int i = 0; i < fChildProcessors.count(); ++i) { 21 for (int i = 0; i < fChildProcessors.count(); ++i) {
(...skipping 21 matching lines...) Expand all
43 return false; 43 return false;
44 } 44 }
45 for (int i = 0; i < this->numChildProcessors(); ++i) { 45 for (int i = 0; i < this->numChildProcessors(); ++i) {
46 if (!this->childProcessor(i).isEqual(that.childProcessor(i), ignoreCoord Transforms)) { 46 if (!this->childProcessor(i).isEqual(that.childProcessor(i), ignoreCoord Transforms)) {
47 return false; 47 return false;
48 } 48 }
49 } 49 }
50 return true; 50 return true;
51 } 51 }
52 52
53 GrGLFragmentProcessor* GrFragmentProcessor::createGLInstance() const { 53 GrGLSLFragmentProcessor* GrFragmentProcessor::createGLInstance() const {
54 GrGLFragmentProcessor* glFragProc = this->onCreateGLInstance(); 54 GrGLSLFragmentProcessor* glFragProc = this->onCreateGLInstance();
55 glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); 55 glFragProc->fChildProcessors.push_back_n(fChildProcessors.count());
56 for (int i = 0; i < fChildProcessors.count(); ++i) { 56 for (int i = 0; i < fChildProcessors.count(); ++i) {
57 glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLInstance( ); 57 glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLInstance( );
58 } 58 }
59 return glFragProc; 59 return glFragProc;
60 } 60 }
61 61
62 void GrFragmentProcessor::addTextureAccess(const GrTextureAccess* textureAccess) { 62 void GrFragmentProcessor::addTextureAccess(const GrTextureAccess* textureAccess) {
63 // Can't add texture accesses after registering any children since their tex ture accesses have 63 // Can't add texture accesses after registering any children since their tex ture accesses have
64 // already been bubbled up into our fTextureAccesses array 64 // already been bubbled up into our fTextureAccesses array
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 class PremulFragmentProcessor : public GrFragmentProcessor { 140 class PremulFragmentProcessor : public GrFragmentProcessor {
141 public: 141 public:
142 PremulFragmentProcessor(const GrFragmentProcessor* processor) { 142 PremulFragmentProcessor(const GrFragmentProcessor* processor) {
143 this->initClassID<PremulFragmentProcessor>(); 143 this->initClassID<PremulFragmentProcessor>();
144 this->registerChildProcessor(processor); 144 this->registerChildProcessor(processor);
145 } 145 }
146 146
147 const char* name() const override { return "Premultiply"; } 147 const char* name() const override { return "Premultiply"; }
148 148
149 private: 149 private:
150 GrGLFragmentProcessor* onCreateGLInstance() const override { 150 GrGLSLFragmentProcessor* onCreateGLInstance() const override {
151 class GLFP : public GrGLFragmentProcessor { 151 class GLFP : public GrGLSLFragmentProcessor {
152 public: 152 public:
153 GLFP() {} 153 GLFP() {}
154 154
155 void emitCode(EmitArgs& args) override { 155 void emitCode(EmitArgs& args) override {
156 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmen tShaderBuilder(); 156 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmen tShaderBuilder();
157 this->emitChild(0, nullptr, args); 157 this->emitChild(0, nullptr, args);
158 fsBuilder->codeAppendf("%s.rgb *= %s.rgb;", args.fOutputColo r, 158 fsBuilder->codeAppendf("%s.rgb *= %s.rgb;", args.fOutputColo r,
159 args.fInputColor ); 159 args.fInputColor );
160 fsBuilder->codeAppendf("%s *= %s.a;", args.fOutputColor, arg s.fInputColor); 160 fsBuilder->codeAppendf("%s *= %s.a;", args.fOutputColor, arg s.fInputColor);
161 } 161 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 class ReplaceInputFragmentProcessor : public GrFragmentProcessor { 213 class ReplaceInputFragmentProcessor : public GrFragmentProcessor {
214 public: 214 public:
215 ReplaceInputFragmentProcessor(const GrFragmentProcessor* child, GrColor color) 215 ReplaceInputFragmentProcessor(const GrFragmentProcessor* child, GrColor color)
216 : fColor(color) { 216 : fColor(color) {
217 this->initClassID<ReplaceInputFragmentProcessor>(); 217 this->initClassID<ReplaceInputFragmentProcessor>();
218 this->registerChildProcessor(child); 218 this->registerChildProcessor(child);
219 } 219 }
220 220
221 const char* name() const override { return "Replace Color"; } 221 const char* name() const override { return "Replace Color"; }
222 222
223 GrGLFragmentProcessor* onCreateGLInstance() const override { 223 GrGLSLFragmentProcessor* onCreateGLInstance() const override {
224 class GLFP : public GrGLFragmentProcessor { 224 class GLFP : public GrGLSLFragmentProcessor {
225 public: 225 public:
226 GLFP() : fHaveSetColor(false) {} 226 GLFP() : fHaveSetColor(false) {}
227 void emitCode(EmitArgs& args) override { 227 void emitCode(EmitArgs& args) override {
228 const char* colorName; 228 const char* colorName;
229 fColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder:: kFragment_Visibility, 229 fColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder:: kFragment_Visibility,
230 kVec4f_GrSLType, kDefa ult_GrSLPrecision, 230 kVec4f_GrSLType, kDefa ult_GrSLPrecision,
231 "Color", &colorName); 231 "Color", &colorName);
232 this->emitChild(0, colorName, args); 232 this->emitChild(0, colorName, args);
233 } 233 }
234 234
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 SeriesFragmentProcessor(const GrFragmentProcessor* children[], int cnt){ 290 SeriesFragmentProcessor(const GrFragmentProcessor* children[], int cnt){
291 SkASSERT(cnt > 1); 291 SkASSERT(cnt > 1);
292 this->initClassID<SeriesFragmentProcessor>(); 292 this->initClassID<SeriesFragmentProcessor>();
293 for (int i = 0; i < cnt; ++i) { 293 for (int i = 0; i < cnt; ++i) {
294 this->registerChildProcessor(children[i]); 294 this->registerChildProcessor(children[i]);
295 } 295 }
296 } 296 }
297 297
298 const char* name() const override { return "Series"; } 298 const char* name() const override { return "Series"; }
299 299
300 GrGLFragmentProcessor* onCreateGLInstance() const override { 300 GrGLSLFragmentProcessor* onCreateGLInstance() const override {
301 class GLFP : public GrGLFragmentProcessor { 301 class GLFP : public GrGLSLFragmentProcessor {
302 public: 302 public:
303 GLFP() {} 303 GLFP() {}
304 void emitCode(EmitArgs& args) override { 304 void emitCode(EmitArgs& args) override {
305 SkString input(args.fInputColor); 305 SkString input(args.fInputColor);
306 for (int i = 0; i < this->numChildProcessors() - 1; ++i) { 306 for (int i = 0; i < this->numChildProcessors() - 1; ++i) {
307 SkString temp; 307 SkString temp;
308 temp.printf("out%d", i); 308 temp.printf("out%d", i);
309 this->emitChild(i, input.c_str(), &temp, args); 309 this->emitChild(i, input.c_str(), &temp, args);
310 input = temp; 310 input = temp;
311 } 311 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 368 }
369 } 369 }
370 370
371 if (1 == cnt) { 371 if (1 == cnt) {
372 return SkRef(series[0]); 372 return SkRef(series[0]);
373 } else { 373 } else {
374 return new SeriesFragmentProcessor(series, cnt); 374 return new SeriesFragmentProcessor(series, cnt);
375 } 375 }
376 } 376 }
377 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