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

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

Issue 1914443002: Revert of RenderTextMac: Cache the SkTypeface on the TextRun (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/render_text_harfbuzz.h ('k') | ui/gfx/render_text_mac.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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 }; 556 };
557 557
558 // Function object for case insensitive string comparison. 558 // Function object for case insensitive string comparison.
559 struct CaseInsensitiveCompare { 559 struct CaseInsensitiveCompare {
560 bool operator() (const Font& a, const Font& b) const { 560 bool operator() (const Font& a, const Font& b) const {
561 return base::CompareCaseInsensitiveASCII(a.GetFontName(), b.GetFontName()) < 561 return base::CompareCaseInsensitiveASCII(a.GetFontName(), b.GetFontName()) <
562 0; 562 0;
563 } 563 }
564 }; 564 };
565 565
566 sk_sp<SkTypeface> CreateSkiaTypeface(const gfx::Font& font, int style) {
567 int skia_style = SkTypeface::kNormal;
568 skia_style |= (style & Font::BOLD) ? SkTypeface::kBold : 0;
569 skia_style |= (style & Font::ITALIC) ? SkTypeface::kItalic : 0;
570 return sk_sp<SkTypeface>(SkTypeface::CreateFromName(
571 font.GetFontName().c_str(), static_cast<SkTypeface::Style>(skia_style)));
572 }
573
574 } // namespace 566 } // namespace
575 567
576 namespace internal { 568 namespace internal {
577 569
578 TextRunHarfBuzz::TextRunHarfBuzz() 570 TextRunHarfBuzz::TextRunHarfBuzz()
579 : width(0.0f), 571 : width(0.0f),
580 preceding_run_widths(0.0f), 572 preceding_run_widths(0.0f),
581 is_rtl(false), 573 is_rtl(false),
582 level(0), 574 level(0),
583 script(USCRIPT_INVALID_CODE), 575 script(USCRIPT_INVALID_CODE),
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 return; 1450 return;
1459 1451
1460 run->glyph_count = 0; 1452 run->glyph_count = 0;
1461 run->width = 0.0f; 1453 run->width = 0.0f;
1462 } 1454 }
1463 1455
1464 bool RenderTextHarfBuzz::ShapeRunWithFont(const base::string16& text, 1456 bool RenderTextHarfBuzz::ShapeRunWithFont(const base::string16& text,
1465 const gfx::Font& font, 1457 const gfx::Font& font,
1466 const FontRenderParams& params, 1458 const FontRenderParams& params,
1467 internal::TextRunHarfBuzz* run) { 1459 internal::TextRunHarfBuzz* run) {
1468 sk_sp<SkTypeface> skia_face(CreateSkiaTypeface(font, run->font_style)); 1460 skia::RefPtr<SkTypeface> skia_face =
1461 internal::CreateSkiaTypeface(font, run->font_style);
1469 if (skia_face == NULL) 1462 if (skia_face == NULL)
1470 return false; 1463 return false;
1471 run->skia_face = skia_face; 1464 run->skia_face = skia_face;
1472 run->font = font; 1465 run->font = font;
1473 run->render_params = params; 1466 run->render_params = params;
1474 1467
1475 hb_font_t* harfbuzz_font = CreateHarfBuzzFont( 1468 hb_font_t* harfbuzz_font = CreateHarfBuzzFont(
1476 run->skia_face.get(), SkIntToScalar(run->font_size), run->render_params, 1469 run->skia_face.get(), SkIntToScalar(run->font_size), run->render_params,
1477 subpixel_rendering_suppressed()); 1470 subpixel_rendering_suppressed());
1478 1471
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 DCHECK(!update_layout_run_list_); 1569 DCHECK(!update_layout_run_list_);
1577 DCHECK(!update_display_run_list_); 1570 DCHECK(!update_display_run_list_);
1578 return text_elided() ? display_run_list_.get() : &layout_run_list_; 1571 return text_elided() ? display_run_list_.get() : &layout_run_list_;
1579 } 1572 }
1580 1573
1581 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { 1574 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const {
1582 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); 1575 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList();
1583 } 1576 }
1584 1577
1585 } // namespace gfx 1578 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text_harfbuzz.h ('k') | ui/gfx/render_text_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698