• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 are generally
18  * collapsed down to their constant representations during the compilation process.
19  */
20 struct Setting : public Expression {
SettingSetting21     Setting(int offset, String name, std::unique_ptr<Expression> value)
22     : INHERITED(offset, kSetting_Kind, value->fType)
23     , fName(std::move(name))
24     , fValue(std::move(value)) {
25         SkASSERT(fValue->isConstant());
26     }
27 
28     std::unique_ptr<Expression> constantPropagate(const IRGenerator& irGenerator,
29                                                   const DefinitionMap& definitions) override;
30 
cloneSetting31     std::unique_ptr<Expression> clone() const override {
32         return std::unique_ptr<Expression>(new Setting(fOffset, fName, fValue->clone()));
33     }
34 
descriptionSetting35     String description() const override {
36         return fName;
37     }
38 
hasSideEffectsSetting39     bool hasSideEffects() const override {
40         return false;
41     }
42 
isConstantSetting43     bool isConstant() const override {
44         return true;
45     }
46 
47     const String fName;
48     std::unique_ptr<Expression> fValue;
49 
50     typedef Expression INHERITED;
51 };
52 
53 } // namespace
54 
55 #endif
56