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

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

Issue 917373002: Use uint16s for texture coordinates when rendering text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use float uvs for distance field paths Created 5 years, 10 months 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 | « gyp/gpu.gypi ('k') | src/gpu/GrBitmapTextContext.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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 /** 109 /**
110 * Types used to describe format of vertices in arrays. 110 * Types used to describe format of vertices in arrays.
111 */ 111 */
112 enum GrVertexAttribType { 112 enum GrVertexAttribType {
113 kFloat_GrVertexAttribType = 0, 113 kFloat_GrVertexAttribType = 0,
114 kVec2f_GrVertexAttribType, 114 kVec2f_GrVertexAttribType,
115 kVec3f_GrVertexAttribType, 115 kVec3f_GrVertexAttribType,
116 kVec4f_GrVertexAttribType, 116 kVec4f_GrVertexAttribType,
117 117
118 kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage 118 kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage
119 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors 119 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors
120 120
121 kLast_GrVertexAttribType = kVec4ub_GrVertexAttribType 121 kVec2s_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinates
122
123 kLast_GrVertexAttribType = kVec2s_GrVertexAttribType
122 }; 124 };
123 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; 125 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
124 126
125 /** 127 /**
126 * Returns the vector size of the type. 128 * Returns the vector size of the type.
127 */ 129 */
128 static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { 130 static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) {
129 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); 131 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
130 static const int kCounts[] = { 1, 2, 3, 4, 1, 4 }; 132 static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2 };
131 return kCounts[type]; 133 return kCounts[type];
132 134
133 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); 135 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
134 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); 136 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
135 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); 137 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
136 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); 138 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
137 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); 139 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
138 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); 140 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
141 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
139 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount); 142 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount);
140 } 143 }
141 144
142 /** 145 /**
143 * Returns the size of the attrib type in bytes. 146 * Returns the size of the attrib type in bytes.
144 */ 147 */
145 static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { 148 static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
146 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); 149 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
147 static const size_t kSizes[] = { 150 static const size_t kSizes[] = {
148 sizeof(float), // kFloat_GrVertexAttribType 151 sizeof(float), // kFloat_GrVertexAttribType
149 2*sizeof(float), // kVec2f_GrVertexAttribType 152 2*sizeof(float), // kVec2f_GrVertexAttribType
150 3*sizeof(float), // kVec3f_GrVertexAttribType 153 3*sizeof(float), // kVec3f_GrVertexAttribType
151 4*sizeof(float), // kVec4f_GrVertexAttribType 154 4*sizeof(float), // kVec4f_GrVertexAttribType
152 1*sizeof(char), // kUByte_GrVertexAttribType 155 1*sizeof(char), // kUByte_GrVertexAttribType
153 4*sizeof(char) // kVec4ub_GrVertexAttribType 156 4*sizeof(char), // kVec4ub_GrVertexAttribType
157 2*sizeof(int16_t) // kVec2s_GrVertexAttribType
154 }; 158 };
155 return kSizes[type]; 159 return kSizes[type];
156 160
157 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); 161 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
158 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); 162 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
159 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); 163 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
160 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); 164 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
161 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); 165 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
162 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); 166 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
167 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
163 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); 168 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount);
164 } 169 }
165 170
166 /** 171 /**
167 * converts a GrVertexAttribType to a GrSLType 172 * converts a GrVertexAttribType to a GrSLType
168 */ 173 */
169 static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) { 174 static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) {
170 switch (type) { 175 switch (type) {
171 default: 176 default:
172 SkFAIL("Unsupported type conversion"); 177 SkFAIL("Unsupported type conversion");
173 case kUByte_GrVertexAttribType: 178 case kUByte_GrVertexAttribType:
174 case kFloat_GrVertexAttribType: 179 case kFloat_GrVertexAttribType:
175 return kFloat_GrSLType; 180 return kFloat_GrSLType;
181 case kVec2s_GrVertexAttribType:
176 case kVec2f_GrVertexAttribType: 182 case kVec2f_GrVertexAttribType:
177 return kVec2f_GrSLType; 183 return kVec2f_GrSLType;
178 case kVec3f_GrVertexAttribType: 184 case kVec3f_GrVertexAttribType:
179 return kVec3f_GrSLType; 185 return kVec3f_GrSLType;
180 case kVec4ub_GrVertexAttribType: 186 case kVec4ub_GrVertexAttribType:
181 case kVec4f_GrVertexAttribType: 187 case kVec4f_GrVertexAttribType:
182 return kVec4f_GrSLType; 188 return kVec4f_GrSLType;
183 } 189 }
184 } 190 }
185 191
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 258
253 bool enabled() const { return fEnabled; } 259 bool enabled() const { return fEnabled; }
254 const SkIRect& rect() const { return fRect; } 260 const SkIRect& rect() const { return fRect; }
255 261
256 private: 262 private:
257 bool fEnabled; 263 bool fEnabled;
258 SkIRect fRect; 264 SkIRect fRect;
259 }; 265 };
260 266
261 #endif 267 #endif
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/GrBitmapTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698