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/GrXfermodeFragmentProcessor.h" | 8 #include "effects/GrXfermodeFragmentProcessor.h" |
9 | 9 |
10 #include "GrFragmentProcessor.h" | 10 #include "GrFragmentProcessor.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | 91 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
92 const ComposeTwoFragmentProcessor& cs = args.fFp.cast<ComposeTwoFragmentProc
essor>(); | 92 const ComposeTwoFragmentProcessor& cs = args.fFp.cast<ComposeTwoFragmentProc
essor>(); |
93 | 93 |
94 const char* inputColor = nullptr; | 94 const char* inputColor = nullptr; |
95 if (args.fInputColor) { | 95 if (args.fInputColor) { |
96 inputColor = "inputColor"; | 96 inputColor = "inputColor"; |
97 fragBuilder->codeAppendf("vec4 inputColor = vec4(%s.rgb, 1.0);", args.fI
nputColor); | 97 fragBuilder->codeAppendf("vec4 inputColor = vec4(%s.rgb, 1.0);", args.fI
nputColor); |
98 } | 98 } |
99 | 99 |
100 // declare outputColor and emit the code for each of the two children | 100 // declare outputColor and emit the code for each of the two children |
101 SkString srcColor("src"); | 101 SkString srcColor("xfer_src"); |
102 this->emitChild(0, inputColor, &srcColor, args); | 102 this->emitChild(0, inputColor, &srcColor, args); |
103 | 103 |
104 SkString dstColor("dst"); | 104 SkString dstColor("xfer_dst"); |
105 this->emitChild(1, inputColor, &dstColor, args); | 105 this->emitChild(1, inputColor, &dstColor, args); |
106 | 106 |
107 // emit blend code | 107 // emit blend code |
108 SkXfermode::Mode mode = cs.getMode(); | 108 SkXfermode::Mode mode = cs.getMode(); |
109 fragBuilder->codeAppendf("// Compose Xfer Mode: %s\n", SkXfermode::ModeName(
mode)); | 109 fragBuilder->codeAppendf("// Compose Xfer Mode: %s\n", SkXfermode::ModeName(
mode)); |
110 GrGLSLBlend::AppendMode(fragBuilder, | 110 GrGLSLBlend::AppendMode(fragBuilder, |
111 srcColor.c_str(), | 111 srcColor.c_str(), |
112 dstColor.c_str(), | 112 dstColor.c_str(), |
113 args.fOutputColor, | 113 args.fOutputColor, |
114 mode); | 114 mode); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK, | 303 return GrConstColorProcessor::Make(GrColor_TRANSPARENT_BLACK, |
304 GrConstColorProcessor::kIgnore_
InputMode); | 304 GrConstColorProcessor::kIgnore_
InputMode); |
305 case SkXfermode::kDst_Mode: | 305 case SkXfermode::kDst_Mode: |
306 return nullptr; | 306 return nullptr; |
307 default: | 307 default: |
308 return sk_sp<GrFragmentProcessor>( | 308 return sk_sp<GrFragmentProcessor>( |
309 new ComposeOneFragmentProcessor(src, mode, | 309 new ComposeOneFragmentProcessor(src, mode, |
310 ComposeOneFragmentProcessor::kSr
c_Child)); | 310 ComposeOneFragmentProcessor::kSr
c_Child)); |
311 } | 311 } |
312 } | 312 } |
OLD | NEW |