blob: 02db11b811fe3ae24ebe490979aeb7f53a4aedcf [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 Salomon5298dc82017-02-22 11:52:03 -050035 bool willReadsDst(const FragmentProcessorAnalysis&) const override {
Brian Salomon9a514982017-02-14 10:28:22 -050036 return fRegionOp != SkRegion::kReplace_Op;
37 }
38
Brian Salomon92aee3d2016-12-21 09:20:25 -050039 GrXferProcessor* onCreateXferProcessor(const GrCaps&,
Brian Salomon5298dc82017-02-22 11:52:03 -050040 const FragmentProcessorAnalysis&,
cdalton86ae0a92015-06-08 15:11:04 -070041 bool hasMixedSamples,
bsalomon6a44c6a2015-05-26 09:49:05 -070042 const DstTexture*) const override;
bsalomon50785a32015-02-06 07:02:37 -080043
Brian Salomon42c456f2017-03-06 11:29:48 -050044 bool willReadDstInShader(const GrCaps&, const FragmentProcessorAnalysis&) const override {
Brian Salomon9a514982017-02-14 10:28:22 -050045 return false;
46 }
bsalomon50785a32015-02-06 07:02:37 -080047
egdaniel87509242014-12-17 13:37:13 -080048 GR_DECLARE_XP_FACTORY_TEST;
49
50 SkRegion::Op fRegionOp;
51 bool fInvertCoverage;
52
53 typedef GrXPFactory INHERITED;
54};
Brian Salomona1633922017-01-09 11:46:10 -050055#if defined(__GNUC__) || defined(__clang)
56#pragma GCC diagnostic pop
57#endif
egdaniel87509242014-12-17 13:37:13 -080058#endif
59