| 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 "GrBitmapTextContext.h" | 8 #include "GrBitmapTextContext.h" |
| 9 #include "GrAtlas.h" | 9 #include "GrAtlas.h" |
| 10 #include "GrDefaultGeoProcFactory.h" | 10 #include "GrDefaultGeoProcFactory.h" |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 // check if we clipped out | 423 // check if we clipped out |
| 424 if (true || NULL == glyph->fPlot) { | 424 if (true || NULL == glyph->fPlot) { |
| 425 int x = vx >> 16; | 425 int x = vx >> 16; |
| 426 int y = vy >> 16; | 426 int y = vy >> 16; |
| 427 if (fClipRect.quickReject(x, y, x + width, y + height)) { | 427 if (fClipRect.quickReject(x, y, x + width, y + height)) { |
| 428 // SkCLZ(3); // so we can set a break-point in the debugger | 428 // SkCLZ(3); // so we can set a break-point in the debugger |
| 429 return; | 429 return; |
| 430 } | 430 } |
| 431 } | 431 } |
| 432 | 432 |
| 433 // If the glyph is too large we fall back to paths |
| 433 if (NULL == glyph->fPlot && !uploadGlyph(glyph, scaler)) { | 434 if (NULL == glyph->fPlot && !uploadGlyph(glyph, scaler)) { |
| 434 if (NULL == glyph->fPath) { | 435 if (NULL == glyph->fPath) { |
| 435 SkPath* path = SkNEW(SkPath); | 436 SkPath* path = SkNEW(SkPath); |
| 436 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { | 437 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { |
| 437 // flag the glyph as being dead? | 438 // flag the glyph as being dead? |
| 438 delete path; | 439 delete path; |
| 439 return; | 440 return; |
| 440 } | 441 } |
| 441 glyph->fPath = path; | 442 glyph->fPath = path; |
| 442 } | 443 } |
| 443 | 444 |
| 444 // flush any accumulated draws before drawing this glyph as a path. | 445 // flush any accumulated draws before drawing this glyph as a path. |
| 445 this->flush(); | 446 this->flush(); |
| 446 | 447 |
| 447 SkMatrix translate; | 448 SkMatrix translate; |
| 448 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds.
fLeft)), | 449 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds.
fLeft)), |
| 449 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds.
fTop))); | 450 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds.
fTop))); |
| 450 GrPaint tmpPaint(fPaint); | 451 SkPath tmpPath(*glyph->fPath); |
| 451 tmpPaint.localCoordChange(translate); | 452 tmpPath.transform(translate); |
| 452 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); | 453 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); |
| 453 fContext->drawPath(tmpPaint, translate, *glyph->fPath, strokeInfo); | 454 fContext->drawPath(fPaint, SkMatrix::I(), tmpPath, strokeInfo); |
| 454 | 455 |
| 455 // remove this glyph from the vertices we need to allocate | 456 // remove this glyph from the vertices we need to allocate |
| 456 fTotalVertexCount -= kVerticesPerGlyph; | 457 fTotalVertexCount -= kVerticesPerGlyph; |
| 457 return; | 458 return; |
| 458 } | 459 } |
| 459 | 460 |
| 460 SkASSERT(glyph->fPlot); | 461 SkASSERT(glyph->fPlot); |
| 461 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); | 462 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); |
| 462 glyph->fPlot->setDrawToken(drawToken); | 463 glyph->fPlot->setDrawToken(drawToken); |
| 463 | 464 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 } | 607 } |
| 607 } | 608 } |
| 608 | 609 |
| 609 inline void GrBitmapTextContext::finish() { | 610 inline void GrBitmapTextContext::finish() { |
| 610 this->flush(); | 611 this->flush(); |
| 611 fTotalVertexCount = 0; | 612 fTotalVertexCount = 0; |
| 612 | 613 |
| 613 GrTextContext::finish(); | 614 GrTextContext::finish(); |
| 614 } | 615 } |
| 615 | 616 |
| OLD | NEW |