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" |
11 #include "GrContext.h" | 11 #include "GrContext.h" |
12 #include "GrFragmentProcessor.h" | 12 #include "GrFragmentProcessor.h" |
13 #include "GrInvariantOutput.h" | 13 #include "GrInvariantOutput.h" |
14 #include "GrPipeline.h" | 14 #include "GrPipeline.h" |
15 #include "GrProcessor.h" | 15 #include "GrProcessor.h" |
16 #include "GrTexture.h" | 16 #include "GrTexture.h" |
17 #include "GrTextureAccess.h" | 17 #include "GrTextureAccess.h" |
18 #include "SkXfermode.h" | 18 #include "SkXfermode.h" |
19 #include "glsl/GrGLSLBlend.h" | 19 #include "glsl/GrGLSLBlend.h" |
20 #include "glsl/GrGLSLCaps.h" | 20 #include "glsl/GrGLSLCaps.h" |
21 #include "glsl/GrGLSLFragmentProcessor.h" | 21 #include "glsl/GrGLSLFragmentProcessor.h" |
22 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 22 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
23 #include "glsl/GrGLSLProgramBuilder.h" | |
24 #include "glsl/GrGLSLProgramDataManager.h" | 23 #include "glsl/GrGLSLProgramDataManager.h" |
| 24 #include "glsl/GrGLSLUniformHandler.h" |
25 #include "glsl/GrGLSLXferProcessor.h" | 25 #include "glsl/GrGLSLXferProcessor.h" |
26 | 26 |
27 bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) { | 27 bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) { |
28 return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode; | 28 return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode; |
29 } | 29 } |
30 | 30 |
31 /////////////////////////////////////////////////////////////////////////////// | 31 /////////////////////////////////////////////////////////////////////////////// |
32 // Static helpers | 32 // Static helpers |
33 /////////////////////////////////////////////////////////////////////////////// | 33 /////////////////////////////////////////////////////////////////////////////// |
34 | 34 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // Apply coverage by multiplying it into the src color before blending.
Mixed samples will | 151 // Apply coverage by multiplying it into the src color before blending.
Mixed samples will |
152 // "just work" automatically. (See onGetOptimizations()) | 152 // "just work" automatically. (See onGetOptimizations()) |
153 if (args.fInputCoverage) { | 153 if (args.fInputCoverage) { |
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(GrGLSLXPFragmentBuilder* fragBuilder, |
162 GrGLSLXPFragmentBuilder* fragBuilder, | 162 GrGLSLUniformHandler* uniformHandler, |
163 const char* srcColor, | 163 const char* srcColor, |
164 const char* srcCoverage, | 164 const char* srcCoverage, |
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()); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 400 |
401 /////////////////////////////////////////////////////////////////////////////// | 401 /////////////////////////////////////////////////////////////////////////////// |
402 | 402 |
403 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { | 403 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { |
404 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 404 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
405 return nullptr; | 405 return nullptr; |
406 } else { | 406 } else { |
407 return new CustomXPFactory(mode); | 407 return new CustomXPFactory(mode); |
408 } | 408 } |
409 } | 409 } |
OLD | NEW |