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 #include <utility> |
22 | 23 |
23 /** | 24 /** |
24 * Wraps the shader outputs and HW blend state that comprise a Porter Duff blend
mode with coverage. | 25 * Wraps the shader outputs and HW blend state that comprise a Porter Duff blend
mode with coverage. |
25 */ | 26 */ |
26 struct BlendFormula { | 27 struct BlendFormula { |
27 public: | 28 public: |
28 /** | 29 /** |
29 * Values the shader can write to primary and secondary outputs. These must
all be modulated by | 30 * 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. | 31 * coverage to support mixed samples. The XP will ignore the multiplies when
not using coverage. |
31 */ | 32 */ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 bool usesInputColor() const { return SkToBool(fProps & kUsesInputColor_Prope
rty); } | 65 bool usesInputColor() const { return SkToBool(fProps & kUsesInputColor_Prope
rty); } |
65 bool canTweakAlphaForCoverage() const { | 66 bool canTweakAlphaForCoverage() const { |
66 return SkToBool(fProps & kCanTweakAlphaForCoverage_Property); | 67 return SkToBool(fProps & kCanTweakAlphaForCoverage_Property); |
67 } | 68 } |
68 | 69 |
69 /** | 70 /** |
70 * Deduce the properties of a compile-time constant BlendFormula. | 71 * Deduce the properties of a compile-time constant BlendFormula. |
71 */ | 72 */ |
72 template<OutputType PrimaryOut, OutputType SecondaryOut, | 73 template<OutputType PrimaryOut, OutputType SecondaryOut, |
73 GrBlendEquation BlendEquation, GrBlendCoeff SrcCoeff, GrBlendCoeff
DstCoeff> | 74 GrBlendEquation BlendEquation, GrBlendCoeff SrcCoeff, GrBlendCoeff
DstCoeff> |
74 struct get_properties : skstd::integral_constant<Properties, static_cast<Pro
perties>( | 75 struct get_properties : std::integral_constant<Properties, static_cast<Prope
rties>( |
75 | 76 |
76 (GR_BLEND_MODIFIES_DST(BlendEquation, SrcCoeff, DstCoeff) ? | 77 (GR_BLEND_MODIFIES_DST(BlendEquation, SrcCoeff, DstCoeff) ? |
77 kModifiesDst_Property : 0) | | 78 kModifiesDst_Property : 0) | |
78 | 79 |
79 (GR_BLEND_COEFFS_USE_DST_COLOR(SrcCoeff, DstCoeff) ? | 80 (GR_BLEND_COEFFS_USE_DST_COLOR(SrcCoeff, DstCoeff) ? |
80 kUsesDstColor_Property : 0) | | 81 kUsesDstColor_Property : 0) | |
81 | 82 |
82 ((PrimaryOut >= kModulate_OutputType && GR_BLEND_COEFFS_USE_SRC_COLOR(Sr
cCoeff,DstCoeff)) || | 83 ((PrimaryOut >= kModulate_OutputType && GR_BLEND_COEFFS_USE_SRC_COLOR(Sr
cCoeff,DstCoeff)) || |
83 (SecondaryOut >= kModulate_OutputType && GR_BLEND_COEFF_REFS_SRC2(DstCo
eff)) ? | 84 (SecondaryOut >= kModulate_OutputType && GR_BLEND_COEFF_REFS_SRC2(DstCo
eff)) ? |
84 kUsesInputColor_Property : 0) | // We assert later that SrcCoeff do
esn't ref src2. | 85 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 } | 917 } |
917 return get_lcd_blend_formula(optimizations.fCoveragePOI, | 918 return get_lcd_blend_formula(optimizations.fCoveragePOI, |
918 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); | 919 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); |
919 } | 920 } |
920 // We fallback on the shader XP when the blend formula would use dual source
blending but we | 921 // We fallback on the shader XP when the blend formula would use dual source
blending but we |
921 // don't have support for it. | 922 // don't have support for it. |
922 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, | 923 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, |
923 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco
ndaryOutput(); | 924 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco
ndaryOutput(); |
924 } | 925 } |
925 | 926 |
OLD | NEW |