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

Side by Side Diff: ui/gfx/render_text_harfbuzz.h

Issue 674683003: Avoid extra FontRenderParams queries in RenderTextHarfBuzz. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: restore check that a family was actually found Created 6 years, 1 month 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 | ui/gfx/render_text_harfbuzz.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_RENDER_TEXT_HARFBUZZ_H_ 5 #ifndef UI_GFX_RENDER_TEXT_HARFBUZZ_H_
6 #define UI_GFX_RENDER_TEXT_HARFBUZZ_H_ 6 #define UI_GFX_RENDER_TEXT_HARFBUZZ_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "third_party/harfbuzz-ng/src/hb.h" 10 #include "third_party/harfbuzz-ng/src/hb.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 Range range; 53 Range range;
54 bool is_rtl; 54 bool is_rtl;
55 UBiDiLevel level; 55 UBiDiLevel level;
56 UScriptCode script; 56 UScriptCode script;
57 57
58 scoped_ptr<uint16[]> glyphs; 58 scoped_ptr<uint16[]> glyphs;
59 scoped_ptr<SkPoint[]> positions; 59 scoped_ptr<SkPoint[]> positions;
60 std::vector<uint32> glyph_to_char; 60 std::vector<uint32> glyph_to_char;
61 size_t glyph_count; 61 size_t glyph_count;
62 62
63 std::string family;
63 skia::RefPtr<SkTypeface> skia_face; 64 skia::RefPtr<SkTypeface> skia_face;
64 FontRenderParams render_params; 65 FontRenderParams render_params;
65 int font_size; 66 int font_size;
66 int font_style; 67 int font_style;
67 bool strike; 68 bool strike;
68 bool diagonal_strike; 69 bool diagonal_strike;
69 bool underline; 70 bool underline;
70 71
71 private: 72 private:
72 DISALLOW_COPY_AND_ASSIGN(TextRunHarfBuzz); 73 DISALLOW_COPY_AND_ASSIGN(TextRunHarfBuzz);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // or last caret position inside (not at a boundary of) the run. 121 // or last caret position inside (not at a boundary of) the run.
121 // The returned value represents a cursor/caret position without a selection. 122 // The returned value represents a cursor/caret position without a selection.
122 SelectionModel FirstSelectionModelInsideRun( 123 SelectionModel FirstSelectionModelInsideRun(
123 const internal::TextRunHarfBuzz* run); 124 const internal::TextRunHarfBuzz* run);
124 SelectionModel LastSelectionModelInsideRun( 125 SelectionModel LastSelectionModelInsideRun(
125 const internal::TextRunHarfBuzz* run); 126 const internal::TextRunHarfBuzz* run);
126 127
127 // Break the text into logical runs and populate the visual <-> logical maps. 128 // Break the text into logical runs and populate the visual <-> logical maps.
128 void ItemizeText(); 129 void ItemizeText();
129 130
131 // Helper method for ShapeRun() that calls ShapeRunWithFont() with |run|,
132 // |family|, and |render_params|, returning true if the family provides all
133 // needed glyphs and false otherwise. Additionally updates |best_family|,
134 // |best_render_params|, and |best_missing_glyphs| if |family| has fewer than
135 // |best_missing_glyphs| missing glyphs.
136 bool CompareFamily(internal::TextRunHarfBuzz* run,
137 const std::string& family,
138 const gfx::FontRenderParams& render_params,
139 std::string* best_family,
140 gfx::FontRenderParams* best_render_params,
141 size_t* best_missing_glyphs);
142
130 // Shape the glyphs needed for the text |run|. 143 // Shape the glyphs needed for the text |run|.
131 void ShapeRun(internal::TextRunHarfBuzz* run); 144 void ShapeRun(internal::TextRunHarfBuzz* run);
132 bool ShapeRunWithFont(internal::TextRunHarfBuzz* run, 145 bool ShapeRunWithFont(internal::TextRunHarfBuzz* run,
133 const std::string& font); 146 const std::string& font_family,
147 const FontRenderParams& params);
134 148
135 // Text runs in logical order. 149 // Text runs in logical order.
136 ScopedVector<internal::TextRunHarfBuzz> runs_; 150 ScopedVector<internal::TextRunHarfBuzz> runs_;
137 151
138 // Maps visual run indices to logical run indices and vice versa. 152 // Maps visual run indices to logical run indices and vice versa.
139 std::vector<int32_t> visual_to_logical_; 153 std::vector<int32_t> visual_to_logical_;
140 std::vector<int32_t> logical_to_visual_; 154 std::vector<int32_t> logical_to_visual_;
141 155
142 bool needs_layout_; 156 bool needs_layout_;
143 157
144 // ICU grapheme iterator for the layout text. Valid when |!needs_layout_|. Can 158 // ICU grapheme iterator for the layout text. Valid when |!needs_layout_|. Can
145 // be NULL in case of an error. 159 // be NULL in case of an error.
146 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_; 160 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_;
147 161
148 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); 162 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz);
149 }; 163 };
150 164
151 } // namespace gfx 165 } // namespace gfx
152 166
153 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ 167 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text_harfbuzz.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698