• 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 "SkSLContext.h"
12 #include "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(Position position, String name, std::unique_ptr<Expression> value)
22     : INHERITED(position, kSetting_Kind, value->fType)
23     , fName(std::move(name))
24     , fValue(std::move(value)) {
25         ASSERT(fValue->isConstant());
26     }
27 
28     std::unique_ptr<Expression> constantPropagate(const IRGenerator& irGenerator,
29                                                   const DefinitionMap& definitions) override;
30 
descriptionSetting31     String description() const override {
32         return fName;
33     }
34 
hasSideEffectsSetting35     bool hasSideEffects() const override {
36         return false;
37     }
38 
isConstantSetting39     bool isConstant() const override {
40         return true;
41     }
42 
43     const String fName;
44     std::unique_ptr<Expression> fValue;
45 
46     typedef Expression INHERITED;
47 };
48 
49 } // namespace
50 
51 #endif
52