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

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

Issue 502533004: Revert of 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
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawState.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 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 26 matching lines...) Expand all
37 static const int kMediumDFFontLimit = 64; 37 static const int kMediumDFFontLimit = 64;
38 static const int kLargeDFFontSize = 128; 38 static const int kLargeDFFontSize = 128;
39 39
40 namespace { 40 namespace {
41 // position + texture coord 41 // position + texture coord
42 extern const GrVertexAttrib gTextVertexAttribs[] = { 42 extern const GrVertexAttrib gTextVertexAttribs[] = {
43 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindin g}, 43 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindin g},
44 {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding} 44 {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kEffect_GrVertexAttribBinding}
45 }; 45 };
46 46
47 static const size_t kTextVASize = 2 * sizeof(SkPoint);
48
49 // position + color + texture coord 47 // position + color + texture coord
50 extern const GrVertexAttrib gTextVertexWithColorAttribs[] = { 48 extern const GrVertexAttrib gTextVertexWithColorAttribs[] = {
51 {kVec2f_GrVertexAttribType, 0, kPosition_Gr VertexAttribBinding}, 49 {kVec2f_GrVertexAttribType, 0, kPosition_Gr VertexAttribBinding},
52 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer texAttribBinding}, 50 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer texAttribBinding},
53 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVe rtexAttribBinding} 51 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kEffect_GrVe rtexAttribBinding}
54 }; 52 };
55 53
56 static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor);
57
58 }; 54 };
59 55
60 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, 56 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context,
61 const SkDeviceProperties& properties, 57 const SkDeviceProperties& properties,
62 bool enable) 58 bool enable)
63 : GrTextContext(context, pro perties) 59 : GrTextContext(context, pro perties)
64 , fStrike(NULL) 60 , fStrike(NULL)
65 #if SK_FORCE_DISTANCEFIELD_FONTS 61 #if SK_FORCE_DISTANCEFIELD_FONTS
66 , fEnableDFRendering(true) 62 , fEnableDFRendering(true)
67 #else 63 #else
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 r.fLeft = sx; 348 r.fLeft = sx;
353 r.fTop = sy; 349 r.fTop = sy;
354 r.fRight = sx + width; 350 r.fRight = sx + width;
355 r.fBottom = sy + height; 351 r.fBottom = sy + height;
356 352
357 fVertexBounds.growToInclude(r); 353 fVertexBounds.growToInclude(r);
358 354
359 size_t vertSize = fUseLCDText ? (2 * sizeof(SkPoint)) 355 size_t vertSize = fUseLCDText ? (2 * sizeof(SkPoint))
360 : (2 * sizeof(SkPoint) + sizeof(GrColor)); 356 : (2 * sizeof(SkPoint) + sizeof(GrColor));
361 357
362 SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexStride()); 358 SkASSERT(vertSize == fDrawTarget->getDrawState().getVertexSize());
363 359
364 SkPoint* positions = reinterpret_cast<SkPoint*>( 360 SkPoint* positions = reinterpret_cast<SkPoint*>(
365 reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex); 361 reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex);
366 positions->setRectFan(r.fLeft, r.fTop, r.fRight, r.fBottom, vertSize); 362 positions->setRectFan(r.fLeft, r.fTop, r.fRight, r.fBottom, vertSize);
367 363
368 // The texture coords are last in both the with and without color vertex lay outs. 364 // The texture coords are last in both the with and without color vertex lay outs.
369 SkPoint* textureCoords = reinterpret_cast<SkPoint*>( 365 SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
370 reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint)) ; 366 reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint)) ;
371 textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)), 367 textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)),
372 SkFixedToFloat(texture->normalizeFixedY(ty)), 368 SkFixedToFloat(texture->normalizeFixedY(ty)),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 0, 0, width, height, 456 0, 0, width, height,
461 (*gammaTexture)->config(), data.get(), 0, 457 (*gammaTexture)->config(), data.get(), 0,
462 GrContext::kDontFlush_PixelOpsFlag); 458 GrContext::kDontFlush_PixelOpsFlag);
463 } 459 }
464 } 460 }
465 461
466 void GrDistanceFieldTextContext::allocateVertices(const char text[], size_t byte Length) { 462 void GrDistanceFieldTextContext::allocateVertices(const char text[], size_t byte Length) {
467 SkASSERT(NULL == fVertices); 463 SkASSERT(NULL == fVertices);
468 if (!fUseLCDText) { 464 if (!fUseLCDText) {
469 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>( 465 fDrawTarget->drawState()->setVertexAttribs<gTextVertexWithColorAttribs>(
470 SK_ARRAY_COUNT(gTextVertexWi thColorAttribs), 466 SK_ARRAY_COUNT(gTextVertexWi thColorAttribs));
471 kTextVAColorSize);
472 } else { 467 } else {
473 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>( 468 fDrawTarget->drawState()->setVertexAttribs<gTextVertexAttribs>(
474 SK_ARRAY_COUNT(gTextVertexAt tribs), 469 SK_ARRAY_COUNT(gTextVertexAt tribs));
475 kTextVASize);
476 } 470 }
477 fVertexCount = 4*fSkPaint.textToGlyphs(text, byteLength, NULL); 471 fVertexCount = 4*fSkPaint.textToGlyphs(text, byteLength, NULL);
478 bool success = fDrawTarget->reserveVertexAndIndexSpace(fVertexCount, 472 bool success = fDrawTarget->reserveVertexAndIndexSpace(fVertexCount,
479 0, 473 0,
480 &fVertices, 474 &fVertices,
481 NULL); 475 NULL);
482 GrAlwaysAssert(success); 476 GrAlwaysAssert(success);
483 } 477 }
484 478
485 void GrDistanceFieldTextContext::drawText(const GrPaint& paint, const SkPaint& s kPaint, 479 void GrDistanceFieldTextContext::drawText(const GrPaint& paint, const SkPaint& s kPaint,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 SkScalarToFixed(x) - (glyph.fAdvanceX >> a lignShift), 628 SkScalarToFixed(x) - (glyph.fAdvanceX >> a lignShift),
635 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift), 629 SkScalarToFixed(y) - (glyph.fAdvanceY >> a lignShift),
636 fontScaler); 630 fontScaler);
637 } 631 }
638 pos += scalarsPerPosition; 632 pos += scalarsPerPosition;
639 } 633 }
640 } 634 }
641 635
642 this->finish(); 636 this->finish();
643 } 637 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698