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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 const char* dstColor, | 165 const char* dstColor, |
166 const char* outColor, | 166 const char* outColor, |
167 const char* outColorSecondary, | 167 const char* outColorSecondary, |
168 const GrXferProcessor& proc) override { | 168 const GrXferProcessor& proc) override { |
169 const CustomXP& xp = proc.cast<CustomXP>(); | 169 const CustomXP& xp = proc.cast<CustomXP>(); |
170 SkASSERT(!xp.hasHWBlendEquation()); | 170 SkASSERT(!xp.hasHWBlendEquation()); |
171 | 171 |
172 GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.mo
de()); | 172 GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.mo
de()); |
173 | 173 |
174 // Apply coverage. | 174 // Apply coverage. |
175 INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor,
outColor, | 175 if (xp.dstReadUsesMixedSamples()) { |
176 outColorSecondary, xp); | 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 } |
177 } | 186 } |
178 | 187 |
179 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over
ride {} | 188 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over
ride {} |
180 | 189 |
181 typedef GrGLSLXferProcessor INHERITED; | 190 typedef GrGLSLXferProcessor INHERITED; |
182 }; | 191 }; |
183 | 192 |
184 /////////////////////////////////////////////////////////////////////////////// | 193 /////////////////////////////////////////////////////////////////////////////// |
185 | 194 |
186 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... |
391 | 400 |
392 /////////////////////////////////////////////////////////////////////////////// | 401 /////////////////////////////////////////////////////////////////////////////// |
393 | 402 |
394 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { | 403 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { |
395 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 404 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
396 return nullptr; | 405 return nullptr; |
397 } else { | 406 } else { |
398 return new CustomXPFactory(mode); | 407 return new CustomXPFactory(mode); |
399 } | 408 } |
400 } | 409 } |
OLD | NEW |