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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 fragBuilder->codeAppendf("%s = %s * %s;", | 154 fragBuilder->codeAppendf("%s = %s * %s;", |
155 args.fOutputPrimary, args.fInputCoverage, a
rgs.fInputColor); | 155 args.fOutputPrimary, args.fInputCoverage, a
rgs.fInputColor); |
156 } else { | 156 } else { |
157 fragBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInpu
tColor); | 157 fragBuilder->codeAppendf("%s = %s;", args.fOutputPrimary, args.fInpu
tColor); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb, | 161 void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb, |
162 GrGLSLXPFragmentBuilder* fragBuilder, | 162 GrGLSLXPFragmentBuilder* fragBuilder, |
163 const char* srcColor, | 163 const char* srcColor, |
| 164 const char* srcCoverage, |
164 const char* dstColor, | 165 const char* dstColor, |
165 const char* outColor, | 166 const char* outColor, |
| 167 const char* outColorSecondary, |
166 const GrXferProcessor& proc) override { | 168 const GrXferProcessor& proc) override { |
167 const CustomXP& xp = proc.cast<CustomXP>(); | 169 const CustomXP& xp = proc.cast<CustomXP>(); |
168 SkASSERT(!xp.hasHWBlendEquation()); | 170 SkASSERT(!xp.hasHWBlendEquation()); |
169 | 171 |
170 GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.mo
de()); | 172 GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.mo
de()); |
| 173 |
| 174 // Apply coverage. |
| 175 if (xp.dstReadUsesMixedSamples()) { |
| 176 if (srcCoverage) { |
| 177 fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage); |
| 178 fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCover
age); |
| 179 } else { |
| 180 fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary); |
| 181 } |
| 182 } else if (srcCoverage) { |
| 183 fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;", |
| 184 outColor, srcCoverage, outColor, srcCoverag
e, dstColor); |
| 185 } |
171 } | 186 } |
172 | 187 |
173 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over
ride {} | 188 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over
ride {} |
174 | 189 |
175 typedef GrGLSLXferProcessor INHERITED; | 190 typedef GrGLSLXferProcessor INHERITED; |
176 }; | 191 }; |
177 | 192 |
178 /////////////////////////////////////////////////////////////////////////////// | 193 /////////////////////////////////////////////////////////////////////////////// |
179 | 194 |
180 void CustomXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuild
er* b) const { | 195 void CustomXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuild
er* b) const { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 400 |
386 /////////////////////////////////////////////////////////////////////////////// | 401 /////////////////////////////////////////////////////////////////////////////// |
387 | 402 |
388 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { | 403 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { |
389 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 404 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
390 return nullptr; | 405 return nullptr; |
391 } else { | 406 } else { |
392 return new CustomXPFactory(mode); | 407 return new CustomXPFactory(mode); |
393 } | 408 } |
394 } | 409 } |
OLD | NEW |