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__) || defined(__clang) 17 #pragma GCC diagnostic push 18 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" 19 #endif 20 class GrDisableColorXPFactory : public GrXPFactory { 21 public: 22 static const GrXPFactory* Get(); 23 24 private: GrDisableColorXPFactory()25 constexpr GrDisableColorXPFactory() {} 26 analysisProperties(const GrProcessorAnalysisColor &,const GrProcessorAnalysisCoverage &,const GrCaps &)27 AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, 28 const GrProcessorAnalysisCoverage&, 29 const GrCaps&) const override { 30 return AnalysisProperties::kCompatibleWithAlphaAsCoverage | 31 AnalysisProperties::kIgnoresInputColor; 32 } 33 34 sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&, 35 GrProcessorAnalysisCoverage, 36 bool hasMixedSamples, 37 const GrCaps&) const override; 38 39 GR_DECLARE_XP_FACTORY_TEST 40 41 typedef GrXPFactory INHERITED; 42 }; 43 #if defined(__GNUC__) || defined(__clang) 44 #pragma GCC diagnostic pop 45 #endif 46 Get()47inline const GrXPFactory* GrDisableColorXPFactory::Get() { 48 // If this is constructed as static constexpr by cl.exe (2015 SP2) the vtable is null. 49 #ifdef SK_BUILD_FOR_WIN 50 static const GrDisableColorXPFactory gDisableColorXPFactory; 51 #else 52 static constexpr const GrDisableColorXPFactory gDisableColorXPFactory; 53 #endif 54 return &gDisableColorXPFactory; 55 } 56 57 #endif 58