blob: 062d9dddd16fca770e3dbba0cdc57b8cf43a737c [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.
16#if defined(__GNUC__) || defined(__clang)
17#pragma GCC diagnostic push
18#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
19#endif
20
egdanielb197b8f2015-02-17 07:34:43 -080021/**
22 * This xfer processor directly blends the the src coverage with the dst using a set operator. It is
23 * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before
24 * applying the set operator.
25 */
egdaniel87509242014-12-17 13:37:13 -080026class GrCoverageSetOpXPFactory : public GrXPFactory {
27public:
Brian Salomona1633922017-01-09 11:46:10 -050028 static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false);
egdaniel87509242014-12-17 13:37:13 -080029
egdaniel87509242014-12-17 13:37:13 -080030private:
Brian Salomona1633922017-01-09 11:46:10 -050031 constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
egdaniel87509242014-12-17 13:37:13 -080032
Brian Salomond61c9d92017-04-10 10:54:25 -040033 sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&,
34 GrProcessorAnalysisCoverage,
35 bool hasMixedSamples,
36 const GrCaps&) const override;
bsalomon50785a32015-02-06 07:02:37 -080037
Brian Salomona811b122017-03-30 08:21:32 -040038 AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&,
39 const GrProcessorAnalysisCoverage&,
Brian Salomon31853842017-03-28 16:32:05 -040040 const GrCaps&) const override {
41 return AnalysisProperties::kIgnoresInputColor;
Brian Salomon9a514982017-02-14 10:28:22 -050042 }
bsalomon50785a32015-02-06 07:02:37 -080043
Brian Salomon780b41f2017-03-13 10:36:40 -040044
Brian Salomon0c26a9d2017-07-06 10:09:38 -040045 GR_DECLARE_XP_FACTORY_TEST
egdaniel87509242014-12-17 13:37:13 -080046
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