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