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