OLD | NEW |
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 "GrBitmapTextContext.h" | 10 #include "GrBitmapTextContext.h" |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 const SkMatrix& ctm = fContext->getMatrix(); | 512 const SkMatrix& ctm = fContext->getMatrix(); |
513 (void) ctm.mapRect(&dstRect, glyphRect); | 513 (void) ctm.mapRect(&dstRect, glyphRect); |
514 if (fClipRect.quickReject(SkScalarTruncToInt(dstRect.left()), | 514 if (fClipRect.quickReject(SkScalarTruncToInt(dstRect.left()), |
515 SkScalarTruncToInt(dstRect.top()), | 515 SkScalarTruncToInt(dstRect.top()), |
516 SkScalarTruncToInt(dstRect.right()), | 516 SkScalarTruncToInt(dstRect.right()), |
517 SkScalarTruncToInt(dstRect.bottom()))) { | 517 SkScalarTruncToInt(dstRect.bottom()))) { |
518 // SkCLZ(3); // so we can set a break-point in the debugger | 518 // SkCLZ(3); // so we can set a break-point in the debugger |
519 return true; | 519 return true; |
520 } | 520 } |
521 | 521 |
522 if (NULL == glyph->fPlot && !uploadGlyph(glyph, scaler)) { | 522 if (NULL == glyph->fPlot) { |
523 if (NULL == glyph->fPath) { | 523 // needs to be a separate conditional to avoid over-optimization |
524 SkPath* path = SkNEW(SkPath); | 524 // on Nexus 7 and Nexus 10 |
525 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { | 525 if (!uploadGlyph(glyph, scaler)) { |
526 // flag the glyph as being dead? | 526 if (NULL == glyph->fPath) { |
527 delete path; | 527 SkPath* path = SkNEW(SkPath); |
528 return true; | 528 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { |
| 529 // flag the glyph as being dead? |
| 530 delete path; |
| 531 return true; |
| 532 } |
| 533 glyph->fPath = path; |
529 } | 534 } |
530 glyph->fPath = path; | 535 |
| 536 // flush any accumulated draws before drawing this glyph as a path. |
| 537 this->flush(); |
| 538 |
| 539 GrContext::AutoMatrix am; |
| 540 SkMatrix ctm; |
| 541 ctm.setScale(fTextRatio, fTextRatio); |
| 542 ctm.postTranslate(sx - dx, sy - dy); |
| 543 GrPaint tmpPaint(fPaint); |
| 544 am.setPreConcat(fContext, ctm, &tmpPaint); |
| 545 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); |
| 546 fContext->drawPath(tmpPaint, *glyph->fPath, strokeInfo); |
| 547 |
| 548 // remove this glyph from the vertices we need to allocate |
| 549 fTotalVertexCount -= kVerticesPerGlyph; |
| 550 return true; |
531 } | 551 } |
532 | |
533 // flush any accumulated draws before drawing this glyph as a path. | |
534 this->flush(); | |
535 | |
536 GrContext::AutoMatrix am; | |
537 SkMatrix ctm; | |
538 ctm.setScale(fTextRatio, fTextRatio); | |
539 ctm.postTranslate(sx - dx, sy - dy); | |
540 GrPaint tmpPaint(fPaint); | |
541 am.setPreConcat(fContext, ctm, &tmpPaint); | |
542 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); | |
543 fContext->drawPath(tmpPaint, *glyph->fPath, strokeInfo); | |
544 | |
545 // remove this glyph from the vertices we need to allocate | |
546 fTotalVertexCount -= kVerticesPerGlyph; | |
547 return true; | |
548 } | 552 } |
549 | 553 |
550 SkASSERT(glyph->fPlot); | 554 SkASSERT(glyph->fPlot); |
551 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); | 555 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); |
552 glyph->fPlot->setDrawToken(drawToken); | 556 glyph->fPlot->setDrawToken(drawToken); |
553 | 557 |
554 GrTexture* texture = glyph->fPlot->texture(); | 558 GrTexture* texture = glyph->fPlot->texture(); |
555 SkASSERT(texture); | 559 SkASSERT(texture); |
556 | 560 |
557 if (fCurrTexture != texture || fCurrVertex + kVerticesPerGlyph > fTotalVerte
xCount) { | 561 if (fCurrTexture != texture || fCurrVertex + kVerticesPerGlyph > fTotalVerte
xCount) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 } | 682 } |
679 } | 683 } |
680 | 684 |
681 inline void GrDistanceFieldTextContext::finish() { | 685 inline void GrDistanceFieldTextContext::finish() { |
682 this->flush(); | 686 this->flush(); |
683 fTotalVertexCount = 0; | 687 fTotalVertexCount = 0; |
684 | 688 |
685 GrTextContext::finish(); | 689 GrTextContext::finish(); |
686 } | 690 } |
687 | 691 |
OLD | NEW |