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, Position pos = {}) DSLModifiers(DSLLayout (),flags,pos)36 : DSLModifiers(DSLLayout(), flags, pos) {} 37 38 DSLModifiers(DSLLayout layout, int flags = 0, Position pos = {}) 39 : fModifiers(layout.fSkSLLayout, flags) 40 , fPosition(pos) {} 41 flags()42 int& flags() { 43 return fModifiers.fFlags; 44 } 45 flags()46 const int& flags() const { 47 return fModifiers.fFlags; 48 } 49 layout()50 DSLLayout layout() const { 51 return DSLLayout(fModifiers.fLayout); 52 } 53 54 private: 55 SkSL::Modifiers fModifiers; 56 Position fPosition; 57 58 friend DSLType StructType(std::string_view name, 59 SkSpan<DSLField> fields, 60 bool interfaceBlock, 61 Position pos); 62 friend class DSLCore; 63 friend class DSLFunction; 64 friend class DSLType; 65 friend class DSLWriter; 66 }; 67 68 } // namespace dsl 69 70 } // namespace SkSL 71 72 #endif 73