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 8 #ifndef GrPorterDuffXferProcessor_DEFINED 9 #define GrPorterDuffXferProcessor_DEFINED 10 11 #include "include/core/SkBlendMode.h" 12 #include "include/gpu/GrTypes.h" 13 #include "include/private/base/SkMacros.h" 14 #include "src/gpu/ganesh/GrProcessorUnitTest.h" 15 #include "src/gpu/ganesh/GrXferProcessor.h" 16 17 // See the comment above GrXPFactory's definition about this warning suppression. 18 #if defined(__GNUC__) 19 #pragma GCC diagnostic push 20 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" 21 #endif 22 #if defined(__clang__) 23 #pragma clang diagnostic push 24 #pragma clang diagnostic ignored "-Wnon-virtual-dtor" 25 #endif 26 class GrPorterDuffXPFactory : public GrXPFactory { 27 public: 28 static const GrXPFactory* Get(SkBlendMode blendMode); 29 30 /** Because src-over is so common we special case it for performance reasons. If this returns 31 null then the SimpleSrcOverXP() below should be used. */ 32 static sk_sp<const GrXferProcessor> MakeSrcOverXferProcessor(const GrProcessorAnalysisColor&, 33 GrProcessorAnalysisCoverage, 34 const GrCaps&); 35 36 /** Returns a simple non-LCD porter duff blend XP with no optimizations or coverage. */ 37 static sk_sp<const GrXferProcessor> MakeNoCoverageXP(SkBlendMode); 38 39 /** This XP implements non-LCD src-over using hw blend with no optimizations. It is returned 40 by reference because it is global and its ref-cnting methods are not thread safe. */ 41 static const GrXferProcessor& SimpleSrcOverXP(); 42 43 static AnalysisProperties SrcOverAnalysisProperties(const GrProcessorAnalysisColor&, 44 const GrProcessorAnalysisCoverage&, 45 const GrCaps&, 46 GrClampType); 47 48 private: 49 constexpr GrPorterDuffXPFactory(SkBlendMode); 50 51 sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&, 52 GrProcessorAnalysisCoverage, 53 const GrCaps&, 54 GrClampType) const override; 55 56 AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, 57 const GrProcessorAnalysisCoverage&, 58 const GrCaps&, 59 GrClampType) const override; 60 61 GR_DECLARE_XP_FACTORY_TEST 62 static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, int* outSecondary); 63 64 SkBlendMode fBlendMode; 65 66 friend class GrPorterDuffTest; // for TestGetXPOutputTypes() 67 using INHERITED = GrXPFactory; 68 }; 69 #if defined(__GNUC__) 70 #pragma GCC diagnostic pop 71 #endif 72 #if defined(__clang__) 73 #pragma clang diagnostic pop 74 #endif 75 76 #endif 77