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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 const char* outColorSecondary, | 219 const char* outColorSecondary, |
220 const GrXferProcessor& proc) override { | 220 const GrXferProcessor& proc) override { |
221 fKUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visib
ility, | 221 fKUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visib
ility, |
222 kVec4f_GrSLType, kDefault_GrSLPrecisi
on, | 222 kVec4f_GrSLType, kDefault_GrSLPrecisi
on, |
223 "k"); | 223 "k"); |
224 const char* kUni = uniformHandler->getUniformCStr(fKUni); | 224 const char* kUni = uniformHandler->getUniformCStr(fKUni); |
225 | 225 |
226 add_arithmetic_code(fragBuilder, srcColor, dstColor, outColor, kUni, fEn
forcePMColor); | 226 add_arithmetic_code(fragBuilder, srcColor, dstColor, outColor, kUni, fEn
forcePMColor); |
227 | 227 |
228 // Apply coverage. | 228 // Apply coverage. |
229 INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor,
outColor, | 229 if (proc.dstReadUsesMixedSamples()) { |
230 outColorSecondary, proc); | 230 if (srcCoverage) { |
| 231 fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage); |
| 232 fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCover
age); |
| 233 } else { |
| 234 fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary); |
| 235 } |
| 236 } else if (srcCoverage) { |
| 237 fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;", |
| 238 outColor, srcCoverage, outColor, srcCoverag
e, dstColor); |
| 239 } |
231 } | 240 } |
232 | 241 |
233 void onSetData(const GrGLSLProgramDataManager& pdman, | 242 void onSetData(const GrGLSLProgramDataManager& pdman, |
234 const GrXferProcessor& processor) override { | 243 const GrXferProcessor& processor) override { |
235 const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); | 244 const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); |
236 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); | 245 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); |
237 fEnforcePMColor = arith.enforcePMColor(); | 246 fEnforcePMColor = arith.enforcePMColor(); |
238 }; | 247 }; |
239 | 248 |
240 GrGLSLProgramDataManager::UniformHandle fKUni; | 249 GrGLSLProgramDataManager::UniformHandle fKUni; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 float k1 = d->fRandom->nextF(); | 312 float k1 = d->fRandom->nextF(); |
304 float k2 = d->fRandom->nextF(); | 313 float k2 = d->fRandom->nextF(); |
305 float k3 = d->fRandom->nextF(); | 314 float k3 = d->fRandom->nextF(); |
306 float k4 = d->fRandom->nextF(); | 315 float k4 = d->fRandom->nextF(); |
307 bool enforcePMColor = d->fRandom->nextBool(); | 316 bool enforcePMColor = d->fRandom->nextBool(); |
308 | 317 |
309 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); | 318 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); |
310 } | 319 } |
311 | 320 |
312 #endif | 321 #endif |
OLD | NEW |