| 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 "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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 47   // Writes the character and glyph ranges of the cluster containing |pos|. | 47   // Writes the character and glyph ranges of the cluster containing |pos|. | 
| 48   void GetClusterAt(size_t pos, Range* chars, Range* glyphs) const; | 48   void GetClusterAt(size_t pos, Range* chars, Range* glyphs) const; | 
| 49 | 49 | 
| 50   // Returns the grapheme bounds at |text_index|. Handles multi-grapheme glyphs. | 50   // Returns the grapheme bounds at |text_index|. Handles multi-grapheme glyphs. | 
| 51   RangeF GetGraphemeBounds(base::i18n::BreakIterator* grapheme_iterator, | 51   RangeF GetGraphemeBounds(base::i18n::BreakIterator* grapheme_iterator, | 
| 52                            size_t text_index); | 52                            size_t text_index); | 
| 53 | 53 | 
| 54   // Returns whether the given shaped run contains any missing glyphs. | 54   // Returns whether the given shaped run contains any missing glyphs. | 
| 55   bool HasMissingGlyphs() const; | 55   bool HasMissingGlyphs() const; | 
| 56 | 56 | 
|  | 57   // Returns the glyph width for the given character range. |char_range| is in | 
|  | 58   // text-space (0 corresponds to |GetDisplayText()[0]|). | 
|  | 59   SkScalar GetGlyphWidthForCharRange(const Range& char_range) const; | 
|  | 60 | 
| 57   float width; | 61   float width; | 
| 58   float preceding_run_widths; | 62   float preceding_run_widths; | 
| 59   Range range; | 63   Range range; | 
| 60   bool is_rtl; | 64   bool is_rtl; | 
| 61   UBiDiLevel level; | 65   UBiDiLevel level; | 
| 62   UScriptCode script; | 66   UScriptCode script; | 
| 63 | 67 | 
| 64   scoped_ptr<uint16[]> glyphs; | 68   scoped_ptr<uint16[]> glyphs; | 
| 65   scoped_ptr<SkPoint[]> positions; | 69   scoped_ptr<SkPoint[]> positions; | 
| 66   std::vector<uint32> glyph_to_char; | 70   std::vector<uint32> glyph_to_char; | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 108   // Initialize the index mapping. | 112   // Initialize the index mapping. | 
| 109   void InitIndexMap(); | 113   void InitIndexMap(); | 
| 110 | 114 | 
| 111   // Precomputes the offsets for all runs. | 115   // Precomputes the offsets for all runs. | 
| 112   void ComputePrecedingRunWidths(); | 116   void ComputePrecedingRunWidths(); | 
| 113 | 117 | 
| 114   // Get the total width of runs, as if they were shown on one line. | 118   // Get the total width of runs, as if they were shown on one line. | 
| 115   // Do not use this when multiline is enabled. | 119   // Do not use this when multiline is enabled. | 
| 116   float width() const { return width_; } | 120   float width() const { return width_; } | 
| 117 | 121 | 
|  | 122   // Get the run index applicable to |position| (at or preceeding |position|). | 
|  | 123   size_t GetRunIndexAt(size_t position) const; | 
|  | 124 | 
| 118  private: | 125  private: | 
| 119   // Text runs in logical order. | 126   // Text runs in logical order. | 
| 120   ScopedVector<TextRunHarfBuzz> runs_; | 127   ScopedVector<TextRunHarfBuzz> runs_; | 
| 121 | 128 | 
| 122   // Maps visual run indices to logical run indices and vice versa. | 129   // Maps visual run indices to logical run indices and vice versa. | 
| 123   std::vector<int32_t> visual_to_logical_; | 130   std::vector<int32_t> visual_to_logical_; | 
| 124   std::vector<int32_t> logical_to_visual_; | 131   std::vector<int32_t> logical_to_visual_; | 
| 125 | 132 | 
| 126   float width_; | 133   float width_; | 
| 127 | 134 | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 172   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_HorizontalPositions); | 179   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_HorizontalPositions); | 
| 173   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, | 180   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, | 
| 174                            HarfBuzz_TextPositionWithFractionalSize); | 181                            HarfBuzz_TextPositionWithFractionalSize); | 
| 175   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks); | 182   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks); | 
| 176   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByEmoji); | 183   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_BreakRunsByEmoji); | 
| 177   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases); | 184   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemeCases); | 
| 178   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemePartition); | 185   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_SubglyphGraphemePartition); | 
| 179   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_NonExistentFont); | 186   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_NonExistentFont); | 
| 180   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); | 187   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UniscribeFallback); | 
| 181   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UnicodeFallback); | 188   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, HarfBuzz_UnicodeFallback); | 
|  | 189   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_LineBreakerBehavior); | 
|  | 190   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, | 
|  | 191                            Multiline_SurrogatePairsOrCombiningChars); | 
|  | 192   FRIEND_TEST_ALL_PREFIXES(RenderTextTest, Multiline_ZeroWidthChars); | 
| 182 | 193 | 
| 183   // Specify the width of a glyph for test. The width of glyphs is very | 194   // Specify the width of a glyph for test. The width of glyphs is very | 
| 184   // platform-dependent and environment-dependent. Otherwise multiline test | 195   // platform-dependent and environment-dependent. Otherwise multiline test | 
| 185   // will become really flaky. | 196   // will become really flaky. | 
| 186   void set_glyph_width_for_test(float test_width) { | 197   void set_glyph_width_for_test(float test_width) { | 
| 187     glyph_width_for_test_ = test_width; | 198     glyph_width_for_test_ = test_width; | 
| 188   } | 199   } | 
| 189 | 200 | 
| 190   // The actual implementation of the text drawing. | 201   // The actual implementation of the text drawing. | 
| 191   void DrawVisualTextInternal(internal::SkiaTextRenderer* renderer); | 202   void DrawVisualTextInternal(internal::SkiaTextRenderer* renderer); | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 263 | 274 | 
| 264   // 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. | 
| 265   float glyph_width_for_test_; | 276   float glyph_width_for_test_; | 
| 266 | 277 | 
| 267   DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 278   DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzz); | 
| 268 }; | 279 }; | 
| 269 | 280 | 
| 270 }  // namespace gfx | 281 }  // namespace gfx | 
| 271 | 282 | 
| 272 #endif  // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 283 #endif  // UI_GFX_RENDER_TEXT_HARFBUZZ_H_ | 
| OLD | NEW | 
|---|