1 | /* |
---|---|
2 | * Copyright 2015 Google Inc. |
3 | * |
4 | * Use of this source code is governed by a BSD-style license that can be |
5 | * found in the LICENSE file. |
6 | */ |
7 | |
8 | #include "src/gpu/glsl/GrGLSLBlend.h" |
9 | #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" |
10 | #include "src/gpu/glsl/GrGLSLProgramBuilder.h" |
11 | |
12 | namespace GrGLSLBlend { |
13 | |
14 | const char* BlendFuncName(SkBlendMode mode) { |
15 | switch (mode) { |
16 | case SkBlendMode::kClear: return "blend_clear"; |
17 | case SkBlendMode::kSrc: return "blend_src"; |
18 | case SkBlendMode::kDst: return "blend_dst"; |
19 | case SkBlendMode::kSrcOver: return "blend_src_over"; |
20 | case SkBlendMode::kDstOver: return "blend_dst_over"; |
21 | case SkBlendMode::kSrcIn: return "blend_src_in"; |
22 | case SkBlendMode::kDstIn: return "blend_dst_in"; |
23 | case SkBlendMode::kSrcOut: return "blend_src_out"; |
24 | case SkBlendMode::kDstOut: return "blend_dst_out"; |
25 | case SkBlendMode::kSrcATop: return "blend_src_atop"; |
26 | case SkBlendMode::kDstATop: return "blend_dst_atop"; |
27 | case SkBlendMode::kXor: return "blend_xor"; |
28 | case SkBlendMode::kPlus: return "blend_plus"; |
29 | case SkBlendMode::kModulate: return "blend_modulate"; |
30 | case SkBlendMode::kScreen: return "blend_screen"; |
31 | case SkBlendMode::kOverlay: return "blend_overlay"; |
32 | case SkBlendMode::kDarken: return "blend_darken"; |
33 | case SkBlendMode::kLighten: return "blend_lighten"; |
34 | case SkBlendMode::kColorDodge: return "blend_color_dodge"; |
35 | case SkBlendMode::kColorBurn: return "blend_color_burn"; |
36 | case SkBlendMode::kHardLight: return "blend_hard_light"; |
37 | case SkBlendMode::kSoftLight: return "blend_soft_light"; |
38 | case SkBlendMode::kDifference: return "blend_difference"; |
39 | case SkBlendMode::kExclusion: return "blend_exclusion"; |
40 | case SkBlendMode::kMultiply: return "blend_multiply"; |
41 | case SkBlendMode::kHue: return "blend_hue"; |
42 | case SkBlendMode::kSaturation: return "blend_saturation"; |
43 | case SkBlendMode::kColor: return "blend_color"; |
44 | case SkBlendMode::kLuminosity: return "blend_luminosity"; |
45 | } |
46 | SkUNREACHABLE; |
47 | } |
48 | |
49 | void AppendMode(GrGLSLFragmentBuilder* fsBuilder, |
50 | const char* srcColor, |
51 | const char* dstColor, |
52 | const char* outColor, |
53 | SkBlendMode mode) { |
54 | fsBuilder->codeAppendf("%s = %s(%s, %s);", outColor, BlendFuncName(mode), srcColor, dstColor); |
55 | } |
56 | |
57 | } // namespace GrGLSLBlend |
58 |