| 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 #include "ui/gfx/render_text_harfbuzz.h" | 5 #include "ui/gfx/render_text_harfbuzz.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/i18n/bidi_line_iterator.h" | 9 #include "base/i18n/bidi_line_iterator.h" |
| 10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 internal::TextRunList* run_list = GetRunList(); | 1011 internal::TextRunList* run_list = GetRunList(); |
| 1012 for (size_t i = 0; i < lines().size(); ++i) { | 1012 for (size_t i = 0; i < lines().size(); ++i) { |
| 1013 const internal::Line& line = lines()[i]; | 1013 const internal::Line& line = lines()[i]; |
| 1014 const Vector2d origin = GetLineOffset(i) + Vector2d(0, line.baseline); | 1014 const Vector2d origin = GetLineOffset(i) + Vector2d(0, line.baseline); |
| 1015 SkScalar preceding_segment_widths = 0; | 1015 SkScalar preceding_segment_widths = 0; |
| 1016 for (const internal::LineSegment& segment : line.segments) { | 1016 for (const internal::LineSegment& segment : line.segments) { |
| 1017 const internal::TextRunHarfBuzz& run = *run_list->runs()[segment.run]; | 1017 const internal::TextRunHarfBuzz& run = *run_list->runs()[segment.run]; |
| 1018 renderer->SetTypeface(run.skia_face.get()); | 1018 renderer->SetTypeface(run.skia_face.get()); |
| 1019 renderer->SetTextSize(SkIntToScalar(run.font_size)); | 1019 renderer->SetTextSize(SkIntToScalar(run.font_size)); |
| 1020 renderer->SetFontRenderParams(run.render_params, | 1020 renderer->SetFontRenderParams(run.render_params, |
| 1021 background_is_transparent()); | 1021 subpixel_rendering_suppressed()); |
| 1022 Range glyphs_range = run.CharRangeToGlyphRange(segment.char_range); | 1022 Range glyphs_range = run.CharRangeToGlyphRange(segment.char_range); |
| 1023 scoped_ptr<SkPoint[]> positions(new SkPoint[glyphs_range.length()]); | 1023 scoped_ptr<SkPoint[]> positions(new SkPoint[glyphs_range.length()]); |
| 1024 SkScalar offset_x = preceding_segment_widths - | 1024 SkScalar offset_x = preceding_segment_widths - |
| 1025 ((glyphs_range.GetMin() != 0) | 1025 ((glyphs_range.GetMin() != 0) |
| 1026 ? run.positions[glyphs_range.GetMin()].x() | 1026 ? run.positions[glyphs_range.GetMin()].x() |
| 1027 : 0); | 1027 : 0); |
| 1028 for (size_t j = 0; j < glyphs_range.length(); ++j) { | 1028 for (size_t j = 0; j < glyphs_range.length(); ++j) { |
| 1029 positions[j] = run.positions[(glyphs_range.is_reversed()) ? | 1029 positions[j] = run.positions[(glyphs_range.is_reversed()) ? |
| 1030 (glyphs_range.start() - j) : | 1030 (glyphs_range.start() - j) : |
| 1031 (glyphs_range.start() + j)]; | 1031 (glyphs_range.start() + j)]; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 run->family = font_family; | 1301 run->family = font_family; |
| 1302 run->render_params = params; | 1302 run->render_params = params; |
| 1303 | 1303 |
| 1304 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. | 1304 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. |
| 1305 tracked_objects::ScopedTracker tracking_profile01( | 1305 tracked_objects::ScopedTracker tracking_profile01( |
| 1306 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1306 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1307 "431326 RenderTextHarfBuzz::ShapeRunWithFont01")); | 1307 "431326 RenderTextHarfBuzz::ShapeRunWithFont01")); |
| 1308 | 1308 |
| 1309 hb_font_t* harfbuzz_font = CreateHarfBuzzFont( | 1309 hb_font_t* harfbuzz_font = CreateHarfBuzzFont( |
| 1310 run->skia_face.get(), SkIntToScalar(run->font_size), run->render_params, | 1310 run->skia_face.get(), SkIntToScalar(run->font_size), run->render_params, |
| 1311 background_is_transparent()); | 1311 subpixel_rendering_suppressed()); |
| 1312 | 1312 |
| 1313 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. | 1313 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. |
| 1314 tracked_objects::ScopedTracker tracking_profile1( | 1314 tracked_objects::ScopedTracker tracking_profile1( |
| 1315 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1315 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1316 "431326 RenderTextHarfBuzz::ShapeRunWithFont1")); | 1316 "431326 RenderTextHarfBuzz::ShapeRunWithFont1")); |
| 1317 | 1317 |
| 1318 // Create a HarfBuzz buffer and add the string to be shaped. The HarfBuzz | 1318 // Create a HarfBuzz buffer and add the string to be shaped. The HarfBuzz |
| 1319 // buffer holds our text, run information to be used by the shaping engine, | 1319 // buffer holds our text, run information to be used by the shaping engine, |
| 1320 // and the resulting glyph data. | 1320 // and the resulting glyph data. |
| 1321 hb_buffer_t* buffer = hb_buffer_create(); | 1321 hb_buffer_t* buffer = hb_buffer_create(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 DCHECK(!update_layout_run_list_); | 1468 DCHECK(!update_layout_run_list_); |
| 1469 DCHECK(!update_display_run_list_); | 1469 DCHECK(!update_display_run_list_); |
| 1470 return text_elided() ? display_run_list_.get() : &layout_run_list_; | 1470 return text_elided() ? display_run_list_.get() : &layout_run_list_; |
| 1471 } | 1471 } |
| 1472 | 1472 |
| 1473 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { | 1473 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
| 1474 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); | 1474 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
| 1475 } | 1475 } |
| 1476 | 1476 |
| 1477 } // namespace gfx | 1477 } // namespace gfx |
| OLD | NEW |