| 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 "effects/GrCustomXfermode.h" | 8 #include "effects/GrCustomXfermode.h" |
| 9 | 9 |
| 10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 330 |
| 331 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, | 331 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
| 332 GrXPFactory::InvariantBlendedColor*) const ove
rride; | 332 GrXPFactory::InvariantBlendedColor*) const ove
rride; |
| 333 | 333 |
| 334 private: | 334 private: |
| 335 GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, | 335 GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, |
| 336 const GrPipelineOptimizations& optimi
zations, | 336 const GrPipelineOptimizations& optimi
zations, |
| 337 bool hasMixedSamples, | 337 bool hasMixedSamples, |
| 338 const DstTexture*) const override; | 338 const DstTexture*) const override; |
| 339 | 339 |
| 340 bool onWillReadDstColor(const GrCaps& caps, | 340 bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const
override; |
| 341 const GrPipelineOptimizations& optimizations, | |
| 342 bool hasMixedSamples) const override; | |
| 343 | 341 |
| 344 bool onIsEqual(const GrXPFactory& xpfBase) const override { | 342 bool onIsEqual(const GrXPFactory& xpfBase) const override { |
| 345 const CustomXPFactory& xpf = xpfBase.cast<CustomXPFactory>(); | 343 const CustomXPFactory& xpf = xpfBase.cast<CustomXPFactory>(); |
| 346 return fMode == xpf.fMode; | 344 return fMode == xpf.fMode; |
| 347 } | 345 } |
| 348 | 346 |
| 349 GR_DECLARE_XP_FACTORY_TEST; | 347 GR_DECLARE_XP_FACTORY_TEST; |
| 350 | 348 |
| 351 SkXfermode::Mode fMode; | 349 SkXfermode::Mode fMode; |
| 352 GrBlendEquation fHWBlendEquation; | 350 GrBlendEquation fHWBlendEquation; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 366 bool hasMixedSamples, | 364 bool hasMixedSamples, |
| 367 const DstTexture* dstTex
ture) const { | 365 const DstTexture* dstTex
ture) const { |
| 368 if (can_use_hw_blend_equation(fHWBlendEquation, opt, caps)) { | 366 if (can_use_hw_blend_equation(fHWBlendEquation, opt, caps)) { |
| 369 SkASSERT(!dstTexture || !dstTexture->texture()); | 367 SkASSERT(!dstTexture || !dstTexture->texture()); |
| 370 return new CustomXP(fMode, fHWBlendEquation); | 368 return new CustomXP(fMode, fHWBlendEquation); |
| 371 } | 369 } |
| 372 return new CustomXP(dstTexture, hasMixedSamples, fMode); | 370 return new CustomXP(dstTexture, hasMixedSamples, fMode); |
| 373 } | 371 } |
| 374 | 372 |
| 375 bool CustomXPFactory::onWillReadDstColor(const GrCaps& caps, | 373 bool CustomXPFactory::onWillReadDstColor(const GrCaps& caps, |
| 376 const GrPipelineOptimizations& optimiza
tions, | 374 const GrPipelineOptimizations& optimiza
tions) const { |
| 377 bool hasMixedSamples) const { | |
| 378 return !can_use_hw_blend_equation(fHWBlendEquation, optimizations, caps); | 375 return !can_use_hw_blend_equation(fHWBlendEquation, optimizations, caps); |
| 379 } | 376 } |
| 380 | 377 |
| 381 void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, | 378 void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
| 382 InvariantBlendedColor* blendedCol
or) const { | 379 InvariantBlendedColor* blendedCol
or) const { |
| 383 blendedColor->fWillBlendWithDst = true; | 380 blendedColor->fWillBlendWithDst = true; |
| 384 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 381 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 385 } | 382 } |
| 386 | 383 |
| 387 GR_DEFINE_XP_FACTORY_TEST(CustomXPFactory); | 384 GR_DEFINE_XP_FACTORY_TEST(CustomXPFactory); |
| 388 const GrXPFactory* CustomXPFactory::TestCreate(GrProcessorTestData* d) { | 385 const GrXPFactory* CustomXPFactory::TestCreate(GrProcessorTestData* d) { |
| 389 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, | 386 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, |
| 390 SkXfermode::kLastSeparableMode); | 387 SkXfermode::kLastSeparableMode); |
| 391 | 388 |
| 392 return new CustomXPFactory(static_cast<SkXfermode::Mode>(mode)); | 389 return new CustomXPFactory(static_cast<SkXfermode::Mode>(mode)); |
| 393 } | 390 } |
| 394 | 391 |
| 395 /////////////////////////////////////////////////////////////////////////////// | 392 /////////////////////////////////////////////////////////////////////////////// |
| 396 | 393 |
| 397 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { | 394 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { |
| 398 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 395 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
| 399 return nullptr; | 396 return nullptr; |
| 400 } else { | 397 } else { |
| 401 return new CustomXPFactory(mode); | 398 return new CustomXPFactory(mode); |
| 402 } | 399 } |
| 403 } | 400 } |
| OLD | NEW |