blob: e8bc5a223f5924697e381d546bcb70e9c1d05c12 [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
Brian Salomona1633922017-01-09 11:46:10 -050015// See the comment above GrXPFactory's definition about this warning suppression.
Chris Dalton1ef80942017-12-04 12:01:30 -070016#if defined(__GNUC__)
Brian Salomona1633922017-01-09 11:46:10 -050017#pragma GCC diagnostic push
18#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
19#endif
Chris Dalton1ef80942017-12-04 12:01:30 -070020#if defined(__clang__)
21#pragma clang diagnostic push
22#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
23#endif
Brian Salomona1633922017-01-09 11:46:10 -050024
egdanielb197b8f2015-02-17 07:34:43 -080025/**
26 * This xfer processor directly blends the the src coverage with the dst using a set operator. It is
27 * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before
28 * applying the set operator.
29 */
egdaniel87509242014-12-17 13:37:13 -080030class GrCoverageSetOpXPFactory : public GrXPFactory {
31public:
Brian Salomona1633922017-01-09 11:46:10 -050032 static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false);
egdaniel87509242014-12-17 13:37:13 -080033
egdaniel87509242014-12-17 13:37:13 -080034private:
Brian Salomona1633922017-01-09 11:46:10 -050035 constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
egdaniel87509242014-12-17 13:37:13 -080036
Brian Salomond61c9d92017-04-10 10:54:25 -040037 sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&,
38 GrProcessorAnalysisCoverage,
39 bool hasMixedSamples,
Brian Osman532b3f92018-07-11 10:02:07 -040040 const GrCaps&) const override;
bsalomon50785a32015-02-06 07:02:37 -080041
Brian Salomona811b122017-03-30 08:21:32 -040042 AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&,
43 const GrProcessorAnalysisCoverage&,
Brian Osman532b3f92018-07-11 10:02:07 -040044 const GrCaps&) const override {
Brian Salomon31853842017-03-28 16:32:05 -040045 return AnalysisProperties::kIgnoresInputColor;
Brian Salomon9a514982017-02-14 10:28:22 -050046 }
bsalomon50785a32015-02-06 07:02:37 -080047
Brian Salomon780b41f2017-03-13 10:36:40 -040048
Brian Salomon0c26a9d2017-07-06 10:09:38 -040049 GR_DECLARE_XP_FACTORY_TEST
egdaniel87509242014-12-17 13:37:13 -080050
51 SkRegion::Op fRegionOp;
52 bool fInvertCoverage;
53
54 typedef GrXPFactory INHERITED;
55};
Chris Dalton1ef80942017-12-04 12:01:30 -070056#if defined(__GNUC__)
Brian Salomona1633922017-01-09 11:46:10 -050057#pragma GCC diagnostic pop
58#endif
Chris Dalton1ef80942017-12-04 12:01:30 -070059#if defined(__clang__)
60#pragma clang diagnostic pop
egdaniel87509242014-12-17 13:37:13 -080061#endif
62
Chris Dalton1ef80942017-12-04 12:01:30 -070063#endif