| 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 SkScalarTruncToInt(dstRect.top()), | 528 SkScalarTruncToInt(dstRect.top()), |
| 529 SkScalarTruncToInt(dstRect.right()), | 529 SkScalarTruncToInt(dstRect.right()), |
| 530 SkScalarTruncToInt(dstRect.bottom()))) { | 530 SkScalarTruncToInt(dstRect.bottom()))) { |
| 531 // SkCLZ(3); // so we can set a break-point in the debugger | 531 // SkCLZ(3); // so we can set a break-point in the debugger |
| 532 return true; | 532 return true; |
| 533 } | 533 } |
| 534 | 534 |
| 535 if (NULL == glyph->fPlot) { | 535 if (NULL == glyph->fPlot) { |
| 536 // needs to be a separate conditional to avoid over-optimization | 536 // needs to be a separate conditional to avoid over-optimization |
| 537 // on Nexus 7 and Nexus 10 | 537 // on Nexus 7 and Nexus 10 |
| 538 |
| 539 // If the glyph is too large we fall back to paths |
| 538 if (!uploadGlyph(glyph, scaler)) { | 540 if (!uploadGlyph(glyph, scaler)) { |
| 539 if (NULL == glyph->fPath) { | 541 if (NULL == glyph->fPath) { |
| 540 SkPath* path = SkNEW(SkPath); | 542 SkPath* path = SkNEW(SkPath); |
| 541 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { | 543 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { |
| 542 // flag the glyph as being dead? | 544 // flag the glyph as being dead? |
| 543 delete path; | 545 delete path; |
| 544 return true; | 546 return true; |
| 545 } | 547 } |
| 546 glyph->fPath = path; | 548 glyph->fPath = path; |
| 547 } | 549 } |
| 548 | 550 |
| 549 // flush any accumulated draws before drawing this glyph as a path. | 551 // flush any accumulated draws before drawing this glyph as a path. |
| 550 this->flush(); | 552 this->flush(); |
| 551 | 553 |
| 552 SkMatrix ctm; | 554 SkMatrix ctm; |
| 553 ctm.setScale(fTextRatio, fTextRatio); | 555 ctm.setScale(fTextRatio, fTextRatio); |
| 554 ctm.postTranslate(sx - dx, sy - dy); | 556 ctm.postTranslate(sx - dx, sy - dy); |
| 555 GrPaint tmpPaint(fPaint); | |
| 556 tmpPaint.localCoordChange(ctm); | |
| 557 | 557 |
| 558 SkMatrix viewM = fViewMatrix; | 558 SkPath tmpPath(*glyph->fPath); |
| 559 viewM.preConcat(ctm); | 559 tmpPath.transform(ctm); |
| 560 |
| 560 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); | 561 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); |
| 561 fContext->drawPath(tmpPaint, viewM, *glyph->fPath, strokeInfo); | 562 fContext->drawPath(fPaint, fViewMatrix, tmpPath, strokeInfo); |
| 562 | 563 |
| 563 // remove this glyph from the vertices we need to allocate | 564 // remove this glyph from the vertices we need to allocate |
| 564 fTotalVertexCount -= kVerticesPerGlyph; | 565 fTotalVertexCount -= kVerticesPerGlyph; |
| 565 return true; | 566 return true; |
| 566 } | 567 } |
| 567 } | 568 } |
| 568 | 569 |
| 569 SkASSERT(glyph->fPlot); | 570 SkASSERT(glyph->fPlot); |
| 570 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); | 571 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); |
| 571 glyph->fPlot->setDrawToken(drawToken); | 572 glyph->fPlot->setDrawToken(drawToken); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 } | 679 } |
| 679 } | 680 } |
| 680 | 681 |
| 681 inline void GrDistanceFieldTextContext::finish() { | 682 inline void GrDistanceFieldTextContext::finish() { |
| 682 this->flush(); | 683 this->flush(); |
| 683 fTotalVertexCount = 0; | 684 fTotalVertexCount = 0; |
| 684 | 685 |
| 685 GrTextContext::finish(); | 686 GrTextContext::finish(); |
| 686 } | 687 } |
| 687 | 688 |
| OLD | NEW |