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

Unified Diff: ui/gfx/render_text_harfbuzz.cc

Issue 1907833002: RenderTextMac: Cache the SkTypeface on the TextRun (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: skia::RefPtr<>(Adopt(..)) -> sk_sp<>(..) 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_harfbuzz.cc
diff --git a/ui/gfx/render_text_harfbuzz.cc b/ui/gfx/render_text_harfbuzz.cc
index 731cc6f24051c2a15b6b6cc31888a03fe38387fa..9fbcbd178785df64506b6277438c5bdfd400c557 100644
--- a/ui/gfx/render_text_harfbuzz.cc
+++ b/ui/gfx/render_text_harfbuzz.cc
@@ -563,6 +563,14 @@ struct CaseInsensitiveCompare {
}
};
+sk_sp<SkTypeface> CreateSkiaTypeface(const gfx::Font& font, int style) {
+ int skia_style = SkTypeface::kNormal;
+ skia_style |= (style & Font::BOLD) ? SkTypeface::kBold : 0;
+ skia_style |= (style & Font::ITALIC) ? SkTypeface::kItalic : 0;
+ return sk_sp<SkTypeface>(SkTypeface::CreateFromName(
+ font.GetFontName().c_str(), static_cast<SkTypeface::Style>(skia_style)));
+}
+
} // namespace
namespace internal {
@@ -1457,8 +1465,7 @@ bool RenderTextHarfBuzz::ShapeRunWithFont(const base::string16& text,
const gfx::Font& font,
const FontRenderParams& params,
internal::TextRunHarfBuzz* run) {
- skia::RefPtr<SkTypeface> skia_face =
- internal::CreateSkiaTypeface(font, run->font_style);
+ sk_sp<SkTypeface> skia_face(CreateSkiaTypeface(font, run->font_style));
if (skia_face == NULL)
return false;
run->skia_face = skia_face;
« 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