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 "GrTypes.h"
12 #include "GrXferProcessor.h"
13 #include "SkRefCnt.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 class GrDisableColorXPFactory : public GrXPFactory {
25 public:
26 static const GrXPFactory* Get();
27
28 private:
GrDisableColorXPFactory()29 constexpr GrDisableColorXPFactory() {}
30
analysisProperties(const GrProcessorAnalysisColor &,const GrProcessorAnalysisCoverage &,const GrCaps &,GrClampType)31 AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&,
32 const GrProcessorAnalysisCoverage&,
33 const GrCaps&,
34 GrClampType) const override {
35 return AnalysisProperties::kCompatibleWithAlphaAsCoverage |
36 AnalysisProperties::kIgnoresInputColor;
37 }
38
39 sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&,
40 GrProcessorAnalysisCoverage,
41 bool hasMixedSamples,
42 const GrCaps&,
43 GrClampType) const override;
44
45 GR_DECLARE_XP_FACTORY_TEST
46
47 typedef GrXPFactory INHERITED;
48 };
49 #if defined(__GNUC__)
50 #pragma GCC diagnostic pop
51 #endif
52 #if defined(__clang__)
53 #pragma clang diagnostic pop
54 #endif
55
Get()56 inline const GrXPFactory* GrDisableColorXPFactory::Get() {
57 // If this is constructed as static constexpr by cl.exe (2015 SP2) the vtable is null.
58 #ifdef SK_BUILD_FOR_WIN
59 static const GrDisableColorXPFactory gDisableColorXPFactory;
60 #else
61 static constexpr const GrDisableColorXPFactory gDisableColorXPFactory;
62 #endif
63 return &gDisableColorXPFactory;
64 }
65
66 #endif
67