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 GrDisableColorXP_DEFINED 9 #define GrDisableColorXP_DEFINED 10 11 #include "GrTypes.h" 12 #include "GrXferProcessor.h" 13 #include "SkRefCnt.h" 14 15 // See the comment above GrXPFactory's definition about this warning suppression. 16 #if defined(__GNUC__) 17 #pragma GCC diagnostic push 18 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" 19 #endif 20 #if defined(__clang__) 21 #pragma clang diagnostic push 22 #pragma clang diagnostic ignored "-Wnon-virtual-dtor" 23 #endif 24 class GrDisableColorXPFactory : public GrXPFactory { 25 public: 26 static const GrXPFactory* Get(); 27 28 private: GrDisableColorXPFactory()29 constexpr GrDisableColorXPFactory() {} 30 analysisProperties(const GrProcessorAnalysisColor &,const GrProcessorAnalysisCoverage &,const GrCaps &)31 AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, 32 const GrProcessorAnalysisCoverage&, 33 const GrCaps&) const override { 34 return AnalysisProperties::kCompatibleWithAlphaAsCoverage | 35 AnalysisProperties::kIgnoresInputColor; 36 } 37 38 sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&, 39 GrProcessorAnalysisCoverage, 40 bool hasMixedSamples, 41 const GrCaps&) const override; 42 43 GR_DECLARE_XP_FACTORY_TEST 44 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 Get()54inline const GrXPFactory* GrDisableColorXPFactory::Get() { 55 // If this is constructed as static constexpr by cl.exe (2015 SP2) the vtable is null. 56 #ifdef SK_BUILD_FOR_WIN 57 static const GrDisableColorXPFactory gDisableColorXPFactory; 58 #else 59 static constexpr const GrDisableColorXPFactory gDisableColorXPFactory; 60 #endif 61 return &gDisableColorXPFactory; 62 } 63 64 #endif 65