Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: src/core/SkFindAndPlaceGlyph.h

Issue 1740163002: Improve horizontal baseline detection. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Just the bug fixes first. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkPaint.cpp » ('j') | src/core/SkScalerContext.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPaint.cpp » ('j') | src/core/SkScalerContext.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698