GrCoverageSetOpXP.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2014 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef GrCoverageSetOpXP_DEFINED
  8. #define GrCoverageSetOpXP_DEFINED
  9. #include "include/core/SkRegion.h"
  10. #include "include/gpu/GrTypes.h"
  11. #include "src/gpu/GrXferProcessor.h"
  12. // See the comment above GrXPFactory's definition about this warning suppression.
  13. #if defined(__GNUC__)
  14. #pragma GCC diagnostic push
  15. #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
  16. #endif
  17. #if defined(__clang__)
  18. #pragma clang diagnostic push
  19. #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
  20. #endif
  21. /**
  22. * This xfer processor directly blends the the src coverage with the dst using a set operator. It is
  23. * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before
  24. * applying the set operator.
  25. */
  26. class GrCoverageSetOpXPFactory : public GrXPFactory {
  27. public:
  28. static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false);
  29. private:
  30. constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
  31. sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&,
  32. GrProcessorAnalysisCoverage,
  33. bool hasMixedSamples,
  34. const GrCaps&,
  35. GrClampType) const override;
  36. AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&,
  37. const GrProcessorAnalysisCoverage&,
  38. const GrCaps&,
  39. GrClampType) const override {
  40. return AnalysisProperties::kIgnoresInputColor;
  41. }
  42. GR_DECLARE_XP_FACTORY_TEST
  43. SkRegion::Op fRegionOp;
  44. bool fInvertCoverage;
  45. typedef GrXPFactory INHERITED;
  46. };
  47. #if defined(__GNUC__)
  48. #pragma GCC diagnostic pop
  49. #endif
  50. #if defined(__clang__)
  51. #pragma clang diagnostic pop
  52. #endif
  53. #endif