Coverage Report

Created: 2021-08-22 09:07

/src/skia/src/sksl/ir/SkSLSetting.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2016 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 SKSL_SETTING
9
#define SKSL_SETTING
10
11
#include "src/sksl/SkSLContext.h"
12
#include "src/sksl/ir/SkSLExpression.h"
13
14
namespace SkSL {
15
16
/**
17
 * Represents a compile-time constant setting, such as sk_Caps.fbFetchSupport. These IRNodes should
18
 * only exist in a dehydrated module. These nodes are replaced with the value of the setting during
19
 * rehydration or compilation (i.e., whenever fReplaceSettings is true).
20
 */
21
class Setting final : public Expression {
22
public:
23
    static constexpr Kind kExpressionKind = Kind::kSetting;
24
25
    Setting(int offset, skstd::string_view name, const Type* type)
26
        : INHERITED(offset, kExpressionKind, type)
27
0
        , fName(std::move(name)) {}
28
29
    // Creates an SkSL setting expression if `fReplaceSettings` is false, or the current value of
30
    // the setting when it is true. Reports errors via the ErrorReporter.
31
    // (There's no failsafe Make equivalent, because there really isn't a good fallback expression
32
    // to produce when the `name` lookup fails. We wouldn't even know the expected type.)
33
    static std::unique_ptr<Expression> Convert(const Context& context, int offset,
34
                                               const skstd::string_view& name);
35
36
0
    std::unique_ptr<Expression> clone() const override {
37
0
        return std::make_unique<Setting>(fOffset, this->name(), &this->type());
38
0
    }
39
40
0
    const skstd::string_view& name() const {
41
0
        return fName;
42
0
    }
43
44
0
    String description() const override {
45
0
        return String(this->name());
46
0
    }
47
48
0
    bool hasProperty(Property property) const override {
49
0
        return false;
50
0
    }
51
52
private:
53
    skstd::string_view fName;
54
55
    using INHERITED = Expression;
56
};
57
58
}  // namespace SkSL
59
60
#endif