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 #ifndef SkArithmeticMode_gpu_DEFINED | 8 #ifndef SkArithmeticMode_gpu_DEFINED |
9 #define SkArithmeticMode_gpu_DEFINED | 9 #define SkArithmeticMode_gpu_DEFINED |
10 | 10 |
11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
12 | 12 |
13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
14 | 14 |
15 #include "GrCoordTransform.h" | 15 #include "GrCoordTransform.h" |
| 16 #include "GrDrawTargetCaps.h" |
16 #include "GrFragmentProcessor.h" | 17 #include "GrFragmentProcessor.h" |
17 #include "GrTextureAccess.h" | 18 #include "GrTextureAccess.h" |
18 #include "GrTypes.h" | 19 #include "GrTypes.h" |
19 #include "GrXferProcessor.h" | 20 #include "GrXferProcessor.h" |
20 | 21 |
21 class GrInvariantOutput; | 22 class GrInvariantOutput; |
22 class GrProcOptInfo; | 23 class GrProcOptInfo; |
23 class GrTexture; | 24 class GrTexture; |
24 | 25 |
25 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 66 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
66 typedef GrFragmentProcessor INHERITED; | 67 typedef GrFragmentProcessor INHERITED; |
67 }; | 68 }; |
68 | 69 |
69 /////////////////////////////////////////////////////////////////////////////// | 70 /////////////////////////////////////////////////////////////////////////////// |
70 // Xfer Processor | 71 // Xfer Processor |
71 /////////////////////////////////////////////////////////////////////////////// | 72 /////////////////////////////////////////////////////////////////////////////// |
72 | 73 |
73 class GrArithmeticXP : public GrXferProcessor { | 74 class GrArithmeticXP : public GrXferProcessor { |
74 public: | 75 public: |
75 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool
enforcePMColor) { | 76 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool
enforcePMColor, |
76 return SkNEW_ARGS(GrArithmeticXP, (k1, k2, k3, k4, enforcePMColor)); | 77 const GrDeviceCoordTexture* dstCopy, |
| 78 bool willReadDstColor) { |
| 79 return SkNEW_ARGS(GrArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstCo
py, |
| 80 willReadDstColor)); |
77 } | 81 } |
78 | 82 |
79 ~GrArithmeticXP() SK_OVERRIDE {}; | 83 ~GrArithmeticXP() SK_OVERRIDE {}; |
80 | 84 |
81 const char* name() const SK_OVERRIDE { return "Arithmetic"; } | 85 const char* name() const SK_OVERRIDE { return "Arithmetic"; } |
82 | 86 |
83 void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const
SK_OVERRIDE; | |
84 | |
85 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; | 87 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; |
86 | 88 |
87 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } | 89 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } |
88 | 90 |
89 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | 91 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
90 const GrProcOptInfo& coveragePOI, | 92 const GrProcOptInfo& coveragePOI, |
91 bool doesStencilWrite, | 93 bool doesStencilWrite, |
92 GrColor* overrideColor, | 94 GrColor* overrideColor, |
93 const GrDrawTargetCaps& caps) SK_
OVERRIDE; | 95 const GrDrawTargetCaps& caps) SK_
OVERRIDE; |
94 | 96 |
95 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE { | 97 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE { |
96 blendInfo->fSrcBlend = kOne_GrBlendCoeff; | 98 blendInfo->fSrcBlend = kOne_GrBlendCoeff; |
97 blendInfo->fDstBlend = kZero_GrBlendCoeff; | 99 blendInfo->fDstBlend = kZero_GrBlendCoeff; |
98 blendInfo->fBlendConstant = 0; | 100 blendInfo->fBlendConstant = 0; |
99 } | 101 } |
100 | 102 |
101 float k1() const { return fK1; } | 103 float k1() const { return fK1; } |
102 float k2() const { return fK2; } | 104 float k2() const { return fK2; } |
103 float k3() const { return fK3; } | 105 float k3() const { return fK3; } |
104 float k4() const { return fK4; } | 106 float k4() const { return fK4; } |
105 bool enforcePMColor() const { return fEnforcePMColor; } | 107 bool enforcePMColor() const { return fEnforcePMColor; } |
106 | 108 |
107 private: | 109 private: |
108 GrArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor); | 110 GrArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor, |
| 111 const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); |
| 112 |
| 113 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con
st SK_OVERRIDE; |
109 | 114 |
110 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { | 115 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { |
111 const GrArithmeticXP& xp = xpBase.cast<GrArithmeticXP>(); | 116 const GrArithmeticXP& xp = xpBase.cast<GrArithmeticXP>(); |
112 if (fK1 != xp.fK1 || | 117 if (fK1 != xp.fK1 || |
113 fK2 != xp.fK2 || | 118 fK2 != xp.fK2 || |
114 fK3 != xp.fK3 || | 119 fK3 != xp.fK3 || |
115 fK4 != xp.fK4 || | 120 fK4 != xp.fK4 || |
116 fEnforcePMColor != xp.fEnforcePMColor) { | 121 fEnforcePMColor != xp.fEnforcePMColor) { |
117 return false; | 122 return false; |
118 } | 123 } |
119 return true; | 124 return true; |
120 } | 125 } |
121 | 126 |
122 float fK1, fK2, fK3, fK4; | 127 float fK1, fK2, fK3, fK4; |
123 bool fEnforcePMColor; | 128 bool fEnforcePMColor; |
124 | 129 |
125 typedef GrXferProcessor INHERITED; | 130 typedef GrXferProcessor INHERITED; |
126 }; | 131 }; |
127 | 132 |
128 /////////////////////////////////////////////////////////////////////////////// | 133 /////////////////////////////////////////////////////////////////////////////// |
129 | 134 |
130 class GrArithmeticXPFactory : public GrXPFactory { | 135 class GrArithmeticXPFactory : public GrXPFactory { |
131 public: | 136 public: |
132 static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enfo
rcePMColor) { | 137 static GrXPFactory* Create(float k1, float k2, float k3, float k4, bool enfo
rcePMColor) { |
133 return SkNEW_ARGS(GrArithmeticXPFactory, (k1, k2, k3, k4, enforcePMColor
)); | 138 return SkNEW_ARGS(GrArithmeticXPFactory, (k1, k2, k3, k4, enforcePMColor
)); |
134 } | 139 } |
135 | 140 |
136 GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI, | |
137 const GrProcOptInfo& coveragePOI) const
SK_OVERRIDE { | |
138 return GrArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor); | |
139 } | |
140 | |
141 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { | 141 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { |
142 return true; | 142 return true; |
143 } | 143 } |
144 | 144 |
145 bool canApplyCoverage(const GrProcOptInfo& colorPOI, | 145 bool canApplyCoverage(const GrProcOptInfo& colorPOI, |
146 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { | 146 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { |
147 return true; | 147 return true; |
148 } | 148 } |
149 | 149 |
150 bool canTweakAlphaForCoverage() const SK_OVERRIDE { | 150 bool canTweakAlphaForCoverage() const SK_OVERRIDE { |
151 return false; | 151 return false; |
152 } | 152 } |
153 | 153 |
154 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo&
coveragePOI, | 154 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo&
coveragePOI, |
155 GrXPFactory::InvariantOutput*) const SK_OVERRIDE; | 155 GrXPFactory::InvariantOutput*) const SK_OVERRIDE; |
156 | 156 |
157 bool willReadDst() const SK_OVERRIDE { return true; } | |
158 | |
159 private: | 157 private: |
160 GrArithmeticXPFactory(float k1, float k2, float k3, float k4, bool enforcePM
Color); | 158 GrArithmeticXPFactory(float k1, float k2, float k3, float k4, bool enforcePM
Color); |
161 | 159 |
| 160 GrXferProcessor* onCreateXferProcessor(const GrProcOptInfo& colorPOI, |
| 161 const GrProcOptInfo& coveragePOI, |
| 162 const GrDeviceCoordTexture* dstCopy)
const SK_OVERRIDE { |
| 163 return GrArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstCo
py, |
| 164 this->willReadDstColor()); |
| 165 } |
| 166 |
| 167 bool willReadDstColor() const SK_OVERRIDE { return true; } |
| 168 |
162 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { | 169 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { |
163 const GrArithmeticXPFactory& xpf = xpfBase.cast<GrArithmeticXPFactory>()
; | 170 const GrArithmeticXPFactory& xpf = xpfBase.cast<GrArithmeticXPFactory>()
; |
164 if (fK1 != xpf.fK1 || | 171 if (fK1 != xpf.fK1 || |
165 fK2 != xpf.fK2 || | 172 fK2 != xpf.fK2 || |
166 fK3 != xpf.fK3 || | 173 fK3 != xpf.fK3 || |
167 fK4 != xpf.fK4 || | 174 fK4 != xpf.fK4 || |
168 fEnforcePMColor != xpf.fEnforcePMColor) { | 175 fEnforcePMColor != xpf.fEnforcePMColor) { |
169 return false; | 176 return false; |
170 } | 177 } |
171 return true; | 178 return true; |
172 } | 179 } |
173 | 180 |
174 GR_DECLARE_XP_FACTORY_TEST; | 181 GR_DECLARE_XP_FACTORY_TEST; |
175 | 182 |
176 float fK1, fK2, fK3, fK4; | 183 float fK1, fK2, fK3, fK4; |
177 bool fEnforcePMColor; | 184 bool fEnforcePMColor; |
178 | 185 |
179 typedef GrXPFactory INHERITED; | 186 typedef GrXPFactory INHERITED; |
180 }; | 187 }; |
181 | 188 |
182 #endif | 189 #endif |
183 #endif | 190 #endif |
OLD | NEW |