| 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_enabled()); |
| 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 = | 1024 SkScalar offset_x = |
| 1025 preceding_segment_widths - run.positions[glyphs_range.start()].x(); | 1025 preceding_segment_widths - run.positions[glyphs_range.start()].x(); |
| 1026 for (size_t j = 0; j < glyphs_range.length(); ++j) { | 1026 for (size_t j = 0; j < glyphs_range.length(); ++j) { |
| 1027 positions[j] = run.positions[(glyphs_range.is_reversed()) ? | 1027 positions[j] = run.positions[(glyphs_range.is_reversed()) ? |
| 1028 (glyphs_range.start() - j) : | 1028 (glyphs_range.start() - j) : |
| 1029 (glyphs_range.start() + j)]; | 1029 (glyphs_range.start() + j)]; |
| 1030 positions[j].offset(SkIntToScalar(origin.x()) + offset_x, | 1030 positions[j].offset(SkIntToScalar(origin.x()) + offset_x, |
| 1031 SkIntToScalar(origin.y())); | 1031 SkIntToScalar(origin.y())); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 run->family = font_family; | 1299 run->family = font_family; |
| 1300 run->render_params = params; | 1300 run->render_params = params; |
| 1301 | 1301 |
| 1302 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. | 1302 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. |
| 1303 tracked_objects::ScopedTracker tracking_profile01( | 1303 tracked_objects::ScopedTracker tracking_profile01( |
| 1304 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1304 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1305 "431326 RenderTextHarfBuzz::ShapeRunWithFont01")); | 1305 "431326 RenderTextHarfBuzz::ShapeRunWithFont01")); |
| 1306 | 1306 |
| 1307 hb_font_t* harfbuzz_font = CreateHarfBuzzFont( | 1307 hb_font_t* harfbuzz_font = CreateHarfBuzzFont( |
| 1308 run->skia_face.get(), SkIntToScalar(run->font_size), run->render_params, | 1308 run->skia_face.get(), SkIntToScalar(run->font_size), run->render_params, |
| 1309 background_is_transparent()); | 1309 subpixel_rendering_enabled()); |
| 1310 | 1310 |
| 1311 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. | 1311 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. |
| 1312 tracked_objects::ScopedTracker tracking_profile1( | 1312 tracked_objects::ScopedTracker tracking_profile1( |
| 1313 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1313 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1314 "431326 RenderTextHarfBuzz::ShapeRunWithFont1")); | 1314 "431326 RenderTextHarfBuzz::ShapeRunWithFont1")); |
| 1315 | 1315 |
| 1316 // Create a HarfBuzz buffer and add the string to be shaped. The HarfBuzz | 1316 // Create a HarfBuzz buffer and add the string to be shaped. The HarfBuzz |
| 1317 // buffer holds our text, run information to be used by the shaping engine, | 1317 // buffer holds our text, run information to be used by the shaping engine, |
| 1318 // and the resulting glyph data. | 1318 // and the resulting glyph data. |
| 1319 hb_buffer_t* buffer = hb_buffer_create(); | 1319 hb_buffer_t* buffer = hb_buffer_create(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 DCHECK(!update_layout_run_list_); | 1466 DCHECK(!update_layout_run_list_); |
| 1467 DCHECK(!update_display_run_list_); | 1467 DCHECK(!update_display_run_list_); |
| 1468 return text_elided() ? display_run_list_.get() : &layout_run_list_; | 1468 return text_elided() ? display_run_list_.get() : &layout_run_list_; |
| 1469 } | 1469 } |
| 1470 | 1470 |
| 1471 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { | 1471 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
| 1472 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); | 1472 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
| 1473 } | 1473 } |
| 1474 | 1474 |
| 1475 } // namespace gfx | 1475 } // namespace gfx |
| OLD | NEW |