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 willReadDstInShader(const GrCaps &,const FragmentProcessorAnalysis &)27 bool willReadDstInShader(const GrCaps&, const FragmentProcessorAnalysis&) const override { 28 return false; 29 } 30 compatibleWithCoverageAsAlpha(bool colorIsOpaque)31 bool compatibleWithCoverageAsAlpha(bool colorIsOpaque) const override { return true; } 32 33 GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, 34 const FragmentProcessorAnalysis&, 35 bool hasMixedSamples, 36 const DstTexture* dstTexture) const override; 37 38 GR_DECLARE_XP_FACTORY_TEST; 39 40 typedef GrXPFactory INHERITED; 41 }; 42 #if defined(__GNUC__) || defined(__clang) 43 #pragma GCC diagnostic pop 44 #endif 45 Get()46inline const GrXPFactory* GrDisableColorXPFactory::Get() { 47 // If this is constructed as static constexpr by cl.exe (2015 SP2) the vtable is null. 48 #ifdef SK_BUILD_FOR_WIN 49 static const GrDisableColorXPFactory gDisableColorXPFactory; 50 #else 51 static constexpr const GrDisableColorXPFactory gDisableColorXPFactory; 52 #endif 53 return &gDisableColorXPFactory; 54 } 55 56 #endif 57