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

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

Issue 1488213002: Add in shader blending for CoverageSetOp XP (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebased Created 5 years 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 | « no previous file | src/gpu/effects/GrCoverageSetOpXP.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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 GrProcessorKeyBuilder* b) { 206 GrProcessorKeyBuilder* b) {
207 const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); 207 const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
208 uint32_t key = arith.enforcePMColor() ? 1 : 0; 208 uint32_t key = arith.enforcePMColor() ? 1 : 0;
209 b->add32(key); 209 b->add32(key);
210 } 210 }
211 211
212 private: 212 private:
213 void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb, 213 void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb,
214 GrGLSLXPFragmentBuilder* fragBuilder, 214 GrGLSLXPFragmentBuilder* fragBuilder,
215 const char* srcColor, 215 const char* srcColor,
216 const char* srcCoverage,
216 const char* dstColor, 217 const char* dstColor,
217 const char* outColor, 218 const char* outColor,
219 const char* outColorSecondary,
218 const GrXferProcessor& proc) override { 220 const GrXferProcessor& proc) override {
219 fKUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility, 221 fKUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
220 kVec4f_GrSLType, kDefault_GrSLPrecision, 222 kVec4f_GrSLType, kDefault_GrSLPrecision,
221 "k"); 223 "k");
222 const char* kUni = pb->getUniformCStr(fKUni); 224 const char* kUni = pb->getUniformCStr(fKUni);
223 225
224 add_arithmetic_code(fragBuilder, srcColor, dstColor, outColor, kUni, fEn forcePMColor); 226 add_arithmetic_code(fragBuilder, srcColor, dstColor, outColor, kUni, fEn forcePMColor);
227
228 // Apply coverage.
229 if (proc.dstReadUsesMixedSamples()) {
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 }
225 } 240 }
226 241
227 void onSetData(const GrGLSLProgramDataManager& pdman, 242 void onSetData(const GrGLSLProgramDataManager& pdman,
228 const GrXferProcessor& processor) override { 243 const GrXferProcessor& processor) override {
229 const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); 244 const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
230 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); 245 pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
231 fEnforcePMColor = arith.enforcePMColor(); 246 fEnforcePMColor = arith.enforcePMColor();
232 }; 247 };
233 248
234 GrGLSLProgramDataManager::UniformHandle fKUni; 249 GrGLSLProgramDataManager::UniformHandle fKUni;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 float k1 = d->fRandom->nextF(); 312 float k1 = d->fRandom->nextF();
298 float k2 = d->fRandom->nextF(); 313 float k2 = d->fRandom->nextF();
299 float k3 = d->fRandom->nextF(); 314 float k3 = d->fRandom->nextF();
300 float k4 = d->fRandom->nextF(); 315 float k4 = d->fRandom->nextF();
301 bool enforcePMColor = d->fRandom->nextBool(); 316 bool enforcePMColor = d->fRandom->nextBool();
302 317
303 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); 318 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor);
304 } 319 }
305 320
306 #endif 321 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/effects/GrCoverageSetOpXP.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698