| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 , fPrecision(kDefault_GrSLPrecision) { | 44 , fPrecision(kDefault_GrSLPrecision) { |
| 45 } | 45 } |
| 46 | 46 |
| 47 GrShaderVar(const SkString& name, GrSLType type, int arrayCount = kNonArray, | 47 GrShaderVar(const SkString& name, GrSLType type, int arrayCount = kNonArray, |
| 48 GrSLPrecision precision = kDefault_GrSLPrecision) | 48 GrSLPrecision precision = kDefault_GrSLPrecision) |
| 49 : fType(type) | 49 : fType(type) |
| 50 , fTypeModifier(kNone_TypeModifier) | 50 , fTypeModifier(kNone_TypeModifier) |
| 51 , fName(name) | 51 , fName(name) |
| 52 , fCount(arrayCount) | 52 , fCount(arrayCount) |
| 53 , fPrecision(precision) { | 53 , fPrecision(precision) { |
| 54 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); | 54 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type))
; |
| 55 SkASSERT(kVoid_GrSLType != type); | 55 SkASSERT(kVoid_GrSLType != type); |
| 56 } | 56 } |
| 57 | 57 |
| 58 GrShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray, | 58 GrShaderVar(const char* name, GrSLType type, int arrayCount = kNonArray, |
| 59 GrSLPrecision precision = kDefault_GrSLPrecision) | 59 GrSLPrecision precision = kDefault_GrSLPrecision) |
| 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 || GrSLTypeIsNumeric(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_G
rSLPrecision) | 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 || GrSLTypeIsNumeric(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 void set(GrSLType type, | 88 void set(GrSLType type, |
| 89 const SkString& name, | 89 const SkString& name, |
| 90 TypeModifier typeModifier = kNone_TypeModifier, | 90 TypeModifier typeModifier = kNone_TypeModifier, |
| 91 GrSLPrecision precision = kDefault_GrSLPrecision, | 91 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 92 int count = kNonArray) { | 92 int count = kNonArray) { |
| 93 SkASSERT(kVoid_GrSLType != type); | 93 SkASSERT(kVoid_GrSLType != type); |
| 94 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); | 94 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type))
; |
| 95 fType = type; | 95 fType = type; |
| 96 fTypeModifier = typeModifier; | 96 fTypeModifier = typeModifier; |
| 97 fName = name; | 97 fName = name; |
| 98 fCount = count; | 98 fCount = count; |
| 99 fPrecision = precision; | 99 fPrecision = precision; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void set(GrSLType type, | 102 void set(GrSLType type, |
| 103 const char* name, | 103 const char* name, |
| 104 TypeModifier typeModifier = kNone_TypeModifier, | 104 TypeModifier typeModifier = kNone_TypeModifier, |
| 105 GrSLPrecision precision = kDefault_GrSLPrecision, | 105 GrSLPrecision precision = kDefault_GrSLPrecision, |
| 106 int count = kNonArray) { | 106 int count = kNonArray) { |
| 107 SkASSERT(kVoid_GrSLType != type); | 107 SkASSERT(kVoid_GrSLType != type); |
| 108 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type
)); | 108 SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsNumeric(type))
; |
| 109 fType = type; | 109 fType = type; |
| 110 fTypeModifier = typeModifier; | 110 fTypeModifier = typeModifier; |
| 111 fName = name; | 111 fName = name; |
| 112 fCount = count; | 112 fCount = count; |
| 113 fPrecision = precision; | 113 fPrecision = precision; |
| 114 } | 114 } |
| 115 | 115 |
| 116 /** | 116 /** |
| 117 * Is the var an array. | 117 * Is the var an array. |
| 118 */ | 118 */ |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 protected: | 183 protected: |
| 184 GrSLType fType; | 184 GrSLType fType; |
| 185 TypeModifier fTypeModifier; | 185 TypeModifier fTypeModifier; |
| 186 SkString fName; | 186 SkString fName; |
| 187 int fCount; | 187 int fCount; |
| 188 GrSLPrecision fPrecision; | 188 GrSLPrecision fPrecision; |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 #endif | 191 #endif |
| OLD | NEW |