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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 GR_STATIC_ASSERT(kExclusion_GrBlendEquation == SkXfermode::kExclusion_Mode +
kOffset); | 47 GR_STATIC_ASSERT(kExclusion_GrBlendEquation == SkXfermode::kExclusion_Mode +
kOffset); |
48 GR_STATIC_ASSERT(kMultiply_GrBlendEquation == SkXfermode::kMultiply_Mode + k
Offset); | 48 GR_STATIC_ASSERT(kMultiply_GrBlendEquation == SkXfermode::kMultiply_Mode + k
Offset); |
49 GR_STATIC_ASSERT(kHSLHue_GrBlendEquation == SkXfermode::kHue_Mode + kOffset)
; | 49 GR_STATIC_ASSERT(kHSLHue_GrBlendEquation == SkXfermode::kHue_Mode + kOffset)
; |
50 GR_STATIC_ASSERT(kHSLSaturation_GrBlendEquation == SkXfermode::kSaturation_M
ode + kOffset); | 50 GR_STATIC_ASSERT(kHSLSaturation_GrBlendEquation == SkXfermode::kSaturation_M
ode + kOffset); |
51 GR_STATIC_ASSERT(kHSLColor_GrBlendEquation == SkXfermode::kColor_Mode + kOff
set); | 51 GR_STATIC_ASSERT(kHSLColor_GrBlendEquation == SkXfermode::kColor_Mode + kOff
set); |
52 GR_STATIC_ASSERT(kHSLLuminosity_GrBlendEquation == SkXfermode::kLuminosity_M
ode + kOffset); | 52 GR_STATIC_ASSERT(kHSLLuminosity_GrBlendEquation == SkXfermode::kLuminosity_M
ode + kOffset); |
53 GR_STATIC_ASSERT(kGrBlendEquationCnt == SkXfermode::kLastMode + 1 + kOffset)
; | 53 GR_STATIC_ASSERT(kGrBlendEquationCnt == SkXfermode::kLastMode + 1 + kOffset)
; |
54 } | 54 } |
55 | 55 |
56 static bool can_use_hw_blend_equation(GrBlendEquation equation, | 56 static bool can_use_hw_blend_equation(GrBlendEquation equation, |
57 const GrProcOptInfo& coveragePOI, | 57 const GrPipelineOptimizations& opt, |
58 const GrCaps& caps) { | 58 const GrCaps& caps) { |
59 if (!caps.advancedBlendEquationSupport()) { | 59 if (!caps.advancedBlendEquationSupport()) { |
60 return false; | 60 return false; |
61 } | 61 } |
62 if (coveragePOI.isFourChannelOutput()) { | 62 if (opt.fOverrides.fUsePLSDstRead) { |
| 63 return false; |
| 64 } |
| 65 if (opt.fCoveragePOI.isFourChannelOutput()) { |
63 return false; // LCD coverage must be applied after the blend equation. | 66 return false; // LCD coverage must be applied after the blend equation. |
64 } | 67 } |
65 if (caps.canUseAdvancedBlendEquation(equation)) { | 68 if (caps.canUseAdvancedBlendEquation(equation)) { |
66 return false; | 69 return false; |
67 } | 70 } |
68 return true; | 71 return true; |
69 } | 72 } |
70 | 73 |
71 /////////////////////////////////////////////////////////////////////////////// | 74 /////////////////////////////////////////////////////////////////////////////// |
72 // Xfer Processor | 75 // Xfer Processor |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 : fMode(mode), | 367 : fMode(mode), |
365 fHWBlendEquation(hw_blend_equation(mode)) { | 368 fHWBlendEquation(hw_blend_equation(mode)) { |
366 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); | 369 SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); |
367 this->initClassID<CustomXPFactory>(); | 370 this->initClassID<CustomXPFactory>(); |
368 } | 371 } |
369 | 372 |
370 GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps, | 373 GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps, |
371 const GrPipelineOptimiza
tions& opt, | 374 const GrPipelineOptimiza
tions& opt, |
372 bool hasMixedSamples, | 375 bool hasMixedSamples, |
373 const DstTexture* dstTex
ture) const { | 376 const DstTexture* dstTex
ture) const { |
374 if (can_use_hw_blend_equation(fHWBlendEquation, opt.fCoveragePOI, caps)) { | 377 if (can_use_hw_blend_equation(fHWBlendEquation, opt, caps)) { |
375 SkASSERT(!dstTexture || !dstTexture->texture()); | 378 SkASSERT(!dstTexture || !dstTexture->texture()); |
376 return new CustomXP(fMode, fHWBlendEquation); | 379 return new CustomXP(fMode, fHWBlendEquation); |
377 } | 380 } |
378 return new CustomXP(dstTexture, hasMixedSamples, fMode); | 381 return new CustomXP(dstTexture, hasMixedSamples, fMode); |
379 } | 382 } |
380 | 383 |
381 bool CustomXPFactory::willReadDstColor(const GrCaps& caps, | 384 bool CustomXPFactory::willReadDstColor(const GrCaps& caps, |
382 const GrPipelineOptimizations& optimizati
ons, | 385 const GrPipelineOptimizations& optimizati
ons, |
383 bool hasMixedSamples) const { | 386 bool hasMixedSamples) const { |
384 return !can_use_hw_blend_equation(fHWBlendEquation, optimizations.fCoverageP
OI, caps); | 387 return !can_use_hw_blend_equation(fHWBlendEquation, optimizations, caps); |
385 } | 388 } |
386 | 389 |
387 void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, | 390 void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
388 InvariantBlendedColor* blendedCol
or) const { | 391 InvariantBlendedColor* blendedCol
or) const { |
389 blendedColor->fWillBlendWithDst = true; | 392 blendedColor->fWillBlendWithDst = true; |
390 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 393 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
391 } | 394 } |
392 | 395 |
393 GR_DEFINE_XP_FACTORY_TEST(CustomXPFactory); | 396 GR_DEFINE_XP_FACTORY_TEST(CustomXPFactory); |
394 const GrXPFactory* CustomXPFactory::TestCreate(GrProcessorTestData* d) { | 397 const GrXPFactory* CustomXPFactory::TestCreate(GrProcessorTestData* d) { |
395 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, | 398 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, |
396 SkXfermode::kLastSeparableMode); | 399 SkXfermode::kLastSeparableMode); |
397 | 400 |
398 return new CustomXPFactory(static_cast<SkXfermode::Mode>(mode)); | 401 return new CustomXPFactory(static_cast<SkXfermode::Mode>(mode)); |
399 } | 402 } |
400 | 403 |
401 /////////////////////////////////////////////////////////////////////////////// | 404 /////////////////////////////////////////////////////////////////////////////// |
402 | 405 |
403 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { | 406 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { |
404 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 407 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
405 return nullptr; | 408 return nullptr; |
406 } else { | 409 } else { |
407 return new CustomXPFactory(mode); | 410 return new CustomXPFactory(mode); |
408 } | 411 } |
409 } | 412 } |
OLD | NEW |