OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrShaderVar_DEFINED | 8 #ifndef GrShaderVar_DEFINED |
9 #define GrShaderVar_DEFINED | 9 #define GrShaderVar_DEFINED |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 : fType(type) | 60 : fType(type) |
61 , fTypeModifier(kNone_TypeModifier) | 61 , fTypeModifier(kNone_TypeModifier) |
62 , fName(name) | 62 , fName(name) |
63 , fCount(arrayCount) | 63 , fCount(arrayCount) |
64 , fPrecision(precision) { | 64 , fPrecision(precision) { |
65 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); | 65 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
66 SkASSERT(kVoid_GrSLType != type); | 66 SkASSERT(kVoid_GrSLType != type); |
67 } | 67 } |
68 | 68 |
69 GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier, | 69 GrShaderVar(const char* name, GrSLType type, TypeModifier typeModifier, |
70 int arrayCount = kNonArray, GrSLPrecision precision = kDefault
_GrSLPrecision) | 70 int arrayCount = kNonArray, GrSLPrecision precision = kDefault_G
rSLPrecision) |
71 : fType(type) | 71 : fType(type) |
72 , fTypeModifier(typeModifier) | 72 , fTypeModifier(typeModifier) |
73 , fName(name) | 73 , fName(name) |
74 , fCount(arrayCount) | 74 , fCount(arrayCount) |
75 , fPrecision(precision) { | 75 , fPrecision(precision) { |
76 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); | 76 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
77 SkASSERT(kVoid_GrSLType != type); | 77 SkASSERT(kVoid_GrSLType != type); |
78 } | 78 } |
79 | 79 |
80 /** | 80 /** |
81 * Values for array count that have special meaning. We allow 1-sized arrays
. | 81 * Values for array count that have special meaning. We allow 1-sized arrays
. |
82 */ | 82 */ |
83 enum { | 83 enum { |
84 kNonArray = 0, // not an array | 84 kNonArray = 0, // not an array |
85 kUnsizedArray = -1, // an unsized array (declared with []) | 85 kUnsizedArray = -1, // an unsized array (declared with []) |
86 }; | 86 }; |
87 | 87 |
88 /** | |
89 * Sets as a non-array. | |
90 */ | |
91 void set(GrSLType type, | 88 void set(GrSLType type, |
92 TypeModifier typeModifier, | |
93 const SkString& name, | 89 const SkString& name, |
94 GrSLPrecision precision = kDefault_GrSLPrecision) { | 90 TypeModifier typeModifier = kNone_TypeModifier, |
| 91 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 92 int count = kNonArray) { |
95 SkASSERT(kVoid_GrSLType != type); | 93 SkASSERT(kVoid_GrSLType != type); |
96 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); | 94 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
97 fType = type; | 95 fType = type; |
98 fTypeModifier = typeModifier; | |
99 fName = name; | |
100 fCount = kNonArray; | |
101 fPrecision = precision; | |
102 } | |
103 | |
104 /** | |
105 * Sets as a non-array. | |
106 */ | |
107 void set(GrSLType type, | |
108 TypeModifier typeModifier, | |
109 const char* name, | |
110 GrSLPrecision precision = kDefault_GrSLPrecision) { | |
111 SkASSERT(kVoid_GrSLType != type); | |
112 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); | |
113 fType = type; | |
114 fTypeModifier = typeModifier; | |
115 fName = name; | |
116 fCount = kNonArray; | |
117 fPrecision = precision; | |
118 } | |
119 | |
120 /** | |
121 * Set all var options | |
122 */ | |
123 void set(GrSLType type, | |
124 TypeModifier typeModifier, | |
125 const SkString& name, | |
126 int count, | |
127 GrSLPrecision precision = kDefault_GrSLPrecision) { | |
128 SkASSERT(kVoid_GrSLType != type); | |
129 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); | |
130 fType = type; | |
131 fTypeModifier = typeModifier; | 96 fTypeModifier = typeModifier; |
132 fName = name; | 97 fName = name; |
133 fCount = count; | 98 fCount = count; |
134 fPrecision = precision; | 99 fPrecision = precision; |
135 } | 100 } |
136 | 101 |
137 /** | |
138 * Set all var options | |
139 */ | |
140 void set(GrSLType type, | 102 void set(GrSLType type, |
141 TypeModifier typeModifier, | |
142 const char* name, | 103 const char* name, |
143 int count, | 104 TypeModifier typeModifier = kNone_TypeModifier, |
144 GrSLPrecision precision = kDefault_GrSLPrecision) { | 105 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 106 int count = kNonArray) { |
145 SkASSERT(kVoid_GrSLType != type); | 107 SkASSERT(kVoid_GrSLType != type); |
146 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); | 108 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); |
147 fType = type; | 109 fType = type; |
148 fTypeModifier = typeModifier; | 110 fTypeModifier = typeModifier; |
149 fName = name; | 111 fName = name; |
150 fCount = count; | 112 fCount = count; |
151 fPrecision = precision; | 113 fPrecision = precision; |
152 } | 114 } |
153 | 115 |
154 /** | 116 /** |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 182 |
221 protected: | 183 protected: |
222 GrSLType fType; | 184 GrSLType fType; |
223 TypeModifier fTypeModifier; | 185 TypeModifier fTypeModifier; |
224 SkString fName; | 186 SkString fName; |
225 int fCount; | 187 int fCount; |
226 GrSLPrecision fPrecision; | 188 GrSLPrecision fPrecision; |
227 }; | 189 }; |
228 | 190 |
229 #endif | 191 #endif |
OLD | NEW |