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 GrCoverageSetOpXP_DEFINED 9 #define GrCoverageSetOpXP_DEFINED 10 11 #include "GrTypes.h" 12 #include "GrXferProcessor.h" 13 #include "SkRegion.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 21 /** 22 * This xfer processor directly blends the the src coverage with the dst using a set operator. It is 23 * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before 24 * applying the set operator. 25 */ 26 class GrCoverageSetOpXPFactory : public GrXPFactory { 27 public: 28 static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false); 29 30 private: 31 constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); 32 33 GrXferProcessor* onCreateXferProcessor(const GrCaps&, 34 const FragmentProcessorAnalysis&, 35 bool hasMixedSamples, 36 const DstTexture*) const override; 37 38 bool willReadDstInShader(const GrCaps&, const FragmentProcessorAnalysis&) const override { 39 return false; 40 } 41 42 bool compatibleWithCoverageAsAlpha(bool colorIsOpaque) const override { return false; } 43 44 GR_DECLARE_XP_FACTORY_TEST; 45 46 SkRegion::Op fRegionOp; 47 bool fInvertCoverage; 48 49 typedef GrXPFactory INHERITED; 50 }; 51 #if defined(__GNUC__) || defined(__clang) 52 #pragma GCC diagnostic pop 53 #endif 54 #endif 55 56