GrPorterDuffXferProcessor.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 GrPorterDuffXferProcessor_DEFINED
  8. #define GrPorterDuffXferProcessor_DEFINED
  9. #include "include/core/SkBlendMode.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. class GrPorterDuffXPFactory : public GrXPFactory {
  22. public:
  23. static const GrXPFactory* Get(SkBlendMode blendMode);
  24. /** Because src-over is so common we special case it for performance reasons. If this returns
  25. null then the SimpleSrcOverXP() below should be used. */
  26. static sk_sp<const GrXferProcessor> MakeSrcOverXferProcessor(const GrProcessorAnalysisColor&,
  27. GrProcessorAnalysisCoverage,
  28. bool hasMixedSamples,
  29. const GrCaps&);
  30. /** Returns a simple non-LCD porter duff blend XP with no optimizations or coverage. */
  31. static sk_sp<const GrXferProcessor> MakeNoCoverageXP(SkBlendMode);
  32. /** This XP implements non-LCD src-over using hw blend with no optimizations. It is returned
  33. by reference because it is global and its ref-cnting methods are not thread safe. */
  34. static const GrXferProcessor& SimpleSrcOverXP();
  35. static AnalysisProperties SrcOverAnalysisProperties(const GrProcessorAnalysisColor&,
  36. const GrProcessorAnalysisCoverage&,
  37. const GrCaps&,
  38. GrClampType);
  39. private:
  40. constexpr GrPorterDuffXPFactory(SkBlendMode);
  41. sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&,
  42. GrProcessorAnalysisCoverage,
  43. bool hasMixedSamples,
  44. const GrCaps&,
  45. GrClampType) const override;
  46. AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&,
  47. const GrProcessorAnalysisCoverage&,
  48. const GrCaps&,
  49. GrClampType) const override;
  50. GR_DECLARE_XP_FACTORY_TEST
  51. static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, int* outSecondary);
  52. SkBlendMode fBlendMode;
  53. friend class GrPorterDuffTest; // for TestGetXPOutputTypes()
  54. typedef GrXPFactory INHERITED;
  55. };
  56. #if defined(__GNUC__)
  57. #pragma GCC diagnostic pop
  58. #endif
  59. #if defined(__clang__)
  60. #pragma clang diagnostic pop
  61. #endif
  62. #endif