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 font is too large, we fall back to paths in SkGpuDevice. However, its possible for | |
bsalomon
2014/12/18 21:03:04
Not just possible for corrupted fonts...
| |
434 // a corrupted font to have a super large glyph. We test for this below and fall back to paths. | |
433 if (NULL == glyph->fPlot && !uploadGlyph(glyph, scaler)) { | 435 if (NULL == glyph->fPlot && !uploadGlyph(glyph, scaler)) { |
434 if (NULL == glyph->fPath) { | 436 if (NULL == glyph->fPath) { |
435 SkPath* path = SkNEW(SkPath); | 437 SkPath* path = SkNEW(SkPath); |
436 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { | 438 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { |
437 // flag the glyph as being dead? | 439 // flag the glyph as being dead? |
438 delete path; | 440 delete path; |
439 return; | 441 return; |
440 } | 442 } |
441 glyph->fPath = path; | 443 glyph->fPath = path; |
442 } | 444 } |
443 | 445 |
444 // flush any accumulated draws before drawing this glyph as a path. | 446 // flush any accumulated draws before drawing this glyph as a path. |
445 this->flush(); | 447 this->flush(); |
446 | 448 |
447 SkMatrix translate; | 449 SkMatrix translate; |
448 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds. fLeft)), | 450 translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds. fLeft)), |
449 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds. fTop))); | 451 SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds. fTop))); |
450 GrPaint tmpPaint(fPaint); | 452 SkPath tmpPath(*glyph->fPath); |
451 tmpPaint.localCoordChange(translate); | 453 tmpPath.transform(translate); |
452 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); | 454 GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle); |
453 fContext->drawPath(tmpPaint, translate, *glyph->fPath, strokeInfo); | 455 fContext->drawPath(fPaint, SkMatrix::I(), tmpPath, strokeInfo); |
454 | 456 |
455 // remove this glyph from the vertices we need to allocate | 457 // remove this glyph from the vertices we need to allocate |
456 fTotalVertexCount -= kVerticesPerGlyph; | 458 fTotalVertexCount -= kVerticesPerGlyph; |
457 return; | 459 return; |
458 } | 460 } |
459 | 461 |
460 SkASSERT(glyph->fPlot); | 462 SkASSERT(glyph->fPlot); |
461 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); | 463 GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken(); |
462 glyph->fPlot->setDrawToken(drawToken); | 464 glyph->fPlot->setDrawToken(drawToken); |
463 | 465 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 } | 608 } |
607 } | 609 } |
608 | 610 |
609 inline void GrBitmapTextContext::finish() { | 611 inline void GrBitmapTextContext::finish() { |
610 this->flush(); | 612 this->flush(); |
611 fTotalVertexCount = 0; | 613 fTotalVertexCount = 0; |
612 | 614 |
613 GrTextContext::finish(); | 615 GrTextContext::finish(); |
614 } | 616 } |
615 | 617 |
OLD | NEW |