Commit b5b43219 authored by calamity's avatar calamity Committed by Commit bot

Remove unnecessary font list creation in AppListItemView.

This CL improves the app list startup time on non-Linux platforms. A new
FontList object was being unnecessarily created on every AppListItemView
which forced recalculations of otherwise cached values.

This was most noticeable on ChromeOS where the app list is
rebuilt every time it is shown.

BUG=415389

Review URL: https://codereview.chromium.org/574983002

Cr-Commit-Position: refs/heads/master@{#295663}
parent e09c59d7
......@@ -41,15 +41,6 @@ const int kTopPadding = 20;
const int kIconTitleSpacing = 7;
const int kProgressBarHorizontalPadding = 12;
// The font is different on each platform. The font size is adjusted on some
// platforms to keep a consistent look.
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// Reducing the font size by 2 makes it the same as the Windows font size.
const int kFontSizeDelta = -2;
#else
const int kFontSizeDelta = 0;
#endif
// Radius of the folder dropping preview circle.
const int kFolderPreviewRadius = 40;
......@@ -70,6 +61,20 @@ const gfx::ShadowValues& GetIconShadows() {
return icon_shadows;
}
gfx::FontList GetFontList() {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
const gfx::FontList& font_list = rb.GetFontList(kItemTextFontStyle);
// The font is different on each platform. The font size is adjusted on some
// platforms to keep a consistent look.
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// Reducing the font size by 2 makes it the same as the Windows font size.
const int kFontSizeDelta = -2;
return font_list.DeriveWithSizeDelta(kFontSizeDelta);
#else
return font_list;
#endif
}
} // namespace
// static
......@@ -91,12 +96,12 @@ AppListItemView::AppListItemView(AppsGridView* apps_grid_view,
is_highlighted_(false) {
icon_->set_interactive(false);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
title_->SetBackgroundColor(0);
title_->SetAutoColorReadabilityEnabled(false);
title_->SetEnabledColor(kGridTitleColor);
title_->SetFontList(
rb.GetFontList(kItemTextFontStyle).DeriveWithSizeDelta(kFontSizeDelta));
static const gfx::FontList font_list = GetFontList();
title_->SetFontList(font_list);
title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
title_->Invalidate();
SetTitleSubpixelAA();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment