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 |
11 #include "SkAutoKern.h" | 11 #include "SkAutoKern.h" |
12 #include "SkGlyph.h" | 12 #include "SkGlyph.h" |
13 #include "SkGlyphCache.h" | 13 #include "SkGlyphCache.h" |
14 #include "SkPaint.h" | 14 #include "SkPaint.h" |
15 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
16 #include "SkUtils.h" | 16 #include "SkUtils.h" |
17 | 17 |
bungeman-skia
2016/01/05 18:54:43
need <utility>
bungeman-skia
2016/01/05 18:59:41
Done.
| |
18 // Calculate a type with the same size as the max of all the Ts. | 18 // Calculate a type with the same size as the max of all the Ts. |
19 // This must be top level because the is no specialization of inner classes. | 19 // This must be top level because the is no specialization of inner classes. |
20 template<typename... Ts> struct SkMaxSizeOf; | 20 template<typename... Ts> struct SkMaxSizeOf; |
21 | 21 |
22 template<> | 22 template<> |
23 struct SkMaxSizeOf<> { | 23 struct SkMaxSizeOf<> { |
24 static const size_t value = 0; | 24 static const size_t value = 0; |
25 }; | 25 }; |
26 | 26 |
27 template<typename H, typename... Ts> | 27 template<typename H, typename... Ts> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 UntaggedVariant(UntaggedVariant&&) = delete; | 84 UntaggedVariant(UntaggedVariant&&) = delete; |
85 UntaggedVariant& operator=(UntaggedVariant&&) = delete; | 85 UntaggedVariant& operator=(UntaggedVariant&&) = delete; |
86 | 86 |
87 template<typename Variant, typename... Args> | 87 template<typename Variant, typename... Args> |
88 void initialize(Args&&... args) { | 88 void initialize(Args&&... args) { |
89 SkASSERT(sizeof(Variant) <= sizeof(fSpace)); | 89 SkASSERT(sizeof(Variant) <= sizeof(fSpace)); |
90 #if defined(_MSC_VER) && _MSC_VER < 1900 | 90 #if defined(_MSC_VER) && _MSC_VER < 1900 |
91 #define alignof __alignof | 91 #define alignof __alignof |
92 #endif | 92 #endif |
93 SkASSERT(alignof(Variant) <= alignof(Space)); | 93 SkASSERT(alignof(Variant) <= alignof(Space)); |
94 new(&fSpace) Variant(skstd::forward<Args>(args)...); | 94 new(&fSpace) Variant(std::forward<Args>(args)...); |
95 } | 95 } |
96 | 96 |
97 private: | 97 private: |
98 typedef SkAlignedSStorage<SkMaxSizeOf<Ts...>::value> Space; | 98 typedef SkAlignedSStorage<SkMaxSizeOf<Ts...>::value> Space; |
99 Space fSpace; | 99 Space fSpace; |
100 }; | 100 }; |
101 | 101 |
102 // PolymorphicVariant holds subclasses of Base without slicing. Ts must be s ubclasses of Base. | 102 // PolymorphicVariant holds subclasses of Base without slicing. Ts must be s ubclasses of Base. |
103 template<typename Base, typename... Ts> | 103 template<typename Base, typename... Ts> |
104 class PolymorphicVariant { | 104 class PolymorphicVariant { |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 ProcessOneGlyph, SkPaint::kLeft_Align, kX_SkAxisAlignment> Positione r; | 602 ProcessOneGlyph, SkPaint::kLeft_Align, kX_SkAxisAlignment> Positione r; |
603 HorizontalPositions positions{pos}; | 603 HorizontalPositions positions{pos}; |
604 TranslationMapper mapper{matrix, offset}; | 604 TranslationMapper mapper{matrix, offset}; |
605 Positioner positioner(glyphFinder); | 605 Positioner positioner(glyphFinder); |
606 const char* cursor = text; | 606 const char* cursor = text; |
607 const char* stop = text + byteLength; | 607 const char* stop = text + byteLength; |
608 while (cursor < stop) { | 608 while (cursor < stop) { |
609 SkPoint mappedPoint = mapper.TranslationMapper::map( | 609 SkPoint mappedPoint = mapper.TranslationMapper::map( |
610 positions.HorizontalPositions::nextPoint()); | 610 positions.HorizontalPositions::nextPoint()); |
611 positioner.Positioner::findAndPositionGlyph( | 611 positioner.Positioner::findAndPositionGlyph( |
612 &cursor, mappedPoint, skstd::forward<ProcessOneGlyph>(processOne Glyph)); | 612 &cursor, mappedPoint, std::forward<ProcessOneGlyph>(processOneGl yph)); |
613 } | 613 } |
614 return; | 614 return; |
615 } | 615 } |
616 | 616 |
617 PositionReader positionReader{ | 617 PositionReader positionReader{ |
618 [&](PositionReader::Variants* to_init) { | 618 [&](PositionReader::Variants* to_init) { |
619 if (2 == scalarsPerPosition) { | 619 if (2 == scalarsPerPosition) { |
620 to_init->initialize<ArbitraryPositions>(pos); | 620 to_init->initialize<ArbitraryPositions>(pos); |
621 } else { | 621 } else { |
622 to_init->initialize<HorizontalPositions>(pos); | 622 to_init->initialize<HorizontalPositions>(pos); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 break; | 674 break; |
675 } | 675 } |
676 } | 676 } |
677 } | 677 } |
678 }; | 678 }; |
679 | 679 |
680 const char* stop = text + byteLength; | 680 const char* stop = text + byteLength; |
681 while (text < stop) { | 681 while (text < stop) { |
682 SkPoint mappedPoint = mapper->map(positionReader->nextPoint()); | 682 SkPoint mappedPoint = mapper->map(positionReader->nextPoint()); |
683 findAndPosition->findAndPositionGlyph( | 683 findAndPosition->findAndPositionGlyph( |
684 &text, mappedPoint, skstd::forward<ProcessOneGlyph>(processOneGlyph) ); | 684 &text, mappedPoint, std::forward<ProcessOneGlyph>(processOneGlyph)); |
685 } | 685 } |
686 } | 686 } |
687 | 687 |
688 template<typename ProcessOneGlyph> | 688 template<typename ProcessOneGlyph> |
689 inline void SkFindAndPlaceGlyph::ProcessText( | 689 inline void SkFindAndPlaceGlyph::ProcessText( |
690 SkPaint::TextEncoding textEncoding, const char text[], size_t byteLength, | 690 SkPaint::TextEncoding textEncoding, const char text[], size_t byteLength, |
691 SkPoint offset, const SkMatrix& matrix, SkPaint::Align textAlignment, | 691 SkPoint offset, const SkMatrix& matrix, SkPaint::Align textAlignment, |
692 SkGlyphCache* cache, ProcessOneGlyph&& processOneGlyph) { | 692 SkGlyphCache* cache, ProcessOneGlyph&& processOneGlyph) { |
693 | 693 |
694 // transform the starting point | 694 // transform the starting point |
(...skipping 23 matching lines...) Expand all Loading... | |
718 ProcessOneGlyph, SkPaint::kLeft_Align, kUseKerning>>(gly phFinder); | 718 ProcessOneGlyph, SkPaint::kLeft_Align, kUseKerning>>(gly phFinder); |
719 } | 719 } |
720 } | 720 } |
721 }; | 721 }; |
722 | 722 |
723 const char* stop = text + byteLength; | 723 const char* stop = text + byteLength; |
724 SkPoint current = offset; | 724 SkPoint current = offset; |
725 while (text < stop) { | 725 while (text < stop) { |
726 current = | 726 current = |
727 findAndPosition->findAndPositionGlyph( | 727 findAndPosition->findAndPositionGlyph( |
728 &text, current, skstd::forward<ProcessOneGlyph>(processOneGlyph) ); | 728 &text, current, std::forward<ProcessOneGlyph>(processOneGlyph)); |
729 | 729 |
730 } | 730 } |
731 } | 731 } |
732 | 732 |
733 #endif // SkFindAndPositionGlyph_DEFINED | 733 #endif // SkFindAndPositionGlyph_DEFINED |
OLD | NEW |