xref: /aosp_15_r20/external/skia/src/gpu/ganesh/effects/GrDisableColorXP.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 GrDisableColorXP_DEFINED
9 #define GrDisableColorXP_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "src/gpu/ganesh/GrProcessorAnalysis.h"
13 #include "src/gpu/ganesh/GrProcessorUnitTest.h"
14 #include "src/gpu/ganesh/GrXferProcessor.h"
15 
16 class GrCaps;
17 enum class GrClampType;
18 
19 // See the comment above GrXPFactory's definition about this warning suppression.
20 #if defined(__GNUC__)
21 #pragma GCC diagnostic push
22 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
23 #endif
24 #if defined(__clang__)
25 #pragma clang diagnostic push
26 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
27 #endif
28 class GrDisableColorXPFactory : public GrXPFactory {
29 public:
30     static const GrDisableColorXPFactory* Get();
31 
32     static sk_sp<const GrXferProcessor> MakeXferProcessor();
33 
34 private:
GrDisableColorXPFactory()35     constexpr GrDisableColorXPFactory() {}
36 
analysisProperties(const GrProcessorAnalysisColor &,const GrProcessorAnalysisCoverage &,const GrCaps &,GrClampType)37     AnalysisProperties analysisProperties(
38             const GrProcessorAnalysisColor&, const GrProcessorAnalysisCoverage&, const GrCaps&,
39             GrClampType) const override {
40         return AnalysisProperties::kCompatibleWithCoverageAsAlpha |
41                AnalysisProperties::kIgnoresInputColor;
42     }
43 
makeXferProcessor(const GrProcessorAnalysisColor &,GrProcessorAnalysisCoverage,const GrCaps &,GrClampType)44     sk_sp<const GrXferProcessor> makeXferProcessor(
45             const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage, const GrCaps&,
46             GrClampType) const override {
47         return MakeXferProcessor();
48     }
49 
50     GR_DECLARE_XP_FACTORY_TEST
51 
52     using INHERITED = GrXPFactory;
53 };
54 #if defined(__GNUC__)
55 #pragma GCC diagnostic pop
56 #endif
57 #if defined(__clang__)
58 #pragma clang diagnostic pop
59 #endif
60 
Get()61 inline const GrDisableColorXPFactory* GrDisableColorXPFactory::Get() {
62     static constexpr const GrDisableColorXPFactory gDisableColorXPFactory;
63     return &gDisableColorXPFactory;
64 }
65 
66 #endif
67