blob: 385cad865e4db4f2853fbfe09063393c16d52c3d [file] [log] [blame]
egdaniel87509242014-12-17 13:37:13 -08001/*
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
egdaniel87509242014-12-17 13:37:13 -080015class GrProcOptInfo;
16
Brian Salomona1633922017-01-09 11:46:10 -050017// See the comment above GrXPFactory's definition about this warning suppression.
18#if defined(__GNUC__) || defined(__clang)
19#pragma GCC diagnostic push
20#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
21#endif
22
egdanielb197b8f2015-02-17 07:34:43 -080023/**
24 * This xfer processor directly blends the the src coverage with the dst using a set operator. It is
25 * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before
26 * applying the set operator.
27 */
egdaniel87509242014-12-17 13:37:13 -080028class GrCoverageSetOpXPFactory : public GrXPFactory {
29public:
Brian Salomona1633922017-01-09 11:46:10 -050030 static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false);
egdaniel87509242014-12-17 13:37:13 -080031
cdalton1fa45722015-06-02 10:43:39 -070032 void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
33 GrXPFactory::InvariantBlendedColor*) const override;
egdaniel87509242014-12-17 13:37:13 -080034
egdaniel87509242014-12-17 13:37:13 -080035private:
Brian Salomona1633922017-01-09 11:46:10 -050036 constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
egdaniel87509242014-12-17 13:37:13 -080037
Brian Salomon92aee3d2016-12-21 09:20:25 -050038 GrXferProcessor* onCreateXferProcessor(const GrCaps&,
39 const GrPipelineAnalysis&,
cdalton86ae0a92015-06-08 15:11:04 -070040 bool hasMixedSamples,
bsalomon6a44c6a2015-05-26 09:49:05 -070041 const DstTexture*) const override;
bsalomon50785a32015-02-06 07:02:37 -080042
Brian Salomon5be6c952017-01-20 19:06:29 +000043 bool willReadDstColor(const GrCaps&, ColorType, CoverageType) const override { return false; }
bsalomon50785a32015-02-06 07:02:37 -080044
egdaniel87509242014-12-17 13:37:13 -080045 GR_DECLARE_XP_FACTORY_TEST;
46
47 SkRegion::Op fRegionOp;
48 bool fInvertCoverage;
49
50 typedef GrXPFactory INHERITED;
51};
Brian Salomona1633922017-01-09 11:46:10 -050052#if defined(__GNUC__) || defined(__clang)
53#pragma GCC diagnostic pop
54#endif
egdaniel87509242014-12-17 13:37:13 -080055#endif
56