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 "SkArithmeticMode_gpu.h" | 8 #include "SkArithmeticMode_gpu.h" |
9 | 9 |
10 #if SK_SUPPORT_GPU | 10 #if SK_SUPPORT_GPU |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); | 155 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrArithmeticFP); |
156 | 156 |
157 /////////////////////////////////////////////////////////////////////////////// | 157 /////////////////////////////////////////////////////////////////////////////// |
158 // Xfer Processor | 158 // Xfer Processor |
159 /////////////////////////////////////////////////////////////////////////////// | 159 /////////////////////////////////////////////////////////////////////////////// |
160 | 160 |
161 class ArithmeticXP : public GrXferProcessor { | 161 class ArithmeticXP : public GrXferProcessor { |
162 public: | 162 public: |
163 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool
enforcePMColor, | 163 static GrXferProcessor* Create(float k1, float k2, float k3, float k4, bool
enforcePMColor, |
164 const GrDeviceCoordTexture* dstCopy, | 164 const DstTexture* dstTexture, bool willReadDs
tColor) { |
165 bool willReadDstColor) { | 165 return SkNEW_ARGS(ArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstText
ure, |
166 return SkNEW_ARGS(ArithmeticXP, (k1, k2, k3, k4, enforcePMColor, dstCopy
, | |
167 willReadDstColor)); | 166 willReadDstColor)); |
168 } | 167 } |
169 | 168 |
170 ~ArithmeticXP() override {}; | 169 ~ArithmeticXP() override {}; |
171 | 170 |
172 const char* name() const override { return "Arithmetic"; } | 171 const char* name() const override { return "Arithmetic"; } |
173 | 172 |
174 GrGLXferProcessor* createGLInstance() const override; | 173 GrGLXferProcessor* createGLInstance() const override; |
175 | 174 |
176 bool hasSecondaryOutput() const override { return false; } | 175 bool hasSecondaryOutput() const override { return false; } |
177 | 176 |
178 float k1() const { return fK1; } | 177 float k1() const { return fK1; } |
179 float k2() const { return fK2; } | 178 float k2() const { return fK2; } |
180 float k3() const { return fK3; } | 179 float k3() const { return fK3; } |
181 float k4() const { return fK4; } | 180 float k4() const { return fK4; } |
182 bool enforcePMColor() const { return fEnforcePMColor; } | 181 bool enforcePMColor() const { return fEnforcePMColor; } |
183 | 182 |
184 private: | 183 private: |
185 ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor, | 184 ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor, |
186 const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); | 185 const DstTexture*, bool willReadDstColor); |
187 | 186 |
188 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 187 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
189 const GrProcOptInfo& coveragePO
I, | 188 const GrProcOptInfo& coveragePO
I, |
190 bool doesStencilWrite, | 189 bool doesStencilWrite, |
191 GrColor* overrideColor, | 190 GrColor* overrideColor, |
192 const GrDrawTargetCaps& caps) o
verride; | 191 const GrDrawTargetCaps& caps) o
verride; |
193 | 192 |
194 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; | 193 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; |
195 | 194 |
196 bool onIsEqual(const GrXferProcessor& xpBase) const override { | 195 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 255 |
257 GrGLProgramDataManager::UniformHandle fKUni; | 256 GrGLProgramDataManager::UniformHandle fKUni; |
258 bool fEnforcePMColor; | 257 bool fEnforcePMColor; |
259 | 258 |
260 typedef GrGLXferProcessor INHERITED; | 259 typedef GrGLXferProcessor INHERITED; |
261 }; | 260 }; |
262 | 261 |
263 /////////////////////////////////////////////////////////////////////////////// | 262 /////////////////////////////////////////////////////////////////////////////// |
264 | 263 |
265 ArithmeticXP::ArithmeticXP(float k1, float k2, float k3, float k4, bool enforceP
MColor, | 264 ArithmeticXP::ArithmeticXP(float k1, float k2, float k3, float k4, bool enforceP
MColor, |
266 const GrDeviceCoordTexture* dstCopy, bool willReadDst
Color) | 265 const DstTexture* dstTexture, bool willReadDstColor) |
267 : INHERITED(dstCopy, willReadDstColor) | 266 : INHERITED(dstTexture, willReadDstColor) |
268 , fK1(k1) | 267 , fK1(k1) |
269 , fK2(k2) | 268 , fK2(k2) |
270 , fK3(k3) | 269 , fK3(k3) |
271 , fK4(k4) | 270 , fK4(k4) |
272 , fEnforcePMColor(enforcePMColor) { | 271 , fEnforcePMColor(enforcePMColor) { |
273 this->initClassID<ArithmeticXP>(); | 272 this->initClassID<ArithmeticXP>(); |
274 } | 273 } |
275 | 274 |
276 void ArithmeticXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui
lder* b) const { | 275 void ArithmeticXP::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBui
lder* b) const { |
277 GLArithmeticXP::GenKey(*this, caps, b); | 276 GLArithmeticXP::GenKey(*this, caps, b); |
(...skipping 16 matching lines...) Expand all Loading... |
294 GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float
k4, | 293 GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float
k4, |
295 bool enforcePMColor) | 294 bool enforcePMColor) |
296 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { | 295 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { |
297 this->initClassID<GrArithmeticXPFactory>(); | 296 this->initClassID<GrArithmeticXPFactory>(); |
298 } | 297 } |
299 | 298 |
300 GrXferProcessor* | 299 GrXferProcessor* |
301 GrArithmeticXPFactory::onCreateXferProcessor(const GrDrawTargetCaps& caps, | 300 GrArithmeticXPFactory::onCreateXferProcessor(const GrDrawTargetCaps& caps, |
302 const GrProcOptInfo& colorPOI, | 301 const GrProcOptInfo& colorPOI, |
303 const GrProcOptInfo& coveragePOI, | 302 const GrProcOptInfo& coveragePOI, |
304 const GrDeviceCoordTexture* dstCopy
) const { | 303 const DstTexture* dstTexture) const
{ |
305 return ArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstCopy, | 304 return ArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstTexture, |
306 this->willReadDstColor(caps, colorPOI, coverageP
OI)); | 305 this->willReadDstColor(caps, colorPOI, coverageP
OI)); |
307 } | 306 } |
308 | 307 |
309 | 308 |
310 void GrArithmeticXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, | 309 void GrArithmeticXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, |
311 const GrProcOptInfo& coveragePOI, | 310 const GrProcOptInfo& coveragePOI, |
312 GrXPFactory::InvariantOutput* out
put) const { | 311 GrXPFactory::InvariantOutput* out
put) const { |
313 output->fWillBlendWithDst = true; | 312 output->fWillBlendWithDst = true; |
314 | 313 |
315 // TODO: We could try to optimize this more. For example if we have solid co
verage and fK1 and | 314 // TODO: We could try to optimize this more. For example if we have solid co
verage and fK1 and |
(...skipping 11 matching lines...) Expand all Loading... |
327 float k1 = random->nextF(); | 326 float k1 = random->nextF(); |
328 float k2 = random->nextF(); | 327 float k2 = random->nextF(); |
329 float k3 = random->nextF(); | 328 float k3 = random->nextF(); |
330 float k4 = random->nextF(); | 329 float k4 = random->nextF(); |
331 bool enforcePMColor = random->nextBool(); | 330 bool enforcePMColor = random->nextBool(); |
332 | 331 |
333 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); | 332 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); |
334 } | 333 } |
335 | 334 |
336 #endif | 335 #endif |
OLD | NEW |