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

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

Issue 1752953003: Replace uses of SkFixed for HarfBuzz conversions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « ui/gfx/harfbuzz_font_skia.cc ('k') | ui/gfx/skia_util.h » ('j') | 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 #include <set> 8 #include <set>
9 9
10 #include "base/i18n/bidi_line_iterator.h" 10 #include "base/i18n/bidi_line_iterator.h"
(...skipping 10 matching lines...) Expand all
21 #include "third_party/icu/source/common/unicode/utf16.h" 21 #include "third_party/icu/source/common/unicode/utf16.h"
22 #include "third_party/skia/include/core/SkColor.h" 22 #include "third_party/skia/include/core/SkColor.h"
23 #include "third_party/skia/include/core/SkTypeface.h" 23 #include "third_party/skia/include/core/SkTypeface.h"
24 #include "ui/gfx/canvas.h" 24 #include "ui/gfx/canvas.h"
25 #include "ui/gfx/font.h" 25 #include "ui/gfx/font.h"
26 #include "ui/gfx/font_fallback.h" 26 #include "ui/gfx/font_fallback.h"
27 #include "ui/gfx/font_render_params.h" 27 #include "ui/gfx/font_render_params.h"
28 #include "ui/gfx/geometry/safe_integer_conversions.h" 28 #include "ui/gfx/geometry/safe_integer_conversions.h"
29 #include "ui/gfx/harfbuzz_font_skia.h" 29 #include "ui/gfx/harfbuzz_font_skia.h"
30 #include "ui/gfx/range/range_f.h" 30 #include "ui/gfx/range/range_f.h"
31 #include "ui/gfx/skia_util.h"
31 #include "ui/gfx/text_utils.h" 32 #include "ui/gfx/text_utils.h"
32 #include "ui/gfx/utf16_indexing.h" 33 #include "ui/gfx/utf16_indexing.h"
33 34
34 #if defined(OS_WIN) 35 #if defined(OS_WIN)
35 #include "ui/gfx/font_fallback_win.h" 36 #include "ui/gfx/font_fallback_win.h"
36 #endif 37 #endif
37 38
38 namespace gfx { 39 namespace gfx {
39 40
40 namespace { 41 namespace {
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 hb_buffer_get_glyph_positions(buffer, NULL); 1497 hb_buffer_get_glyph_positions(buffer, NULL);
1497 run->glyphs.reset(new uint16_t[run->glyph_count]); 1498 run->glyphs.reset(new uint16_t[run->glyph_count]);
1498 run->glyph_to_char.resize(run->glyph_count); 1499 run->glyph_to_char.resize(run->glyph_count);
1499 run->positions.reset(new SkPoint[run->glyph_count]); 1500 run->positions.reset(new SkPoint[run->glyph_count]);
1500 run->width = 0.0f; 1501 run->width = 0.0f;
1501 1502
1502 for (size_t i = 0; i < run->glyph_count; ++i) { 1503 for (size_t i = 0; i < run->glyph_count; ++i) {
1503 DCHECK_LE(infos[i].codepoint, std::numeric_limits<uint16_t>::max()); 1504 DCHECK_LE(infos[i].codepoint, std::numeric_limits<uint16_t>::max());
1504 run->glyphs[i] = static_cast<uint16_t>(infos[i].codepoint); 1505 run->glyphs[i] = static_cast<uint16_t>(infos[i].codepoint);
1505 run->glyph_to_char[i] = infos[i].cluster; 1506 run->glyph_to_char[i] = infos[i].cluster;
1506 const SkScalar x_offset = SkFixedToScalar(hb_positions[i].x_offset); 1507 const SkScalar x_offset =
1507 const SkScalar y_offset = SkFixedToScalar(hb_positions[i].y_offset); 1508 HarfBuzzUnitsToSkiaScalar(hb_positions[i].x_offset);
1509 const SkScalar y_offset =
1510 HarfBuzzUnitsToSkiaScalar(hb_positions[i].y_offset);
1508 run->positions[i].set(run->width + x_offset, -y_offset); 1511 run->positions[i].set(run->width + x_offset, -y_offset);
1509 run->width += (glyph_width_for_test_ > 0) 1512 run->width += (glyph_width_for_test_ > 0)
1510 ? glyph_width_for_test_ 1513 ? glyph_width_for_test_
1511 : SkFixedToFloat(hb_positions[i].x_advance); 1514 : HarfBuzzUnitsToFloat(hb_positions[i].x_advance);
1512 // Round run widths if subpixel positioning is off to match native behavior. 1515 // Round run widths if subpixel positioning is off to match native behavior.
1513 if (!run->render_params.subpixel_positioning) 1516 if (!run->render_params.subpixel_positioning)
1514 run->width = std::floor(run->width + 0.5f); 1517 run->width = std::floor(run->width + 0.5f);
1515 } 1518 }
1516 1519
1517 hb_buffer_destroy(buffer); 1520 hb_buffer_destroy(buffer);
1518 hb_font_destroy(harfbuzz_font); 1521 hb_font_destroy(harfbuzz_font);
1519 return true; 1522 return true;
1520 } 1523 }
1521 1524
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 DCHECK(!update_layout_run_list_); 1567 DCHECK(!update_layout_run_list_);
1565 DCHECK(!update_display_run_list_); 1568 DCHECK(!update_display_run_list_);
1566 return text_elided() ? display_run_list_.get() : &layout_run_list_; 1569 return text_elided() ? display_run_list_.get() : &layout_run_list_;
1567 } 1570 }
1568 1571
1569 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { 1572 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const {
1570 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); 1573 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList();
1571 } 1574 }
1572 1575
1573 } // namespace gfx 1576 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/harfbuzz_font_skia.cc ('k') | ui/gfx/skia_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698