OLD | NEW |
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 Loading... |
53 } | 53 } |
54 | 54 |
55 class GLArithmeticFP : public GrGLFragmentProcessor { | 55 class GLArithmeticFP : public GrGLFragmentProcessor { |
56 public: | 56 public: |
57 GLArithmeticFP(const GrProcessor&) : fEnforcePMColor(true) {} | 57 GLArithmeticFP(const GrProcessor&) : fEnforcePMColor(true) {} |
58 | 58 |
59 ~GLArithmeticFP() override {} | 59 ~GLArithmeticFP() override {} |
60 | 60 |
61 void emitCode(EmitArgs& args) override { | 61 void emitCode(EmitArgs& args) override { |
62 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder
(); | 62 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder
(); |
63 fsBuilder->codeAppend("vec4 _dstColor;"); | 63 SkString dstColor("dstColor"); |
64 this->emitChild(0, nullptr, "_dstColor", args); | 64 this->emitChild(0, nullptr, &dstColor, args); |
65 | 65 |
66 fKUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibili
ty, | 66 fKUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_Visibili
ty, |
67 kVec4f_GrSLType, kDefault_GrSLPrecisio
n, | 67 kVec4f_GrSLType, kDefault_GrSLPrecisio
n, |
68 "k"); | 68 "k"); |
69 const char* kUni = args.fBuilder->getUniformCStr(fKUni); | 69 const char* kUni = args.fBuilder->getUniformCStr(fKUni); |
70 | 70 |
71 add_arithmetic_code(fsBuilder, args.fInputColor, "_dstColor", args.fOutp
utColor, kUni, | 71 add_arithmetic_code(fsBuilder, args.fInputColor, dstColor.c_str(), args.
fOutputColor, kUni, |
72 fEnforcePMColor); | 72 fEnforcePMColor); |
73 } | 73 } |
74 | 74 |
75 static void GenKey(const GrProcessor& proc, const GrGLSLCaps& caps, GrProces
sorKeyBuilder* b) { | 75 static void GenKey(const GrProcessor& proc, const GrGLSLCaps& caps, GrProces
sorKeyBuilder* b) { |
76 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>(); | 76 const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>(); |
77 uint32_t key = arith.enforcePMColor() ? 1 : 0; | 77 uint32_t key = arith.enforcePMColor() ? 1 : 0; |
78 b->add32(key); | 78 b->add32(key); |
79 } | 79 } |
80 | 80 |
81 protected: | 81 protected: |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 float k1 = d->fRandom->nextF(); | 291 float k1 = d->fRandom->nextF(); |
292 float k2 = d->fRandom->nextF(); | 292 float k2 = d->fRandom->nextF(); |
293 float k3 = d->fRandom->nextF(); | 293 float k3 = d->fRandom->nextF(); |
294 float k4 = d->fRandom->nextF(); | 294 float k4 = d->fRandom->nextF(); |
295 bool enforcePMColor = d->fRandom->nextBool(); | 295 bool enforcePMColor = d->fRandom->nextBool(); |
296 | 296 |
297 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); | 297 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); |
298 } | 298 } |
299 | 299 |
300 #endif | 300 #endif |
OLD | NEW |