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

Side by Side Diff: src/effects/SkArithmeticMode_gpu.cpp

Issue 1251173002: Added GrGLFragmentProcessor::EmitArgs struct for use with emitCode() (Closed) Base URL: https://skia.googlesource.com/skia@composeshader_gpu
Patch Set: Created 5 years, 5 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/effects/SkAlphaThresholdFilter.cpp ('k') | src/effects/SkBlurMaskFilter.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 2015 Google Inc. 2 * Copyright 2015 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 "SkArithmeticMode_gpu.h" 8 #include "SkArithmeticMode_gpu.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 class GLArithmeticFP : public GrGLFragmentProcessor { 55 class GLArithmeticFP : public GrGLFragmentProcessor {
56 public: 56 public:
57 GLArithmeticFP(const GrProcessor&) 57 GLArithmeticFP(const GrProcessor&)
58 : fEnforcePMColor(true) { 58 : fEnforcePMColor(true) {
59 } 59 }
60 60
61 ~GLArithmeticFP() override {} 61 ~GLArithmeticFP() override {}
62 62
63 void emitCode(GrGLFPBuilder* builder, 63 void emitCode(EmitArgs& args) override {
64 const GrFragmentProcessor& fp, 64 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder ();
65 const char* outputColor,
66 const char* inputColor,
67 const TransformedCoordsArray& coords,
68 const TextureSamplerArray& samplers) override {
69 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
70 fsBuilder->codeAppend("vec4 bgColor = "); 65 fsBuilder->codeAppend("vec4 bgColor = ");
71 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0] .getType()); 66 fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_str( ),
67 args.fCoords[0].getType());
72 fsBuilder->codeAppendf(";"); 68 fsBuilder->codeAppendf(";");
73 const char* dstColor = "bgColor"; 69 const char* dstColor = "bgColor";
74 70
75 fKUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, 71 fKUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibili ty,
76 kVec4f_GrSLType, kDefault_GrSLPrecision, 72 kVec4f_GrSLType, kDefault_GrSLPrecision,
77 "k"); 73 "k");
78 const char* kUni = builder->getUniformCStr(fKUni); 74 const char* kUni = args.fBuilder->getUniformCStr(fKUni);
79 75
80 add_arithmetic_code(fsBuilder, inputColor, dstColor, outputColor, kUni, fEnforcePMColor); 76 add_arithmetic_code(fsBuilder, args.fInputColor, dstColor, args.fOutputC olor, kUni,
77 fEnforcePMColor);
81 } 78 }
82 79
83 void setData(const GrGLProgramDataManager& pdman, const GrProcessor& proc) o verride { 80 void setData(const GrGLProgramDataManager& pdman, const GrProcessor& proc) o verride {
84 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>(); 81 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>();
85 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); 82 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
86 fEnforcePMColor = arith.enforcePMColor(); 83 fEnforcePMColor = arith.enforcePMColor();
87 } 84 }
88 85
89 static void GenKey(const GrProcessor& proc, const GrGLSLCaps& caps, GrProces sorKeyBuilder* b) { 86 static void GenKey(const GrProcessor& proc, const GrGLSLCaps& caps, GrProces sorKeyBuilder* b) {
90 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>(); 87 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 float k1 = d->fRandom->nextF(); 302 float k1 = d->fRandom->nextF();
306 float k2 = d->fRandom->nextF(); 303 float k2 = d->fRandom->nextF();
307 float k3 = d->fRandom->nextF(); 304 float k3 = d->fRandom->nextF();
308 float k4 = d->fRandom->nextF(); 305 float k4 = d->fRandom->nextF();
309 bool enforcePMColor = d->fRandom->nextBool(); 306 bool enforcePMColor = d->fRandom->nextBool();
310 307
311 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); 308 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor);
312 } 309 }
313 310
314 #endif 311 #endif
OLDNEW
« no previous file with comments | « src/effects/SkAlphaThresholdFilter.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698