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

Side by Side Diff: src/gpu/GrTextContext.cpp

Issue 13296005: Revise attribute binding interface (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fix fExperimentalGS in GrGLProgramDesc Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/gl/GrGLProgram.h » ('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 2010 Google Inc. 2 * Copyright 2010 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 8
9 9
10 #include "GrTextContext.h" 10 #include "GrTextContext.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 if (fCurrTexture != texture || fCurrVertex + 4 > fMaxVertices) { 188 if (fCurrTexture != texture || fCurrVertex + 4 > fMaxVertices) {
189 this->flushGlyphs(); 189 this->flushGlyphs();
190 fCurrTexture = texture; 190 fCurrTexture = texture;
191 fCurrTexture->ref(); 191 fCurrTexture->ref();
192 } 192 }
193 193
194 if (NULL == fVertices) { 194 if (NULL == fVertices) {
195 // position + texture coord 195 // position + texture coord
196 static const GrVertexAttrib kVertexAttribs[] = { 196 static const GrVertexAttrib kVertexAttribs[] = {
197 {kVec2f_GrVertexAttribType, 0}, 197 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttri bBinding},
198 {kVec2f_GrVertexAttribType, sizeof(GrPoint)} 198 {kVec2f_GrVertexAttribType, sizeof(GrPoint), kEffect_GrVertexAttribB inding}
199 }; 199 };
200 static const GrAttribBindings kAttribBindings = 0;
201 200
202 // If we need to reserve vertices allow the draw target to suggest 201 // If we need to reserve vertices allow the draw target to suggest
203 // a number of verts to reserve and whether to perform a flush. 202 // a number of verts to reserve and whether to perform a flush.
204 fMaxVertices = kMinRequestedVerts; 203 fMaxVertices = kMinRequestedVerts;
205 bool flush = false; 204 bool flush = false;
206 fDrawTarget = fContext->getTextTarget(fPaint); 205 fDrawTarget = fContext->getTextTarget(fPaint);
207 if (NULL != fDrawTarget) { 206 if (NULL != fDrawTarget) {
208 fDrawTarget->drawState()->setVertexAttribs(kVertexAttribs, SK_ARRAY_ COUNT(kVertexAttribs)); 207 fDrawTarget->drawState()->setVertexAttribs(kVertexAttribs, SK_ARRAY_ COUNT(kVertexAttribs));
209 flush = fDrawTarget->geometryHints(&fMaxVertices, NULL); 208 flush = fDrawTarget->geometryHints(&fMaxVertices, NULL);
210 } 209 }
211 if (flush) { 210 if (flush) {
212 this->flushGlyphs(); 211 this->flushGlyphs();
213 fContext->flush(); 212 fContext->flush();
214 // flushGlyphs() will reset fDrawTarget to NULL. 213 // flushGlyphs() will reset fDrawTarget to NULL.
215 fDrawTarget = fContext->getTextTarget(fPaint); 214 fDrawTarget = fContext->getTextTarget(fPaint);
216 fDrawTarget->drawState()->setVertexAttribs(kVertexAttribs, SK_ARRAY_ COUNT(kVertexAttribs)); 215 fDrawTarget->drawState()->setVertexAttribs(kVertexAttribs, SK_ARRAY_ COUNT(kVertexAttribs));
217 } 216 }
218 fDrawTarget->drawState()->setAttribIndex(GrDrawState::kPosition_AttribIn dex, 0);
219 fDrawTarget->drawState()->setAttribBindings(kAttribBindings);
220 fMaxVertices = kDefaultRequestedVerts; 217 fMaxVertices = kDefaultRequestedVerts;
221 // ignore return, no point in flushing again. 218 // ignore return, no point in flushing again.
222 fDrawTarget->geometryHints(&fMaxVertices, NULL); 219 fDrawTarget->geometryHints(&fMaxVertices, NULL);
223 220
224 int maxQuadVertices = 4 * fContext->getQuadIndexBuffer()->maxQuads(); 221 int maxQuadVertices = 4 * fContext->getQuadIndexBuffer()->maxQuads();
225 if (fMaxVertices < kMinRequestedVerts) { 222 if (fMaxVertices < kMinRequestedVerts) {
226 fMaxVertices = kDefaultRequestedVerts; 223 fMaxVertices = kDefaultRequestedVerts;
227 } else if (fMaxVertices > maxQuadVertices) { 224 } else if (fMaxVertices > maxQuadVertices) {
228 // don't exceed the limit of the index buffer 225 // don't exceed the limit of the index buffer
229 fMaxVertices = maxQuadVertices; 226 fMaxVertices = maxQuadVertices;
(...skipping 15 matching lines...) Expand all
245 SkFixedToFloat(vx + width), 242 SkFixedToFloat(vx + width),
246 SkFixedToFloat(vy + height), 243 SkFixedToFloat(vy + height),
247 2 * sizeof(SkPoint)); 244 2 * sizeof(SkPoint));
248 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed X(tx)), 245 fVertices[2*fCurrVertex+1].setRectFan(SkFixedToFloat(texture->normalizeFixed X(tx)),
249 SkFixedToFloat(texture->normalizeFixed Y(ty)), 246 SkFixedToFloat(texture->normalizeFixed Y(ty)),
250 SkFixedToFloat(texture->normalizeFixed X(tx + width)), 247 SkFixedToFloat(texture->normalizeFixed X(tx + width)),
251 SkFixedToFloat(texture->normalizeFixed Y(ty + height)), 248 SkFixedToFloat(texture->normalizeFixed Y(ty + height)),
252 2 * sizeof(SkPoint)); 249 2 * sizeof(SkPoint));
253 fCurrVertex += 4; 250 fCurrVertex += 4;
254 } 251 }
OLDNEW
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/gl/GrGLProgram.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698