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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.h

Issue 2686503003: Add support for shaping a substring to HarfBuzzShaper (Closed)
Patch Set: Fix windows compiler error Created 3 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef HarfBuzzShaper_h 31 #ifndef HarfBuzzShaper_h
32 #define HarfBuzzShaper_h 32 #define HarfBuzzShaper_h
33 33
34 #include <hb.h>
35 #include <unicode/uscript.h>
36 #include <memory>
37 #include "platform/fonts/shaping/RunSegmenter.h"
34 #include "platform/fonts/shaping/ShapeResult.h" 38 #include "platform/fonts/shaping/ShapeResult.h"
35 #include "platform/text/TextRun.h" 39 #include "platform/text/TextRun.h"
36 #include "wtf/Allocator.h" 40 #include "wtf/Allocator.h"
37 #include "wtf/Deque.h" 41 #include "wtf/Deque.h"
38 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
39 #include <hb.h>
40 #include <memory>
41 #include <unicode/uscript.h>
42 43
43 namespace blink { 44 namespace blink {
44 45
45 class Font; 46 class Font;
46 class SimpleFontData; 47 class SimpleFontData;
47 class HarfBuzzShaper; 48 class HarfBuzzShaper;
49 struct HolesQueueItem;
48 50
49 class PLATFORM_EXPORT HarfBuzzShaper final { 51 class PLATFORM_EXPORT HarfBuzzShaper final {
50 public: 52 public:
51 HarfBuzzShaper(const UChar*, unsigned length, TextDirection); 53 HarfBuzzShaper(const UChar*, unsigned length);
52 PassRefPtr<ShapeResult> shapeResult(const Font*) const; 54 PassRefPtr<ShapeResult> shape(const Font*,
55 TextDirection,
56 unsigned start,
57 unsigned end) const;
58 PassRefPtr<ShapeResult> shape(const Font*, TextDirection) const;
53 ~HarfBuzzShaper() {} 59 ~HarfBuzzShaper() {}
54 60
55 enum HolesQueueItemAction { HolesQueueNextFont, HolesQueueRange }; 61 private:
62 using FeaturesVector = Vector<hb_feature_t, 6>;
56 63
57 struct HolesQueueItem { 64 // Shapes a single seqment, as identified by the RunSegmenterRange parameter,
drott 2017/02/07 23:12:41 Is this the codereview tool showing it in a funny
58 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 65 // one or more times taking font fallback into account. The start and end
59 HolesQueueItemAction m_action; 66 // parameters are for the entire text run, not the segment, and are used to
60 unsigned m_startIndex; 67 // determine pre- and post-context for shaping.
61 unsigned m_numCharacters; 68 void shapeSegment(ShapeResult*,
62 HolesQueueItem(HolesQueueItemAction action, unsigned start, unsigned num) 69 Deque<HolesQueueItem>*,
63 : m_action(action), m_startIndex(start), m_numCharacters(num){}; 70 hb_buffer_t*,
64 }; 71 const Font*,
72 FeaturesVector*,
73 RunSegmenter::RunSegmenterRange,
74 unsigned start,
75 unsigned end,
76 TextDirection) const;
65 77
66 private:
67 bool extractShapeResults(hb_buffer_t*, 78 bool extractShapeResults(hb_buffer_t*,
68 ShapeResult*, 79 ShapeResult*,
69 bool& fontCycleQueued, 80 bool& fontCycleQueued,
70 Deque<HolesQueueItem>*, 81 Deque<HolesQueueItem>*,
71 const HolesQueueItem&, 82 const HolesQueueItem&,
72 const Font*, 83 const Font*,
84 TextDirection,
73 const SimpleFontData*, 85 const SimpleFontData*,
74 UScriptCode, 86 UScriptCode,
75 bool isLastResort) const; 87 bool isLastResort) const;
76 bool collectFallbackHintChars(const Deque<HolesQueueItem>&, 88 bool collectFallbackHintChars(const Deque<HolesQueueItem>*,
77 Vector<UChar32>& hint) const; 89 Vector<UChar32>& hint) const;
78 90
79 void insertRunIntoShapeResult( 91 void insertRunIntoShapeResult(
80 ShapeResult*, 92 ShapeResult*,
81 std::unique_ptr<ShapeResult::RunInfo> runToInsert, 93 std::unique_ptr<ShapeResult::RunInfo> runToInsert,
82 unsigned startGlyph, 94 unsigned startGlyph,
83 unsigned numGlyphs, 95 unsigned numGlyphs,
84 hb_buffer_t*); 96 hb_buffer_t*);
85 97
86 const UChar* m_normalizedBuffer; 98 const UChar* m_text;
87 unsigned m_normalizedBufferLength; 99 unsigned m_textLength;
88 TextDirection m_textDirection;
89 }; 100 };
90 101
91 } // namespace blink 102 } // namespace blink
92 103
93 #endif // HarfBuzzShaper_h 104 #endif // HarfBuzzShaper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698