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

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

Issue 1561683002: Start using <type_traits> and <utility> (C++11). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix skstd::unique_ptr::compressed_pair. Created 4 years, 11 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 | « src/core/SkDraw.cpp ('k') | src/gpu/effects/GrPorterDuffXferProcessor.cpp » ('j') | no next file with comments »
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
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 #include <utility>
17 18
18 // Calculate a type with the same size as the max of all the Ts. 19 // 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. 20 // This must be top level because the is no specialization of inner classes.
20 template<typename... Ts> struct SkMaxSizeOf; 21 template<typename... Ts> struct SkMaxSizeOf;
21 22
22 template<> 23 template<>
23 struct SkMaxSizeOf<> { 24 struct SkMaxSizeOf<> {
24 static const size_t value = 0; 25 static const size_t value = 0;
25 }; 26 };
26 27
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 UntaggedVariant(UntaggedVariant&&) = delete; 85 UntaggedVariant(UntaggedVariant&&) = delete;
85 UntaggedVariant& operator=(UntaggedVariant&&) = delete; 86 UntaggedVariant& operator=(UntaggedVariant&&) = delete;
86 87
87 template<typename Variant, typename... Args> 88 template<typename Variant, typename... Args>
88 void initialize(Args&&... args) { 89 void initialize(Args&&... args) {
89 SkASSERT(sizeof(Variant) <= sizeof(fSpace)); 90 SkASSERT(sizeof(Variant) <= sizeof(fSpace));
90 #if defined(_MSC_VER) && _MSC_VER < 1900 91 #if defined(_MSC_VER) && _MSC_VER < 1900
91 #define alignof __alignof 92 #define alignof __alignof
92 #endif 93 #endif
93 SkASSERT(alignof(Variant) <= alignof(Space)); 94 SkASSERT(alignof(Variant) <= alignof(Space));
94 new(&fSpace) Variant(skstd::forward<Args>(args)...); 95 new(&fSpace) Variant(std::forward<Args>(args)...);
95 } 96 }
96 97
97 private: 98 private:
98 typedef SkAlignedSStorage<SkMaxSizeOf<Ts...>::value> Space; 99 typedef SkAlignedSStorage<SkMaxSizeOf<Ts...>::value> Space;
99 Space fSpace; 100 Space fSpace;
100 }; 101 };
101 102
102 // PolymorphicVariant holds subclasses of Base without slicing. Ts must be s ubclasses of Base. 103 // PolymorphicVariant holds subclasses of Base without slicing. Ts must be s ubclasses of Base.
103 template<typename Base, typename... Ts> 104 template<typename Base, typename... Ts>
104 class PolymorphicVariant { 105 class PolymorphicVariant {
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 ProcessOneGlyph, SkPaint::kLeft_Align, kX_SkAxisAlignment> Positione r; 603 ProcessOneGlyph, SkPaint::kLeft_Align, kX_SkAxisAlignment> Positione r;
603 HorizontalPositions positions{pos}; 604 HorizontalPositions positions{pos};
604 TranslationMapper mapper{matrix, offset}; 605 TranslationMapper mapper{matrix, offset};
605 Positioner positioner(glyphFinder); 606 Positioner positioner(glyphFinder);
606 const char* cursor = text; 607 const char* cursor = text;
607 const char* stop = text + byteLength; 608 const char* stop = text + byteLength;
608 while (cursor < stop) { 609 while (cursor < stop) {
609 SkPoint mappedPoint = mapper.TranslationMapper::map( 610 SkPoint mappedPoint = mapper.TranslationMapper::map(
610 positions.HorizontalPositions::nextPoint()); 611 positions.HorizontalPositions::nextPoint());
611 positioner.Positioner::findAndPositionGlyph( 612 positioner.Positioner::findAndPositionGlyph(
612 &cursor, mappedPoint, skstd::forward<ProcessOneGlyph>(processOne Glyph)); 613 &cursor, mappedPoint, std::forward<ProcessOneGlyph>(processOneGl yph));
613 } 614 }
614 return; 615 return;
615 } 616 }
616 617
617 PositionReader positionReader{ 618 PositionReader positionReader{
618 [&](PositionReader::Variants* to_init) { 619 [&](PositionReader::Variants* to_init) {
619 if (2 == scalarsPerPosition) { 620 if (2 == scalarsPerPosition) {
620 to_init->initialize<ArbitraryPositions>(pos); 621 to_init->initialize<ArbitraryPositions>(pos);
621 } else { 622 } else {
622 to_init->initialize<HorizontalPositions>(pos); 623 to_init->initialize<HorizontalPositions>(pos);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 break; 675 break;
675 } 676 }
676 } 677 }
677 } 678 }
678 }; 679 };
679 680
680 const char* stop = text + byteLength; 681 const char* stop = text + byteLength;
681 while (text < stop) { 682 while (text < stop) {
682 SkPoint mappedPoint = mapper->map(positionReader->nextPoint()); 683 SkPoint mappedPoint = mapper->map(positionReader->nextPoint());
683 findAndPosition->findAndPositionGlyph( 684 findAndPosition->findAndPositionGlyph(
684 &text, mappedPoint, skstd::forward<ProcessOneGlyph>(processOneGlyph) ); 685 &text, mappedPoint, std::forward<ProcessOneGlyph>(processOneGlyph));
685 } 686 }
686 } 687 }
687 688
688 template<typename ProcessOneGlyph> 689 template<typename ProcessOneGlyph>
689 inline void SkFindAndPlaceGlyph::ProcessText( 690 inline void SkFindAndPlaceGlyph::ProcessText(
690 SkPaint::TextEncoding textEncoding, const char text[], size_t byteLength, 691 SkPaint::TextEncoding textEncoding, const char text[], size_t byteLength,
691 SkPoint offset, const SkMatrix& matrix, SkPaint::Align textAlignment, 692 SkPoint offset, const SkMatrix& matrix, SkPaint::Align textAlignment,
692 SkGlyphCache* cache, ProcessOneGlyph&& processOneGlyph) { 693 SkGlyphCache* cache, ProcessOneGlyph&& processOneGlyph) {
693 694
694 // transform the starting point 695 // transform the starting point
(...skipping 23 matching lines...) Expand all
718 ProcessOneGlyph, SkPaint::kLeft_Align, kUseKerning>>(gly phFinder); 719 ProcessOneGlyph, SkPaint::kLeft_Align, kUseKerning>>(gly phFinder);
719 } 720 }
720 } 721 }
721 }; 722 };
722 723
723 const char* stop = text + byteLength; 724 const char* stop = text + byteLength;
724 SkPoint current = offset; 725 SkPoint current = offset;
725 while (text < stop) { 726 while (text < stop) {
726 current = 727 current =
727 findAndPosition->findAndPositionGlyph( 728 findAndPosition->findAndPositionGlyph(
728 &text, current, skstd::forward<ProcessOneGlyph>(processOneGlyph) ); 729 &text, current, std::forward<ProcessOneGlyph>(processOneGlyph));
729 730
730 } 731 }
731 } 732 }
732 733
733 #endif // SkFindAndPositionGlyph_DEFINED 734 #endif // SkFindAndPositionGlyph_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/gpu/effects/GrPorterDuffXferProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698