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 "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 405 |
406 if (NULL == fStrike) { | 406 if (NULL == fStrike) { |
407 fStrike = fContext->getFontCache()->getStrike(scaler, true); | 407 fStrike = fContext->getFontCache()->getStrike(scaler, true); |
408 } | 408 } |
409 | 409 |
410 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); | 410 GrGlyph* glyph = fStrike->getGlyph(packed, scaler); |
411 if (NULL == glyph || glyph->fBounds.isEmpty()) { | 411 if (NULL == glyph || glyph->fBounds.isEmpty()) { |
412 return; | 412 return; |
413 } | 413 } |
414 | 414 |
| 415 // TODO: support color glyphs |
| 416 if (kA8_GrMaskFormat != glyph->fMaskFormat) { |
| 417 return; |
| 418 } |
| 419 |
415 SkScalar sx = SkFixedToScalar(vx); | 420 SkScalar sx = SkFixedToScalar(vx); |
416 SkScalar sy = SkFixedToScalar(vy); | 421 SkScalar sy = SkFixedToScalar(vy); |
417 /* | 422 /* |
418 // not valid, need to find a different solution for this | 423 // not valid, need to find a different solution for this |
419 vx += SkIntToFixed(glyph->fBounds.fLeft); | 424 vx += SkIntToFixed(glyph->fBounds.fLeft); |
420 vy += SkIntToFixed(glyph->fBounds.fTop); | 425 vy += SkIntToFixed(glyph->fBounds.fTop); |
421 | 426 |
422 // keep them as ints until we've done the clip-test | 427 // keep them as ints until we've done the clip-test |
423 GrFixed width = glyph->fBounds.width(); | 428 GrFixed width = glyph->fBounds.width(); |
424 GrFixed height = glyph->fBounds.height(); | 429 GrFixed height = glyph->fBounds.height(); |
425 | 430 |
426 // check if we clipped out | 431 // check if we clipped out |
427 if (true || NULL == glyph->fPlot) { | 432 if (true || NULL == glyph->fPlot) { |
428 int x = vx >> 16; | 433 int x = vx >> 16; |
429 int y = vy >> 16; | 434 int y = vy >> 16; |
430 if (fClipRect.quickReject(x, y, x + width, y + height)) { | 435 if (fClipRect.quickReject(x, y, x + width, y + height)) { |
431 // SkCLZ(3); // so we can set a break-point in the debugger | 436 // SkCLZ(3); // so we can set a break-point in the debugger |
432 return; | 437 return; |
433 } | 438 } |
434 } | 439 } |
435 */ | 440 */ |
436 if (NULL == glyph->fPlot) { | 441 if (NULL == glyph->fPlot) { |
437 if (!fStrike->glyphTooLargeForAtlas(glyph)) { | 442 if (!fStrike->glyphTooLargeForAtlas(glyph)) { |
438 if (fStrike->addGlyphToAtlas(glyph, scaler)) { | 443 if (fStrike->addGlyphToAtlas(glyph, scaler)) { |
439 goto HAS_ATLAS; | 444 goto HAS_ATLAS; |
440 } | 445 } |
441 | 446 |
442 // try to clear out an unused plot before we flush | 447 // try to clear out an unused plot before we flush |
443 if (fContext->getFontCache()->freeUnusedPlot(fStrike) && | 448 if (fContext->getFontCache()->freeUnusedPlot(fStrike, glyph) && |
444 fStrike->addGlyphToAtlas(glyph, scaler)) { | 449 fStrike->addGlyphToAtlas(glyph, scaler)) { |
445 goto HAS_ATLAS; | 450 goto HAS_ATLAS; |
446 } | 451 } |
447 | 452 |
448 if (c_DumpFontCache) { | 453 if (c_DumpFontCache) { |
449 #ifdef SK_DEVELOPER | 454 #ifdef SK_DEVELOPER |
450 fContext->getFontCache()->dump(); | 455 fContext->getFontCache()->dump(); |
451 #endif | 456 #endif |
452 } | 457 } |
453 | 458 |
454 // before we purge the cache, we must flush any accumulated draws | 459 // before we purge the cache, we must flush any accumulated draws |
455 this->flush(); | 460 this->flush(); |
456 fContext->flush(); | 461 fContext->flush(); |
457 | 462 |
458 // we should have an unused plot now | 463 // we should have an unused plot now |
459 if (fContext->getFontCache()->freeUnusedPlot(fStrike) && | 464 if (fContext->getFontCache()->freeUnusedPlot(fStrike, glyph) && |
460 fStrike->addGlyphToAtlas(glyph, scaler)) { | 465 fStrike->addGlyphToAtlas(glyph, scaler)) { |
461 goto HAS_ATLAS; | 466 goto HAS_ATLAS; |
462 } | 467 } |
463 } | 468 } |
464 | 469 |
465 if (NULL == glyph->fPath) { | 470 if (NULL == glyph->fPath) { |
466 SkPath* path = SkNEW(SkPath); | 471 SkPath* path = SkNEW(SkPath); |
467 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { | 472 if (!scaler->getGlyphPath(glyph->glyphID(), path)) { |
468 // flag the glyph as being dead? | 473 // flag the glyph as being dead? |
469 delete path; | 474 delete path; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 fVertexBounds.setLargestInverted(); | 668 fVertexBounds.setLargestInverted(); |
664 } | 669 } |
665 } | 670 } |
666 | 671 |
667 inline void GrDistanceFieldTextContext::finish() { | 672 inline void GrDistanceFieldTextContext::finish() { |
668 this->flush(); | 673 this->flush(); |
669 | 674 |
670 GrTextContext::finish(); | 675 GrTextContext::finish(); |
671 } | 676 } |
672 | 677 |
OLD | NEW |