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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 void GrArithmeticFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { | 135 void GrArithmeticFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { |
136 // TODO: optimize this | 136 // TODO: optimize this |
137 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); | 137 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
138 } | 138 } |
139 | 139 |
140 /////////////////////////////////////////////////////////////////////////////// | 140 /////////////////////////////////////////////////////////////////////////////// |
141 | 141 |
142 GrFragmentProcessor* GrArithmeticFP::TestCreate(SkRandom* rand, | 142 GrFragmentProcessor* GrArithmeticFP::TestCreate(SkRandom* rand, |
143 GrContext*, | 143 GrContext*, |
144 const GrDrawTargetCaps&, | 144 const GrCaps&, |
145 GrTexture* textures[]) { | 145 GrTexture* textures[]) { |
146 float k1 = rand->nextF(); | 146 float k1 = rand->nextF(); |
147 float k2 = rand->nextF(); | 147 float k2 = rand->nextF(); |
148 float k3 = rand->nextF(); | 148 float k3 = rand->nextF(); |
149 float k4 = rand->nextF(); | 149 float k4 = rand->nextF(); |
150 bool enforcePMColor = rand->nextBool(); | 150 bool enforcePMColor = rand->nextBool(); |
151 | 151 |
152 return SkNEW_ARGS(GrArithmeticFP, (k1, k2, k3, k4, enforcePMColor, textures[
0])); | 152 return SkNEW_ARGS(GrArithmeticFP, (k1, k2, k3, k4, enforcePMColor, textures[
0])); |
153 } | 153 } |
154 | 154 |
(...skipping 27 matching lines...) Expand all Loading... |
182 bool enforcePMColor() const { return fEnforcePMColor; } | 182 bool enforcePMColor() const { return fEnforcePMColor; } |
183 | 183 |
184 private: | 184 private: |
185 ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor, | 185 ArithmeticXP(float k1, float k2, float k3, float k4, bool enforcePMColor, |
186 const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); | 186 const GrDeviceCoordTexture* dstCopy, bool willReadDstColor); |
187 | 187 |
188 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 188 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
189 const GrProcOptInfo& coveragePO
I, | 189 const GrProcOptInfo& coveragePO
I, |
190 bool doesStencilWrite, | 190 bool doesStencilWrite, |
191 GrColor* overrideColor, | 191 GrColor* overrideColor, |
192 const GrDrawTargetCaps& caps) o
verride; | 192 const GrCaps& caps) override; |
193 | 193 |
194 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; | 194 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; |
195 | 195 |
196 bool onIsEqual(const GrXferProcessor& xpBase) const override { | 196 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
197 const ArithmeticXP& xp = xpBase.cast<ArithmeticXP>(); | 197 const ArithmeticXP& xp = xpBase.cast<ArithmeticXP>(); |
198 if (fK1 != xp.fK1 || | 198 if (fK1 != xp.fK1 || |
199 fK2 != xp.fK2 || | 199 fK2 != xp.fK2 || |
200 fK3 != xp.fK3 || | 200 fK3 != xp.fK3 || |
201 fK4 != xp.fK4 || | 201 fK4 != xp.fK4 || |
202 fEnforcePMColor != xp.fEnforcePMColor) { | 202 fEnforcePMColor != xp.fEnforcePMColor) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 278 } |
279 | 279 |
280 GrGLXferProcessor* ArithmeticXP::createGLInstance() const { | 280 GrGLXferProcessor* ArithmeticXP::createGLInstance() const { |
281 return SkNEW_ARGS(GLArithmeticXP, (*this)); | 281 return SkNEW_ARGS(GLArithmeticXP, (*this)); |
282 } | 282 } |
283 | 283 |
284 GrXferProcessor::OptFlags ArithmeticXP::onGetOptimizations(const GrProcOptInfo&
colorPOI, | 284 GrXferProcessor::OptFlags ArithmeticXP::onGetOptimizations(const GrProcOptInfo&
colorPOI, |
285 const GrProcOptInfo&
coveragePOI, | 285 const GrProcOptInfo&
coveragePOI, |
286 bool doesStencilWrite
, | 286 bool doesStencilWrite
, |
287 GrColor* overrideColo
r, | 287 GrColor* overrideColo
r, |
288 const GrDrawTargetCap
s& caps) { | 288 const GrCaps& caps) { |
289 return GrXferProcessor::kNone_Opt; | 289 return GrXferProcessor::kNone_Opt; |
290 } | 290 } |
291 | 291 |
292 /////////////////////////////////////////////////////////////////////////////// | 292 /////////////////////////////////////////////////////////////////////////////// |
293 | 293 |
294 GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float
k4, | 294 GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float
k4, |
295 bool enforcePMColor) | 295 bool enforcePMColor) |
296 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { | 296 : fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) { |
297 this->initClassID<GrArithmeticXPFactory>(); | 297 this->initClassID<GrArithmeticXPFactory>(); |
298 } | 298 } |
299 | 299 |
300 GrXferProcessor* | 300 GrXferProcessor* |
301 GrArithmeticXPFactory::onCreateXferProcessor(const GrDrawTargetCaps& caps, | 301 GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps, |
302 const GrProcOptInfo& colorPOI, | 302 const GrProcOptInfo& colorPOI, |
303 const GrProcOptInfo& coveragePOI, | 303 const GrProcOptInfo& coveragePOI, |
304 const GrDeviceCoordTexture* dstCopy
) const { | 304 const GrDeviceCoordTexture* dstCopy
) const { |
305 return ArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstCopy, | 305 return ArithmeticXP::Create(fK1, fK2, fK3, fK4, fEnforcePMColor, dstCopy, |
306 this->willReadDstColor(caps, colorPOI, coverageP
OI)); | 306 this->willReadDstColor(caps, colorPOI, coverageP
OI)); |
307 } | 307 } |
308 | 308 |
309 | 309 |
310 void GrArithmeticXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, | 310 void GrArithmeticXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, |
311 const GrProcOptInfo& coveragePOI, | 311 const GrProcOptInfo& coveragePOI, |
312 GrXPFactory::InvariantOutput* out
put) const { | 312 GrXPFactory::InvariantOutput* out
put) const { |
313 output->fWillBlendWithDst = true; | 313 output->fWillBlendWithDst = true; |
314 | 314 |
315 // TODO: We could try to optimize this more. For example if we have solid co
verage and fK1 and | 315 // TODO: We could try to optimize this more. For example if we have solid co
verage and fK1 and |
316 // fK3 are zero, then we won't be blending the color with dst at all so we c
an know what the | 316 // fK3 are zero, then we won't be blending the color with dst at all so we c
an know what the |
317 // output color is (up to the valid color components passed in). | 317 // output color is (up to the valid color components passed in). |
318 output->fBlendedColorFlags = 0; | 318 output->fBlendedColorFlags = 0; |
319 } | 319 } |
320 | 320 |
321 GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); | 321 GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory); |
322 | 322 |
323 GrXPFactory* GrArithmeticXPFactory::TestCreate(SkRandom* random, | 323 GrXPFactory* GrArithmeticXPFactory::TestCreate(SkRandom* random, |
324 GrContext*, | 324 GrContext*, |
325 const GrDrawTargetCaps&, | 325 const GrCaps&, |
326 GrTexture*[]) { | 326 GrTexture*[]) { |
327 float k1 = random->nextF(); | 327 float k1 = random->nextF(); |
328 float k2 = random->nextF(); | 328 float k2 = random->nextF(); |
329 float k3 = random->nextF(); | 329 float k3 = random->nextF(); |
330 float k4 = random->nextF(); | 330 float k4 = random->nextF(); |
331 bool enforcePMColor = random->nextBool(); | 331 bool enforcePMColor = random->nextBool(); |
332 | 332 |
333 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); | 333 return GrArithmeticXPFactory::Create(k1, k2, k3, k4, enforcePMColor); |
334 } | 334 } |
335 | 335 |
336 #endif | 336 #endif |
OLD | NEW |