Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(939)

Side by Side Diff: include/gpu/GrTypesPriv.h

Issue 649783003: Force input coverage to be only a byte in gpu shaders. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrAAHairLinePathRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 GrTypesPriv_DEFINED 8 #ifndef GrTypesPriv_DEFINED
9 #define GrTypesPriv_DEFINED 9 #define GrTypesPriv_DEFINED
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 ////////////////////////////////////////////////////////////////////////////// 63 //////////////////////////////////////////////////////////////////////////////
64 64
65 /** 65 /**
66 * Types used to describe format of vertices in arrays. 66 * Types used to describe format of vertices in arrays.
67 */ 67 */
68 enum GrVertexAttribType { 68 enum GrVertexAttribType {
69 kFloat_GrVertexAttribType = 0, 69 kFloat_GrVertexAttribType = 0,
70 kVec2f_GrVertexAttribType, 70 kVec2f_GrVertexAttribType,
71 kVec3f_GrVertexAttribType, 71 kVec3f_GrVertexAttribType,
72 kVec4f_GrVertexAttribType, 72 kVec4f_GrVertexAttribType,
73
74 kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage
73 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors 75 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors
74 76
75 kLast_GrVertexAttribType = kVec4ub_GrVertexAttribType 77 kLast_GrVertexAttribType = kVec4ub_GrVertexAttribType
76 }; 78 };
77 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; 79 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
78 80
79 /** 81 /**
80 * Returns the vector size of the type. 82 * Returns the vector size of the type.
81 */ 83 */
82 static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { 84 static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) {
83 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); 85 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
84 static const int kCounts[] = { 1, 2, 3, 4, 4 }; 86 static const int kCounts[] = { 1, 2, 3, 4, 1, 4 };
85 return kCounts[type]; 87 return kCounts[type];
86 88
87 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); 89 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
88 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); 90 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
89 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); 91 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
90 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); 92 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
91 GR_STATIC_ASSERT(4 == kVec4ub_GrVertexAttribType); 93 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
94 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
92 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount); 95 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount);
93 } 96 }
94 97
95 /** 98 /**
96 * Returns the size of the attrib type in bytes. 99 * Returns the size of the attrib type in bytes.
97 */ 100 */
98 static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { 101 static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
99 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); 102 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
100 static const size_t kSizes[] = { 103 static const size_t kSizes[] = {
101 sizeof(float), // kFloat_GrVertexAttribType 104 sizeof(float), // kFloat_GrVertexAttribType
102 2*sizeof(float), // kVec2f_GrVertexAttribType 105 2*sizeof(float), // kVec2f_GrVertexAttribType
103 3*sizeof(float), // kVec3f_GrVertexAttribType 106 3*sizeof(float), // kVec3f_GrVertexAttribType
104 4*sizeof(float), // kVec4f_GrVertexAttribType 107 4*sizeof(float), // kVec4f_GrVertexAttribType
108 1*sizeof(char), // kUByte_GrVertexAttribType
105 4*sizeof(char) // kVec4ub_GrVertexAttribType 109 4*sizeof(char) // kVec4ub_GrVertexAttribType
106 }; 110 };
107 return kSizes[type]; 111 return kSizes[type];
108 112
109 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); 113 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
110 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); 114 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
111 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); 115 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
112 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); 116 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
113 GR_STATIC_ASSERT(4 == kVec4ub_GrVertexAttribType); 117 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
118 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
114 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); 119 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount);
115 } 120 }
116 121
117 /** 122 /**
118 * Semantic bindings for vertex attributes. kEffect means that the attribute is input to a 123 * Semantic bindings for vertex attributes. kEffect means that the attribute is input to a
119 * GrProcessor. Each binding other than kEffect may not appear more than once in the current set of 124 * GrProcessor. Each binding other than kEffect may not appear more than once in the current set of
120 * attributes. kPosition must be appear for exactly one attribute. 125 * attributes. kPosition must be appear for exactly one attribute.
121 */ 126 */
122 enum GrVertexAttribBinding { 127 enum GrVertexAttribBinding {
123 kPosition_GrVertexAttribBinding, // required, must have vector count of 2 128 kPosition_GrVertexAttribBinding, // required, must have vector count of 2
124 kLocalCoord_GrVertexAttribBinding, // must have vector count of 2 129 kLocalCoord_GrVertexAttribBinding, // must have vector count of 2
125 kColor_GrVertexAttribBinding, // must have vector count of 4 130 kColor_GrVertexAttribBinding, // must have vector count of 4
126 kCoverage_GrVertexAttribBinding, // must have vector count of 4 131 kCoverage_GrVertexAttribBinding, // must have a single byte
127 132
128 kLastFixedFunction_GrVertexAttribBinding = kCoverage_GrVertexAttribBinding, 133 kLastFixedFunction_GrVertexAttribBinding = kCoverage_GrVertexAttribBinding,
129 134
130 kGeometryProcessor_GrVertexAttribBinding, // vector length must agree w ith 135 kGeometryProcessor_GrVertexAttribBinding, // vector length must agree w ith
131 // GrProcessor::vertexAttribType() for e ach effect input to 136 // GrProcessor::vertexAttribType() for e ach effect input to
132 // which the attribute is mapped by GrDr awState::setEffect() 137 // which the attribute is mapped by GrDr awState::setEffect()
133 kLast_GrVertexAttribBinding = kGeometryProcessor_GrVertexAttribBinding 138 kLast_GrVertexAttribBinding = kGeometryProcessor_GrVertexAttribBinding
134 }; 139 };
135 140
136 static const int kGrVertexAttribBindingCnt = kLast_GrVertexAttribBinding + 1; 141 static const int kGrVertexAttribBindingCnt = kLast_GrVertexAttribBinding + 1;
137 static const int kGrFixedFunctionVertexAttribBindingCnt = 142 static const int kGrFixedFunctionVertexAttribBindingCnt =
138 kLastFixedFunction_GrVertexAttribBinding + 1; 143 kLastFixedFunction_GrVertexAttribBinding + 1;
139 144
140 static inline int GrFixedFunctionVertexAttribVectorCount(GrVertexAttribBinding b inding) { 145 static inline int GrFixedFunctionVertexAttribVectorCount(GrVertexAttribBinding b inding) {
141 SkASSERT(binding >= 0 && binding < kGrFixedFunctionVertexAttribBindingCnt); 146 SkASSERT(binding >= 0 && binding < kGrFixedFunctionVertexAttribBindingCnt);
142 static const int kVecCounts[] = { 2, 2, 4, 4 }; 147 static const int kVecCounts[] = { 2, 2, 4, 1 };
143 148
144 return kVecCounts[binding]; 149 return kVecCounts[binding];
145 150
146 GR_STATIC_ASSERT(0 == kPosition_GrVertexAttribBinding); 151 GR_STATIC_ASSERT(0 == kPosition_GrVertexAttribBinding);
147 GR_STATIC_ASSERT(1 == kLocalCoord_GrVertexAttribBinding); 152 GR_STATIC_ASSERT(1 == kLocalCoord_GrVertexAttribBinding);
148 GR_STATIC_ASSERT(2 == kColor_GrVertexAttribBinding); 153 GR_STATIC_ASSERT(2 == kColor_GrVertexAttribBinding);
149 GR_STATIC_ASSERT(3 == kCoverage_GrVertexAttribBinding); 154 GR_STATIC_ASSERT(3 == kCoverage_GrVertexAttribBinding);
150 GR_STATIC_ASSERT(kGrFixedFunctionVertexAttribBindingCnt == SK_ARRAY_COUNT(kV ecCounts)); 155 GR_STATIC_ASSERT(kGrFixedFunctionVertexAttribBindingCnt == SK_ARRAY_COUNT(kV ecCounts));
151 } 156 }
152 157
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 /** 225 /**
221 * Indicates the type of pending IO operations that can be recorded for gpu reso urces. 226 * Indicates the type of pending IO operations that can be recorded for gpu reso urces.
222 */ 227 */
223 enum GrIOType { 228 enum GrIOType {
224 kRead_GrIOType, 229 kRead_GrIOType,
225 kWrite_GrIOType, 230 kWrite_GrIOType,
226 kRW_GrIOType 231 kRW_GrIOType
227 }; 232 };
228 233
229 #endif 234 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAAHairLinePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698