OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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/GrPorterDuffXferProcessor.h" | 8 #include "effects/GrPorterDuffXferProcessor.h" |
9 | 9 |
10 #include "GrBlend.h" | 10 #include "GrBlend.h" |
11 #include "GrCaps.h" | 11 #include "GrCaps.h" |
12 #include "GrPipeline.h" | 12 #include "GrPipeline.h" |
13 #include "GrProcessor.h" | 13 #include "GrProcessor.h" |
14 #include "GrProcOptInfo.h" | 14 #include "GrProcOptInfo.h" |
15 #include "GrTypes.h" | 15 #include "GrTypes.h" |
16 #include "GrXferProcessor.h" | 16 #include "GrXferProcessor.h" |
17 #include "glsl/GrGLSLBlend.h" | 17 #include "glsl/GrGLSLBlend.h" |
18 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 18 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
19 #include "glsl/GrGLSLProgramDataManager.h" | 19 #include "glsl/GrGLSLProgramDataManager.h" |
20 #include "glsl/GrGLSLUniformHandler.h" | 20 #include "glsl/GrGLSLUniformHandler.h" |
21 #include "glsl/GrGLSLXferProcessor.h" | 21 #include "glsl/GrGLSLXferProcessor.h" |
22 | 22 |
bungeman-skia
2016/01/05 18:54:43
need <utility>
bungeman-skia
2016/01/05 18:59:41
Done.
| |
23 /** | 23 /** |
24 * Wraps the shader outputs and HW blend state that comprise a Porter Duff blend mode with coverage. | 24 * Wraps the shader outputs and HW blend state that comprise a Porter Duff blend mode with coverage. |
25 */ | 25 */ |
26 struct BlendFormula { | 26 struct BlendFormula { |
27 public: | 27 public: |
28 /** | 28 /** |
29 * Values the shader can write to primary and secondary outputs. These must all be modulated by | 29 * Values the shader can write to primary and secondary outputs. These must all be modulated by |
30 * coverage to support mixed samples. The XP will ignore the multiplies when not using coverage. | 30 * coverage to support mixed samples. The XP will ignore the multiplies when not using coverage. |
31 */ | 31 */ |
32 enum OutputType { | 32 enum OutputType { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 bool usesInputColor() const { return SkToBool(fProps & kUsesInputColor_Prope rty); } | 64 bool usesInputColor() const { return SkToBool(fProps & kUsesInputColor_Prope rty); } |
65 bool canTweakAlphaForCoverage() const { | 65 bool canTweakAlphaForCoverage() const { |
66 return SkToBool(fProps & kCanTweakAlphaForCoverage_Property); | 66 return SkToBool(fProps & kCanTweakAlphaForCoverage_Property); |
67 } | 67 } |
68 | 68 |
69 /** | 69 /** |
70 * Deduce the properties of a compile-time constant BlendFormula. | 70 * Deduce the properties of a compile-time constant BlendFormula. |
71 */ | 71 */ |
72 template<OutputType PrimaryOut, OutputType SecondaryOut, | 72 template<OutputType PrimaryOut, OutputType SecondaryOut, |
73 GrBlendEquation BlendEquation, GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff> | 73 GrBlendEquation BlendEquation, GrBlendCoeff SrcCoeff, GrBlendCoeff DstCoeff> |
74 struct get_properties : skstd::integral_constant<Properties, static_cast<Pro perties>( | 74 struct get_properties : std::integral_constant<Properties, static_cast<Prope rties>( |
75 | 75 |
76 (GR_BLEND_MODIFIES_DST(BlendEquation, SrcCoeff, DstCoeff) ? | 76 (GR_BLEND_MODIFIES_DST(BlendEquation, SrcCoeff, DstCoeff) ? |
77 kModifiesDst_Property : 0) | | 77 kModifiesDst_Property : 0) | |
78 | 78 |
79 (GR_BLEND_COEFFS_USE_DST_COLOR(SrcCoeff, DstCoeff) ? | 79 (GR_BLEND_COEFFS_USE_DST_COLOR(SrcCoeff, DstCoeff) ? |
80 kUsesDstColor_Property : 0) | | 80 kUsesDstColor_Property : 0) | |
81 | 81 |
82 ((PrimaryOut >= kModulate_OutputType && GR_BLEND_COEFFS_USE_SRC_COLOR(Sr cCoeff,DstCoeff)) || | 82 ((PrimaryOut >= kModulate_OutputType && GR_BLEND_COEFFS_USE_SRC_COLOR(Sr cCoeff,DstCoeff)) || |
83 (SecondaryOut >= kModulate_OutputType && GR_BLEND_COEFF_REFS_SRC2(DstCo eff)) ? | 83 (SecondaryOut >= kModulate_OutputType && GR_BLEND_COEFF_REFS_SRC2(DstCo eff)) ? |
84 kUsesInputColor_Property : 0) | // We assert later that SrcCoeff do esn't ref src2. | 84 kUsesInputColor_Property : 0) | // We assert later that SrcCoeff do esn't ref src2. |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
916 } | 916 } |
917 return get_lcd_blend_formula(optimizations.fCoveragePOI, | 917 return get_lcd_blend_formula(optimizations.fCoveragePOI, |
918 SkXfermode::kSrcOver_Mode).hasSecondaryOutp ut(); | 918 SkXfermode::kSrcOver_Mode).hasSecondaryOutp ut(); |
919 } | 919 } |
920 // We fallback on the shader XP when the blend formula would use dual source blending but we | 920 // We fallback on the shader XP when the blend formula would use dual source blending but we |
921 // don't have support for it. | 921 // don't have support for it. |
922 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI , | 922 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI , |
923 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco ndaryOutput(); | 923 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco ndaryOutput(); |
924 } | 924 } |
925 | 925 |
OLD | NEW |