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