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

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

Issue 923973003: Fix the x-offset calculation when drawing the text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 10 months 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 | no next file » | 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 #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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 const Vector2d origin = GetLineOffset(i) + Vector2d(0, line.baseline); 1005 const Vector2d origin = GetLineOffset(i) + Vector2d(0, line.baseline);
1006 SkScalar preceding_segment_widths = 0; 1006 SkScalar preceding_segment_widths = 0;
1007 for (const internal::LineSegment& segment : line.segments) { 1007 for (const internal::LineSegment& segment : line.segments) {
1008 const internal::TextRunHarfBuzz& run = *run_list->runs()[segment.run]; 1008 const internal::TextRunHarfBuzz& run = *run_list->runs()[segment.run];
1009 renderer.SetTypeface(run.skia_face.get()); 1009 renderer.SetTypeface(run.skia_face.get());
1010 renderer.SetTextSize(SkIntToScalar(run.font_size)); 1010 renderer.SetTextSize(SkIntToScalar(run.font_size));
1011 renderer.SetFontRenderParams(run.render_params, 1011 renderer.SetFontRenderParams(run.render_params,
1012 background_is_transparent()); 1012 background_is_transparent());
1013 Range glyphs_range = run.CharRangeToGlyphRange(segment.char_range); 1013 Range glyphs_range = run.CharRangeToGlyphRange(segment.char_range);
1014 scoped_ptr<SkPoint[]> positions(new SkPoint[glyphs_range.length()]); 1014 scoped_ptr<SkPoint[]> positions(new SkPoint[glyphs_range.length()]);
1015 SkScalar offset_x = 1015 SkScalar offset_x = preceding_segment_widths -
1016 preceding_segment_widths - run.positions[glyphs_range.start()].x(); 1016 ((glyphs_range.GetMin() != 0)
1017 ? run.positions[glyphs_range.GetMin()].x()
1018 : 0);
1017 for (size_t j = 0; j < glyphs_range.length(); ++j) { 1019 for (size_t j = 0; j < glyphs_range.length(); ++j) {
1018 positions[j] = run.positions[(glyphs_range.is_reversed()) ? 1020 positions[j] = run.positions[(glyphs_range.is_reversed()) ?
1019 (glyphs_range.start() - j) : 1021 (glyphs_range.start() - j) :
1020 (glyphs_range.start() + j)]; 1022 (glyphs_range.start() + j)];
1021 positions[j].offset(SkIntToScalar(origin.x()) + offset_x, 1023 positions[j].offset(SkIntToScalar(origin.x()) + offset_x,
1022 SkIntToScalar(origin.y())); 1024 SkIntToScalar(origin.y()));
1023 } 1025 }
1024 for (BreakList<SkColor>::const_iterator it = 1026 for (BreakList<SkColor>::const_iterator it =
1025 colors().GetBreak(segment.char_range.start()); 1027 colors().GetBreak(segment.char_range.start());
1026 it != colors().breaks().end() && 1028 it != colors().breaks().end() &&
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 DCHECK(!update_layout_run_list_); 1459 DCHECK(!update_layout_run_list_);
1458 DCHECK(!update_display_run_list_); 1460 DCHECK(!update_display_run_list_);
1459 return text_elided() ? display_run_list_.get() : &layout_run_list_; 1461 return text_elided() ? display_run_list_.get() : &layout_run_list_;
1460 } 1462 }
1461 1463
1462 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { 1464 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const {
1463 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); 1465 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList();
1464 } 1466 }
1465 1467
1466 } // namespace gfx 1468 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698