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

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

Issue 1397423004: Improve shaping segmentation for grapheme cluster based font fallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 18 matching lines...) Expand all
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" 34 #include "hb.h"
35 #include "platform/fonts/shaping/Shaper.h" 35 #include "platform/fonts/shaping/Shaper.h"
36 #include "platform/geometry/FloatPoint.h" 36 #include "platform/geometry/FloatPoint.h"
37 #include "platform/geometry/FloatRect.h" 37 #include "platform/geometry/FloatRect.h"
38 #include "platform/text/TextRun.h" 38 #include "platform/text/TextRun.h"
39 #include "wtf/Deque.h"
39 #include "wtf/HashSet.h" 40 #include "wtf/HashSet.h"
40 #include "wtf/OwnPtr.h" 41 #include "wtf/OwnPtr.h"
41 #include "wtf/PassOwnPtr.h" 42 #include "wtf/PassOwnPtr.h"
42 #include "wtf/Vector.h" 43 #include "wtf/Vector.h"
43 #include "wtf/text/CharacterNames.h" 44 #include "wtf/text/CharacterNames.h"
44 45
45 #include <unicode/uscript.h> 46 #include <unicode/uscript.h>
46 47
47 namespace blink { 48 namespace blink {
48 49
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 114
114 friend class HarfBuzzShaper; 115 friend class HarfBuzzShaper;
115 }; 116 };
116 117
117 class PLATFORM_EXPORT HarfBuzzShaper final : public Shaper { 118 class PLATFORM_EXPORT HarfBuzzShaper final : public Shaper {
118 public: 119 public:
119 HarfBuzzShaper(const Font*, const TextRun&); 120 HarfBuzzShaper(const Font*, const TextRun&);
120 PassRefPtr<ShapeResult> shapeResult(); 121 PassRefPtr<ShapeResult> shapeResult();
121 ~HarfBuzzShaper() { } 122 ~HarfBuzzShaper() { }
122 123
123 private: 124 enum HolesQueueItemAction {
124 struct HarfBuzzRun { 125 HolesQueueNextFont,
125 const SimpleFontData* m_fontData; 126 HolesQueueRange
126 unsigned m_startIndex;
127 size_t m_numCharacters;
128 hb_direction_t m_direction;
129 hb_script_t m_script;
130 }; 127 };
131 128
129 struct HolesQueueItem {
130 HolesQueueItemAction m_action;
131 unsigned m_startIndex;
132 unsigned m_numCharacters;
133 HolesQueueItem(HolesQueueItemAction action, unsigned start, unsigned num )
134 : m_action(action)
135 , m_startIndex(start)
136 , m_numCharacters(num) {};
137 };
138
139 private:
132 float nextExpansionPerOpportunity(); 140 float nextExpansionPerOpportunity();
133 void setExpansion(float); 141 void setExpansion(float);
134 void setFontFeatures(); 142 void setFontFeatures();
135 143
136 bool createHarfBuzzRuns(); 144 inline bool shapeRange(hb_buffer_t* harfBuzzBuffer, int startIndex, int numC haracters, const SimpleFontData* currentFont, UScriptCode currentRunScript, hb_l anguage_t);
eae 2015/10/14 08:12:01 How about using unsigned for startIndex and numCha
137 bool createHarfBuzzRunsForSingleCharacter(); 145 bool extractShapeResults(hb_buffer_t* harfBuzzBuffer, ShapeResult*, Deque<Ha rfBuzzShaper::HolesQueueItem>*, bool& fontCycleQueued, const HolesQueueItem& cur rentQueueItem, const SimpleFontData* currentFont, UScriptCode currentRunScript, bool isLastResort);
138 PassRefPtr<ShapeResult> shapeHarfBuzzRuns(); 146 bool buildHint(Vector<UChar32>& hint, bool needsList);
eae 2015/10/14 08:12:01 This could use a better name or a comment.
139 void shapeResult(ShapeResult*, unsigned, const HarfBuzzRun*, hb_buffer_t*); 147
148 void insertRunIntoShapeResult(ShapeResult*, PassOwnPtr<ShapeResult::RunInfo> runToInsert, int startGlyph, int numGlyphs, int, hb_buffer_t*);
140 float adjustSpacing(ShapeResult::RunInfo*, size_t glyphIndex, unsigned curre ntCharacterIndex, float& offsetX, float& totalAdvance); 149 float adjustSpacing(ShapeResult::RunInfo*, size_t glyphIndex, unsigned curre ntCharacterIndex, float& offsetX, float& totalAdvance);
141 void addHarfBuzzRun(unsigned startCharacter, unsigned endCharacter, const Si mpleFontData*, UScriptCode);
142 150
143 OwnPtr<UChar[]> m_normalizedBuffer; 151 OwnPtr<UChar[]> m_normalizedBuffer;
144 unsigned m_normalizedBufferLength; 152 unsigned m_normalizedBufferLength;
145 153
146 float m_wordSpacingAdjustment; // Delta adjustment (pixels) for each word br eak. 154 float m_wordSpacingAdjustment; // Delta adjustment (pixels) for each word br eak.
147 float m_letterSpacing; // Pixels to be added after each glyph. 155 float m_letterSpacing; // Pixels to be added after each glyph.
148 unsigned m_expansionOpportunityCount; 156 unsigned m_expansionOpportunityCount;
149 157
150 Vector<hb_feature_t, 4> m_features; 158 Vector<hb_feature_t, 4> m_features;
151 Vector<HarfBuzzRun, 16> m_harfBuzzRuns; 159 Deque<HolesQueueItem> m_holesQueue;
152 }; 160 };
153 161
162
154 } // namespace blink 163 } // namespace blink
155 164
156 #endif // HarfBuzzShaper_h 165 #endif // HarfBuzzShaper_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698