2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrCoverageSetOpXP_DEFINED
9 #define GrCoverageSetOpXP_DEFINED
12 #include "GrXferProcessor.h"
18 * This xfer processor directly blends the the src coverage with the dst using a set operator. It is
19 * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before
20 * applying the set operator.
22 class GrCoverageSetOpXPFactory : public GrXPFactory {
24 static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = false);
26 bool supportsRGBCoverage(GrColor /*knownColor*/,
27 uint32_t /*knownColorFlags*/) const SK_OVERRIDE {
31 bool canTweakAlphaForCoverage() const SK_OVERRIDE { return false; }
33 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
34 GrXPFactory::InvariantOutput*) const SK_OVERRIDE;
37 GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
39 GrXferProcessor* onCreateXferProcessor(const GrDrawTargetCaps& caps,
40 const GrProcOptInfo& colorPOI,
41 const GrProcOptInfo& coveragePOI,
42 const GrDeviceCoordTexture* dstCopy) const SK_OVERRIDE;
44 bool willReadDstColor(const GrDrawTargetCaps& /*caps*/,
45 const GrProcOptInfo& /*colorPOI*/,
46 const GrProcOptInfo& /*coveragePOI*/) const SK_OVERRIDE {
50 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE {
51 const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFactory>();
52 return fRegionOp == xpf.fRegionOp;
55 GR_DECLARE_XP_FACTORY_TEST;
57 SkRegion::Op fRegionOp;
60 typedef GrXPFactory INHERITED;