• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 Google LLC
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_DSL_MODIFIERS
9 #define SKSL_DSL_MODIFIERS
10 
11 #include "include/core/SkSpan.h"
12 #include "include/private/SkSLModifiers.h"
13 #include "include/sksl/DSLLayout.h"
14 
15 namespace SkSL {
16 
17 namespace dsl {
18 
19 class DSLField;
20 class DSLType;
21 
22 enum Modifier {
23     kNo_Modifier            = SkSL::Modifiers::kNo_Flag,
24     kConst_Modifier         = SkSL::Modifiers::kConst_Flag,
25     kIn_Modifier            = SkSL::Modifiers::kIn_Flag,
26     kOut_Modifier           = SkSL::Modifiers::kOut_Flag,
27     kInOut_Modifier         = SkSL::Modifiers::kIn_Flag | SkSL::Modifiers::kOut_Flag,
28     kUniform_Modifier       = SkSL::Modifiers::kUniform_Flag,
29     kFlat_Modifier          = SkSL::Modifiers::kFlat_Flag,
30     kNoPerspective_Modifier = SkSL::Modifiers::kNoPerspective_Flag,
31 };
32 
33 class DSLModifiers {
34 public:
35     DSLModifiers(int flags = 0)
DSLModifiers(DSLLayout (),flags)36         : DSLModifiers(DSLLayout(), flags) {}
37 
38     DSLModifiers(DSLLayout layout, int flags = 0)
39         : fModifiers(layout.fSkSLLayout, flags) {}
40 
flags()41     int flags() const {
42         return fModifiers.fFlags;
43     }
44 
layout()45     DSLLayout layout() const {
46         return DSLLayout(fModifiers.fLayout);
47     }
48 
49 private:
50     SkSL::Modifiers fModifiers;
51 
52     friend DSLType Struct(skstd::string_view name, SkSpan<DSLField> fields, PositionInfo pos);
53     friend class DSLCore;
54     friend class DSLFunction;
55     friend class DSLType;
56     friend class DSLVarBase;
57     friend class DSLWriter;
58 };
59 
60 } // namespace dsl
61 
62 } // namespace SkSL
63 
64 #endif
65