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

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

Issue 511593004: Make setVertexAttribs in GrDrawState take a stride parameter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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
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 #include "GrDistanceFieldTextContext.h" 8 #include "GrDistanceFieldTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 335 }
336 336
337 bool useColorVerts = !fUseLCDText; 337 bool useColorVerts = !fUseLCDText;
338 338
339 if (NULL == fVertices) { 339 if (NULL == fVertices) {
340 // If we need to reserve vertices allow the draw target to suggest 340 // If we need to reserve vertices allow the draw target to suggest
341 // a number of verts to reserve and whether to perform a flush. 341 // a number of verts to reserve and whether to perform a flush.
342 fMaxVertices = kMinRequestedVerts; 342 fMaxVertices = kMinRequestedVerts;
343 if (useColorVerts) { 343 if (useColorVerts) {
344 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttri bs>( 344 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttri bs>(
345 SK_ARRAY_COUNT(gTextVertexWi thColorAttribs)); 345 SK_ARRAY_COUNT(gTextVertexWi thColorAttribs),
346 2 * sizeof(SkPoint) + sizeof (GrColor));
346 } else { 347 } else {
347 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( 348 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
348 SK_ARRAY_COUNT(gTextVertexAt tribs)); 349 SK_ARRAY_COUNT(gTextVertexAt tribs),
350 2 * sizeof(SkPoint));
349 } 351 }
350 bool flush = fDrawTarget->geometryHints(&fMaxVertices, NULL); 352 bool flush = fDrawTarget->geometryHints(&fMaxVertices, NULL);
351 if (flush) { 353 if (flush) {
352 this->flushGlyphs(); 354 this->flushGlyphs();
353 fContext->flush(); 355 fContext->flush();
354 if (useColorVerts) { 356 if (useColorVerts) {
355 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorA ttribs>( 357 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorA ttribs>(
356 SK_ARRAY_COUNT(gTextVertexWi thColorAttribs)); 358 SK_ARRAY_COUNT(gTextVertexWi thColorAttribs),
359 2 * sizeof(SkPoint) + sizeof (GrColor));
357 } else { 360 } else {
358 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( 361 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
359 SK_ARRAY_COUNT(gTextVertexAt tribs)); 362 SK_ARRAY_COUNT(gTextVertexAt tribs),
363 2 * sizeof(SkPoint));
360 } 364 }
361 } 365 }
362 fMaxVertices = kDefaultRequestedVerts; 366 fMaxVertices = kDefaultRequestedVerts;
363 // ignore return, no point in flushing again. 367 // ignore return, no point in flushing again.
364 fDrawTarget->geometryHints(&fMaxVertices, NULL); 368 fDrawTarget->geometryHints(&fMaxVertices, NULL);
365 369
366 int maxQuadVertices = 4 * fContext->getQuadIndexBuffer()->maxQuads(); 370 int maxQuadVertices = 4 * fContext->getQuadIndexBuffer()->maxQuads();
367 if (fMaxVertices < kMinRequestedVerts) { 371 if (fMaxVertices < kMinRequestedVerts) {
368 fMaxVertices = kDefaultRequestedVerts; 372 fMaxVertices = kDefaultRequestedVerts;
369 } else if (fMaxVertices > maxQuadVertices) { 373 } else if (fMaxVertices > maxQuadVertices) {
(...skipping 29 matching lines...) Expand all
399 r.fLeft = sx; 403 r.fLeft = sx;
400 r.fTop = sy; 404 r.fTop = sy;
401 r.fRight = sx + width; 405 r.fRight = sx + width;
402 r.fBottom = sy + height; 406 r.fBottom = sy + height;
403 407
404 fVertexBounds.growToInclude(r); 408 fVertexBounds.growToInclude(r);
405 409
406 size_t vertSize = fUseLCDText ? (2 * sizeof(SkPoint)) 410 size_t vertSize = fUseLCDText ? (2 * sizeof(SkPoint))
407 : (2 * sizeof(SkPoint) + sizeof(GrColor)); 411 : (2 * sizeof(SkPoint) + sizeof(GrColor));
408 412
409 SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexSize()); 413 SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexStride());
410 414
411 SkPoint* positions = reinterpret_cast<SkPoint*>( 415 SkPoint* positions = reinterpret_cast<SkPoint*>(
412 reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex); 416 reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex);
413 positions->setRectFan(r.fLeft, r.fTop, r.fRight, r.fBottom, vertSize); 417 positions->setRectFan(r.fLeft, r.fTop, r.fRight, r.fBottom, vertSize);
414 418
415 // The texture coords are last in both the with and without color vertex lay outs. 419 // The texture coords are last in both the with and without color vertex lay outs.
416 SkPoint* textureCoords = reinterpret_cast<SkPoint*>( 420 SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
417 reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint)) ; 421 reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint)) ;
418 textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)), 422 textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)),
419 SkFixedToFloat(texture->normalizeFixedY(ty)), 423 SkFixedToFloat(texture->normalizeFixedY(ty)),
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 SkScalarToFixed(x) - (glyph.fAdvanceX >> a lignShift), 648 SkScalarToFixed(x) - (glyph.fAdvanceX >> a lignShift),
645 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift), 649 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift),
646 fontScaler); 650 fontScaler);
647 } 651 }
648 pos += scalarsPerPosition; 652 pos += scalarsPerPosition;
649 } 653 }
650 } 654 }
651 655
652 this->finish(); 656 this->finish();
653 } 657 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698