blob: 7781b848bc1686bd18e1b98dfae71740bf198c84 [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
egdaniel87509242014-12-17 13:37:13 -080032private:
Brian Salomona1633922017-01-09 11:46:10 -050033 constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
egdaniel87509242014-12-17 13:37:13 -080034
Brian Salomon9a514982017-02-14 10:28:22 -050035 bool isPreCoverageBlendedColorConstant(const GrProcOptInfo&, GrColor*) const override {
36 return false;
37 }
38
39 bool willReadsDst(const GrProcOptInfo&, const GrProcOptInfo&) const override {
40 return fRegionOp != SkRegion::kReplace_Op;
41 }
42
Brian Salomon92aee3d2016-12-21 09:20:25 -050043 GrXferProcessor* onCreateXferProcessor(const GrCaps&,
44 const GrPipelineAnalysis&,
cdalton86ae0a92015-06-08 15:11:04 -070045 bool hasMixedSamples,
bsalomon6a44c6a2015-05-26 09:49:05 -070046 const DstTexture*) const override;
bsalomon50785a32015-02-06 07:02:37 -080047
Brian Salomon9a514982017-02-14 10:28:22 -050048 bool willReadDstInShader(const GrCaps&, ColorType, CoverageType) const override {
49 return false;
50 }
bsalomon50785a32015-02-06 07:02:37 -080051
egdaniel87509242014-12-17 13:37:13 -080052 GR_DECLARE_XP_FACTORY_TEST;
53
54 SkRegion::Op fRegionOp;
55 bool fInvertCoverage;
56
57 typedef GrXPFactory INHERITED;
58};
Brian Salomona1633922017-01-09 11:46:10 -050059#if defined(__GNUC__) || defined(__clang)
60#pragma GCC diagnostic pop
61#endif
egdaniel87509242014-12-17 13:37:13 -080062#endif
63