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

Side by Side Diff: src/gpu/glsl/GrGLSLXferProcessor.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 | « src/gpu/glsl/GrGLSLXferProcessor.h ('k') | no next file » | 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 2014 Google Inc. 2 * Copyright 2014 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 "glsl/GrGLSLXferProcessor.h" 8 #include "glsl/GrGLSLXferProcessor.h"
9 9
10 #include "GrXferProcessor.h" 10 #include "GrXferProcessor.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 fragBuilder->codeAppendf("vec4 %s = ", dstColor); 58 fragBuilder->codeAppendf("vec4 %s = ", dstColor);
59 fragBuilder->appendTextureLookup(args.fSamplers[0], "_dstTexCoord", kVec 2f_GrSLType); 59 fragBuilder->appendTextureLookup(args.fSamplers[0], "_dstTexCoord", kVec 2f_GrSLType);
60 fragBuilder->codeAppend(";"); 60 fragBuilder->codeAppend(";");
61 } 61 }
62 62
63 this->emitBlendCodeForDstRead(args.fPB, 63 this->emitBlendCodeForDstRead(args.fPB,
64 fragBuilder, 64 fragBuilder,
65 args.fInputColor, 65 args.fInputColor,
66 args.fInputCoverage,
66 dstColor, 67 dstColor,
67 args.fOutputPrimary, 68 args.fOutputPrimary,
69 args.fOutputSecondary,
68 args.fXP); 70 args.fXP);
69
70 // Apply coverage.
71 if (args.fXP.dstReadUsesMixedSamples()) {
72 if (args.fInputCoverage) {
73 fragBuilder->codeAppendf("%s *= %s;", args.fOutputPrimary, args.fInp utCoverage);
74 fragBuilder->codeAppendf("%s = %s;", args.fOutputSecondary, args.fIn putCoverage);
75 } else {
76 fragBuilder->codeAppendf("%s = vec4(1.0);", args.fOutputSecondary);
77 }
78 } else if (args.fInputCoverage) {
79 fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
80 args.fOutputPrimary, args.fInputCoverage,
81 args.fOutputPrimary, args.fInputCoverage, dstCo lor);
82 }
83 } 71 }
84 72
85 void GrGLSLXferProcessor::setData(const GrGLSLProgramDataManager& pdm, const GrX ferProcessor& xp) { 73 void GrGLSLXferProcessor::setData(const GrGLSLProgramDataManager& pdm, const GrX ferProcessor& xp) {
86 if (xp.getDstTexture()) { 74 if (xp.getDstTexture()) {
87 if (fDstTopLeftUni.isValid()) { 75 if (fDstTopLeftUni.isValid()) {
88 pdm.set2f(fDstTopLeftUni, static_cast<float>(xp.dstTextureOffset().f X), 76 pdm.set2f(fDstTopLeftUni, static_cast<float>(xp.dstTextureOffset().f X),
89 static_cast<float>(xp.dstTextureOffset().fY)); 77 static_cast<float>(xp.dstTextureOffset().fY));
90 pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(), 78 pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(),
91 1.f / xp.getDstTexture()->height()); 79 1.f / xp.getDstTexture()->height());
92 } else { 80 } else {
93 SkASSERT(!fDstScaleUni.isValid()); 81 SkASSERT(!fDstScaleUni.isValid());
94 } 82 }
95 } else { 83 } else {
96 SkASSERT(!fDstTopLeftUni.isValid()); 84 SkASSERT(!fDstTopLeftUni.isValid());
97 SkASSERT(!fDstScaleUni.isValid()); 85 SkASSERT(!fDstScaleUni.isValid());
98 } 86 }
99 this->onSetData(pdm, xp); 87 this->onSetData(pdm, xp);
100 } 88 }
101 89
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLXferProcessor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698