blob: 3510505d4496da202acbc35058db384b0cfd8f91 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkRegion.h"
12#include "include/gpu/GrTypes.h"
13#include "src/gpu/GrXferProcessor.h"
egdaniel87509242014-12-17 13:37:13 -080014
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 Osman5ced0bf2019-03-15 10:15:29 -040040 const GrCaps&,
41 GrClampType) const override;
bsalomon50785a32015-02-06 07:02:37 -080042
Brian Salomona811b122017-03-30 08:21:32 -040043 AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&,
44 const GrProcessorAnalysisCoverage&,
Brian Osman5ced0bf2019-03-15 10:15:29 -040045 const GrCaps&,
46 GrClampType) const override {
Brian Salomon31853842017-03-28 16:32:05 -040047 return AnalysisProperties::kIgnoresInputColor;
Brian Salomon9a514982017-02-14 10:28:22 -050048 }
bsalomon50785a32015-02-06 07:02:37 -080049
Brian Salomon780b41f2017-03-13 10:36:40 -040050
Brian Salomon0c26a9d2017-07-06 10:09:38 -040051 GR_DECLARE_XP_FACTORY_TEST
egdaniel87509242014-12-17 13:37:13 -080052
53 SkRegion::Op fRegionOp;
54 bool fInvertCoverage;
55
56 typedef GrXPFactory INHERITED;
57};
Chris Dalton1ef80942017-12-04 12:01:30 -070058#if defined(__GNUC__)
Brian Salomona1633922017-01-09 11:46:10 -050059#pragma GCC diagnostic pop
60#endif
Chris Dalton1ef80942017-12-04 12:01:30 -070061#if defined(__clang__)
62#pragma clang diagnostic pop
egdaniel87509242014-12-17 13:37:13 -080063#endif
64
Chris Dalton1ef80942017-12-04 12:01:30 -070065#endif