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 "effects/GrCustomXfermode.h" | 8 #include "effects/GrCustomXfermode.h" |
9 | 9 |
10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 key |= xp.mode() << 3; | 139 key |= xp.mode() << 3; |
140 } | 140 } |
141 b->add32(key); | 141 b->add32(key); |
142 } | 142 } |
143 | 143 |
144 private: | 144 private: |
145 void emitOutputsForBlendState(const EmitArgs& args) override { | 145 void emitOutputsForBlendState(const EmitArgs& args) override { |
146 const CustomXP& xp = args.fXP.cast<CustomXP>(); | 146 const CustomXP& xp = args.fXP.cast<CustomXP>(); |
147 SkASSERT(xp.hasHWBlendEquation()); | 147 SkASSERT(xp.hasHWBlendEquation()); |
148 | 148 |
149 GrGLSLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(
); | 149 GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder; |
150 fsBuilder->enableAdvancedBlendEquationIfNeeded(xp.hwBlendEquation()); | 150 fragBuilder->enableAdvancedBlendEquationIfNeeded(xp.hwBlendEquation()); |
151 | 151 |
152 // Apply coverage by multiplying it into the src color before blending.
Mixed samples will | 152 // Apply coverage by multiplying it into the src color before blending.
Mixed samples will |
153 // "just work" automatically. (See onGetOptimizations()) | 153 // "just work" automatically. (See onGetOptimizations()) |
154 if (xp.readsCoverage()) { | 154 if (xp.readsCoverage()) { |
155 fsBuilder->codeAppendf("%s = %s * %s;", | 155 fragBuilder->codeAppendf("%s = %s * %s;", |
156 args.fOutputPrimary, args.fInputCoverage, arg
s.fInputColor); | 156 args.fOutputPrimary, args.fInputCoverage, a
rgs.fInputColor); |
157 } else { | 157 } else { |
158 fsBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInputC
olor); | 158 fragBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInpu
tColor); |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb, const char* srcColor, cons
t char* dstColor, | 162 void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb, |
163 const char* outColor, const GrXferProcessor& pr
oc) override { | 163 GrGLSLXPFragmentBuilder* fragBuilder, |
| 164 const char* srcColor, |
| 165 const char* dstColor, |
| 166 const char* outColor, |
| 167 const GrXferProcessor& proc) override { |
164 const CustomXP& xp = proc.cast<CustomXP>(); | 168 const CustomXP& xp = proc.cast<CustomXP>(); |
165 SkASSERT(!xp.hasHWBlendEquation()); | 169 SkASSERT(!xp.hasHWBlendEquation()); |
166 | 170 |
167 GrGLSLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder(); | 171 GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.mo
de()); |
168 GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.mode
()); | |
169 } | 172 } |
170 | 173 |
171 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over
ride {} | 174 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over
ride {} |
172 | 175 |
173 typedef GrGLSLXferProcessor INHERITED; | 176 typedef GrGLSLXferProcessor INHERITED; |
174 }; | 177 }; |
175 | 178 |
176 /////////////////////////////////////////////////////////////////////////////// | 179 /////////////////////////////////////////////////////////////////////////////// |
177 | 180 |
178 void CustomXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuild
er* b) const { | 181 void CustomXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuild
er* b) const { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 395 |
393 /////////////////////////////////////////////////////////////////////////////// | 396 /////////////////////////////////////////////////////////////////////////////// |
394 | 397 |
395 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { | 398 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { |
396 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 399 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
397 return nullptr; | 400 return nullptr; |
398 } else { | 401 } else { |
399 return new CustomXPFactory(mode); | 402 return new CustomXPFactory(mode); |
400 } | 403 } |
401 } | 404 } |
OLD | NEW |