blob: 5de068cb899b025c094e5d7e7018db19391c6909 [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 Salomona076d872017-04-04 15:17:03 -040033 sk_sp<GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&,
34 GrProcessorAnalysisCoverage, bool hasMixedSamples,
35 const GrCaps&) const override;
bsalomon50785a32015-02-06 07:02:37 -080036
Brian Salomona811b122017-03-30 08:21:32 -040037 AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&,
38 const GrProcessorAnalysisCoverage&,
Brian Salomon31853842017-03-28 16:32:05 -040039 const GrCaps&) const override {
40 return AnalysisProperties::kIgnoresInputColor;
Brian Salomon9a514982017-02-14 10:28:22 -050041 }
bsalomon50785a32015-02-06 07:02:37 -080042
Brian Salomon780b41f2017-03-13 10:36:40 -040043
egdaniel87509242014-12-17 13:37:13 -080044 GR_DECLARE_XP_FACTORY_TEST;
45
46 SkRegion::Op fRegionOp;
47 bool fInvertCoverage;
48
49 typedef GrXPFactory INHERITED;
50};
Brian Salomona1633922017-01-09 11:46:10 -050051#if defined(__GNUC__) || defined(__clang)
52#pragma GCC diagnostic pop
53#endif
egdaniel87509242014-12-17 13:37:13 -080054#endif
55