OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #ifndef SkFindAndPositionGlyph_DEFINED | 8 #ifndef SkFindAndPositionGlyph_DEFINED |
9 #define SkFindAndPositionGlyph_DEFINED | 9 #define SkFindAndPositionGlyph_DEFINED |
10 | 10 |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 } | 580 } |
581 }; | 581 }; |
582 | 582 |
583 template<typename ProcessOneGlyph> | 583 template<typename ProcessOneGlyph> |
584 inline void SkFindAndPlaceGlyph::ProcessPosText( | 584 inline void SkFindAndPlaceGlyph::ProcessPosText( |
585 SkPaint::TextEncoding textEncoding, const char text[], size_t byteLength, | 585 SkPaint::TextEncoding textEncoding, const char text[], size_t byteLength, |
586 SkPoint offset, const SkMatrix& matrix, const SkScalar pos[], int scalarsPer
Position, | 586 SkPoint offset, const SkMatrix& matrix, const SkScalar pos[], int scalarsPer
Position, |
587 SkPaint::Align textAlignment, | 587 SkPaint::Align textAlignment, |
588 SkGlyphCache* cache, ProcessOneGlyph&& processOneGlyph) { | 588 SkGlyphCache* cache, ProcessOneGlyph&& processOneGlyph) { |
589 | 589 |
590 SkAxisAlignment axisAlignment = SkComputeAxisAlignmentForHText(matrix); | 590 SkAxisAlignment axisAlignment = cache->getScalerContext()->computeAxisAlignm
entForHText(); |
591 uint32_t mtype = matrix.getType(); | 591 uint32_t mtype = matrix.getType(); |
592 | |
593 LookupGlyph glyphFinder(textEncoding, cache); | 592 LookupGlyph glyphFinder(textEncoding, cache); |
594 | 593 |
595 // Specialized code for handling the most common case for blink. The while l
oop is totally | 594 // Specialized code for handling the most common case for blink. The while l
oop is totally |
596 // de-virtualized. | 595 // de-virtualized. |
597 if (scalarsPerPosition == 1 | 596 if (scalarsPerPosition == 1 |
598 && textAlignment == SkPaint::kLeft_Align | 597 && textAlignment == SkPaint::kLeft_Align |
599 && axisAlignment == kX_SkAxisAlignment | 598 && axisAlignment == kX_SkAxisAlignment |
600 && cache->isSubpixel() | 599 && cache->isSubpixel() |
601 && mtype <= SkMatrix::kTranslate_Mask) { | 600 && mtype <= SkMatrix::kTranslate_Mask) { |
602 typedef GlyphFindAndPlaceSubpixel< | 601 typedef GlyphFindAndPlaceSubpixel< |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 | 702 |
704 if (textAlignment == SkPaint::kCenter_Align) { | 703 if (textAlignment == SkPaint::kCenter_Align) { |
705 stop *= SK_ScalarHalf; | 704 stop *= SK_ScalarHalf; |
706 } | 705 } |
707 offset -= stop; | 706 offset -= stop; |
708 } | 707 } |
709 | 708 |
710 GlyphFindAndPlace<ProcessOneGlyph> findAndPosition{ | 709 GlyphFindAndPlace<ProcessOneGlyph> findAndPosition{ |
711 [&](typename GlyphFindAndPlace<ProcessOneGlyph>::Variants* to_init) { | 710 [&](typename GlyphFindAndPlace<ProcessOneGlyph>::Variants* to_init) { |
712 if (cache->isSubpixel()) { | 711 if (cache->isSubpixel()) { |
713 SkAxisAlignment axisAlignment = SkComputeAxisAlignmentForHText(m
atrix); | 712 SkAxisAlignment axisAlignment = |
| 713 cache->getScalerContext()->computeAxisAlignmentForHText(); |
714 InitSubpixel<ProcessOneGlyph, SkPaint::kLeft_Align>( | 714 InitSubpixel<ProcessOneGlyph, SkPaint::kLeft_Align>( |
715 to_init, axisAlignment, glyphFinder); | 715 to_init, axisAlignment, glyphFinder); |
716 } else { | 716 } else { |
717 to_init->template initialize< | 717 to_init->template initialize< |
718 GlyphFindAndPlaceFullPixel< | 718 GlyphFindAndPlaceFullPixel< |
719 ProcessOneGlyph, SkPaint::kLeft_Align, kUseKerning>>(gly
phFinder); | 719 ProcessOneGlyph, SkPaint::kLeft_Align, kUseKerning>>(gly
phFinder); |
720 } | 720 } |
721 } | 721 } |
722 }; | 722 }; |
723 | 723 |
724 const char* stop = text + byteLength; | 724 const char* stop = text + byteLength; |
725 SkPoint current = offset; | 725 SkPoint current = offset; |
726 while (text < stop) { | 726 while (text < stop) { |
727 current = | 727 current = |
728 findAndPosition->findAndPositionGlyph( | 728 findAndPosition->findAndPositionGlyph( |
729 &text, current, std::forward<ProcessOneGlyph>(processOneGlyph)); | 729 &text, current, std::forward<ProcessOneGlyph>(processOneGlyph)); |
730 | 730 |
731 } | 731 } |
732 } | 732 } |
733 | 733 |
734 #endif // SkFindAndPositionGlyph_DEFINED | 734 #endif // SkFindAndPositionGlyph_DEFINED |
OLD | NEW |