1/*
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 "include/core/SkRegion.h"
12#include "include/gpu/GrTypes.h"
13#include "src/gpu/GrXferProcessor.h"
14
15// See the comment above GrXPFactory's definition about this warning suppression.
16#if defined(__GNUC__)
17#pragma GCC diagnostic push
18#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
19#endif
20#if defined(__clang__)
21#pragma clang diagnostic push
22#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
23#endif
24
25/**
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 */
30class GrCoverageSetOpXPFactory : public GrXPFactory {
31public:
32 static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false);
33
34private:
35 constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
36
37 sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&,
38 GrProcessorAnalysisCoverage,
39 bool hasMixedSamples,
40 const GrCaps&,
41 GrClampType) const override;
42
43 AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&,
44 const GrProcessorAnalysisCoverage&,
45 const GrCaps&,
46 GrClampType) const override {
47 return AnalysisProperties::kIgnoresInputColor;
48 }
49
50
51 GR_DECLARE_XP_FACTORY_TEST
52
53 SkRegion::Op fRegionOp;
54 bool fInvertCoverage;
55
56 typedef GrXPFactory INHERITED;
57};
58#if defined(__GNUC__)
59#pragma GCC diagnostic pop
60#endif
61#if defined(__clang__)
62#pragma clang diagnostic pop
63#endif
64
65#endif
66