aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrOverdrawFragmentProcessor.cpp
blob: 31ab53d3974063f5175f43c90fd8a91750b96943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/*
 * This file was autogenerated from GrOverdrawFragmentProcessor.fp; do not modify.
 */
#include "GrOverdrawFragmentProcessor.h"
#if SK_SUPPORT_GPU
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramBuilder.h"
#include "SkSLCPP.h"
#include "SkSLUtil.h"
class GrGLSLOverdrawFragmentProcessor : public GrGLSLFragmentProcessor {
public:
    GrGLSLOverdrawFragmentProcessor() {}
    void emitCode(EmitArgs& args) override {
        GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
        const GrOverdrawFragmentProcessor& _outer = args.fFp.cast<GrOverdrawFragmentProcessor>();
        (void)_outer;
        auto color0 = _outer.color0();
        (void)color0;
        auto color1 = _outer.color1();
        (void)color1;
        auto color2 = _outer.color2();
        (void)color2;
        auto color3 = _outer.color3();
        (void)color3;
        auto color4 = _outer.color4();
        (void)color4;
        auto color5 = _outer.color5();
        (void)color5;
        fragBuilder->codeAppendf(
                "half alpha = half(255.0 * float(%s.w));\nif (float(alpha) < 0.5) {\n    %s = "
                "half4(%f, %f, %f, %f);\n} else if (float(alpha) < 1.5) {\n    %s = half4(%f, %f, "
                "%f, %f);\n} else if (float(alpha) < 2.5) {\n    %s = half4(%f, %f, %f, %f);\n} "
                "else if (float(alpha) < 3.5) {\n    %s = half4(%f, %f, %f, %f);\n} else if "
                "(float(alpha) < 4.5) {\n    %s = half4(%f, %f, %f, %f);\n} else {\n    %s = "
                "half4(%f, %f, %f, %f);\n}\n",
                args.fInputColor ? args.fInputColor : "half4(1)", args.fOutputColor,
                SkGetPackedR32(_outer.color0()) / 255.0, SkGetPackedG32(_outer.color0()) / 255.0,
                SkGetPackedB32(_outer.color0()) / 255.0, SkGetPackedA32(_outer.color0()) / 255.0,
                args.fOutputColor, SkGetPackedR32(_outer.color1()) / 255.0,
                SkGetPackedG32(_outer.color1()) / 255.0, SkGetPackedB32(_outer.color1()) / 255.0,
                SkGetPackedA32(_outer.color1()) / 255.0, args.fOutputColor,
                SkGetPackedR32(_outer.color2()) / 255.0, SkGetPackedG32(_outer.color2()) / 255.0,
                SkGetPackedB32(_outer.color2()) / 255.0, SkGetPackedA32(_outer.color2()) / 255.0,
                args.fOutputColor, SkGetPackedR32(_outer.color3()) / 255.0,
                SkGetPackedG32(_outer.color3()) / 255.0, SkGetPackedB32(_outer.color3()) / 255.0,
                SkGetPackedA32(_outer.color3()) / 255.0, args.fOutputColor,
                SkGetPackedR32(_outer.color4()) / 255.0, SkGetPackedG32(_outer.color4()) / 255.0,
                SkGetPackedB32(_outer.color4()) / 255.0, SkGetPackedA32(_outer.color4()) / 255.0,
                args.fOutputColor, SkGetPackedR32(_outer.color5()) / 255.0,
                SkGetPackedG32(_outer.color5()) / 255.0, SkGetPackedB32(_outer.color5()) / 255.0,
                SkGetPackedA32(_outer.color5()) / 255.0);
    }

private:
    void onSetData(const GrGLSLProgramDataManager& pdman,
                   const GrFragmentProcessor& _proc) override {}
};
GrGLSLFragmentProcessor* GrOverdrawFragmentProcessor::onCreateGLSLInstance() const {
    return new GrGLSLOverdrawFragmentProcessor();
}
void GrOverdrawFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
                                                        GrProcessorKeyBuilder* b) const {}
bool GrOverdrawFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) const {
    const GrOverdrawFragmentProcessor& that = other.cast<GrOverdrawFragmentProcessor>();
    (void)that;
    if (fColor0 != that.fColor0) return false;
    if (fColor1 != that.fColor1) return false;
    if (fColor2 != that.fColor2) return false;
    if (fColor3 != that.fColor3) return false;
    if (fColor4 != that.fColor4) return false;
    if (fColor5 != that.fColor5) return false;
    return true;
}
GrOverdrawFragmentProcessor::GrOverdrawFragmentProcessor(const GrOverdrawFragmentProcessor& src)
        : INHERITED(kGrOverdrawFragmentProcessor_ClassID, src.optimizationFlags())
        , fColor0(src.fColor0)
        , fColor1(src.fColor1)
        , fColor2(src.fColor2)
        , fColor3(src.fColor3)
        , fColor4(src.fColor4)
        , fColor5(src.fColor5) {}
std::unique_ptr<GrFragmentProcessor> GrOverdrawFragmentProcessor::clone() const {
    return std::unique_ptr<GrFragmentProcessor>(new GrOverdrawFragmentProcessor(*this));
}
#endif