OLD | NEW |
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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
| 11 #include <memory> |
| 12 |
11 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 14 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
15 #include "third_party/harfbuzz-ng/src/hb.h" | 16 #include "third_party/harfbuzz-ng/src/hb.h" |
16 #include "third_party/icu/source/common/unicode/ubidi.h" | 17 #include "third_party/icu/source/common/unicode/ubidi.h" |
17 #include "third_party/icu/source/common/unicode/uscript.h" | 18 #include "third_party/icu/source/common/unicode/uscript.h" |
18 #include "ui/gfx/render_text.h" | 19 #include "ui/gfx/render_text.h" |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 namespace i18n { | 22 namespace i18n { |
22 class BreakIterator; | 23 class BreakIterator; |
23 } | 24 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // text-space (0 corresponds to |GetDisplayText()[0]|). | 61 // text-space (0 corresponds to |GetDisplayText()[0]|). |
61 SkScalar GetGlyphWidthForCharRange(const Range& char_range) const; | 62 SkScalar GetGlyphWidthForCharRange(const Range& char_range) const; |
62 | 63 |
63 float width; | 64 float width; |
64 float preceding_run_widths; | 65 float preceding_run_widths; |
65 Range range; | 66 Range range; |
66 bool is_rtl; | 67 bool is_rtl; |
67 UBiDiLevel level; | 68 UBiDiLevel level; |
68 UScriptCode script; | 69 UScriptCode script; |
69 | 70 |
70 scoped_ptr<uint16_t[]> glyphs; | 71 std::unique_ptr<uint16_t[]> glyphs; |
71 scoped_ptr<SkPoint[]> positions; | 72 std::unique_ptr<SkPoint[]> positions; |
72 std::vector<uint32_t> glyph_to_char; | 73 std::vector<uint32_t> glyph_to_char; |
73 size_t glyph_count; | 74 size_t glyph_count; |
74 | 75 |
75 Font font; | 76 Font font; |
76 skia::RefPtr<SkTypeface> skia_face; | 77 skia::RefPtr<SkTypeface> skia_face; |
77 FontRenderParams render_params; | 78 FontRenderParams render_params; |
78 int font_size; | 79 int font_size; |
79 int baseline_offset; | 80 int baseline_offset; |
80 int baseline_type; | 81 int baseline_type; |
81 int font_style; | 82 int font_style; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 }; | 139 }; |
139 | 140 |
140 } // namespace internal | 141 } // namespace internal |
141 | 142 |
142 class GFX_EXPORT RenderTextHarfBuzz : public RenderText { | 143 class GFX_EXPORT RenderTextHarfBuzz : public RenderText { |
143 public: | 144 public: |
144 RenderTextHarfBuzz(); | 145 RenderTextHarfBuzz(); |
145 ~RenderTextHarfBuzz() override; | 146 ~RenderTextHarfBuzz() override; |
146 | 147 |
147 // RenderText: | 148 // RenderText: |
148 scoped_ptr<RenderText> CreateInstanceOfSameType() const override; | 149 std::unique_ptr<RenderText> CreateInstanceOfSameType() const override; |
149 bool MultilineSupported() const override; | 150 bool MultilineSupported() const override; |
150 const base::string16& GetDisplayText() override; | 151 const base::string16& GetDisplayText() override; |
151 Size GetStringSize() override; | 152 Size GetStringSize() override; |
152 SizeF GetStringSizeF() override; | 153 SizeF GetStringSizeF() override; |
153 SelectionModel FindCursorPosition(const Point& point) override; | 154 SelectionModel FindCursorPosition(const Point& point) override; |
154 std::vector<FontSpan> GetFontSpansForTesting() override; | 155 std::vector<FontSpan> GetFontSpansForTesting() override; |
155 Range GetGlyphBounds(size_t index) override; | 156 Range GetGlyphBounds(size_t index) override; |
156 | 157 |
157 protected: | 158 protected: |
158 // RenderText: | 159 // RenderText: |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 base::i18n::BreakIterator* GetGraphemeIterator(); | 251 base::i18n::BreakIterator* GetGraphemeIterator(); |
251 | 252 |
252 // Returns the current run list, |display_run_list_| if the text is | 253 // Returns the current run list, |display_run_list_| if the text is |
253 // elided, or |layout_run_list_| otherwise. | 254 // elided, or |layout_run_list_| otherwise. |
254 internal::TextRunList* GetRunList(); | 255 internal::TextRunList* GetRunList(); |
255 const internal::TextRunList* GetRunList() const; | 256 const internal::TextRunList* GetRunList() const; |
256 | 257 |
257 // Text run list for |layout_text_| and |display_text_|. | 258 // Text run list for |layout_text_| and |display_text_|. |
258 // |display_run_list_| is created only when the text is elided. | 259 // |display_run_list_| is created only when the text is elided. |
259 internal::TextRunList layout_run_list_; | 260 internal::TextRunList layout_run_list_; |
260 scoped_ptr<internal::TextRunList> display_run_list_; | 261 std::unique_ptr<internal::TextRunList> display_run_list_; |
261 | 262 |
262 bool update_layout_run_list_ : 1; | 263 bool update_layout_run_list_ : 1; |
263 bool update_display_run_list_ : 1; | 264 bool update_display_run_list_ : 1; |
264 bool update_grapheme_iterator_ : 1; | 265 bool update_grapheme_iterator_ : 1; |
265 bool update_display_text_ : 1; | 266 bool update_display_text_ : 1; |
266 | 267 |
267 // ICU grapheme iterator for the layout text. Use GetGraphemeIterator() | 268 // ICU grapheme iterator for the layout text. Use GetGraphemeIterator() |
268 // to access the iterator. | 269 // to access the iterator. |
269 scoped_ptr<base::i18n::BreakIterator> grapheme_iterator_; | 270 std::unique_ptr<base::i18n::BreakIterator> grapheme_iterator_; |
270 | 271 |
271 // The total size of the layouted text. | 272 // The total size of the layouted text. |
272 SizeF total_size_; | 273 SizeF total_size_; |
273 | 274 |
274 // Fixed width of glyphs. This should only be set in test environments. | 275 // Fixed width of glyphs. This should only be set in test environments. |
275 float glyph_width_for_test_; | 276 float glyph_width_for_test_; |
276 | 277 |
277 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 278 DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); |
278 }; | 279 }; |
279 | 280 |
280 } // namespace gfx | 281 } // namespace gfx |
281 | 282 |
282 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 283 #endif // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ |
OLD | NEW |