diff options
author | asvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-03 20:09:28 +0000 |
---|---|---|
committer | asvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-03 20:09:28 +0000 |
commit | 165daf264ed5a09e2e783191a89500ccae65a5d5 (patch) | |
tree | 4a92affceb157b2c01b02a5bc7aabe790a7625e6 /ui | |
parent | a78a7233d2444ebfbae7bb89031b76eca42b095f (diff) | |
download | chromium_src-165daf264ed5a09e2e783191a89500ccae65a5d5.zip chromium_src-165daf264ed5a09e2e783191a89500ccae65a5d5.tar.gz chromium_src-165daf264ed5a09e2e783191a89500ccae65a5d5.tar.bz2 |
Optimize PlatformFontWin::GetFontSize().
Cache the value on HFontRef() instead of querying
it each time from Windows APIs.
BUG=105550
TEST=Existing unit tests.
Review URL: http://codereview.chromium.org/9314049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120381 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/platform_font_win.cc | 7 | ||||
-rw-r--r-- | ui/gfx/platform_font_win.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/ui/gfx/platform_font_win.cc b/ui/gfx/platform_font_win.cc index b188677..1cca192 100644 --- a/ui/gfx/platform_font_win.cc +++ b/ui/gfx/platform_font_win.cc @@ -114,10 +114,7 @@ std::string PlatformFontWin::GetFontName() const { } int PlatformFontWin::GetFontSize() const { - LOGFONT font_info; - GetObject(font_ref_->hfont(), sizeof(LOGFONT), &font_info); - DCHECK_LT(font_info.lfHeight, 0); - return -font_info.lfHeight; + return font_ref_->font_size(); } NativeFont PlatformFontWin::GetNativeFont() const { @@ -217,6 +214,8 @@ PlatformFontWin::HFontRef::HFontRef(HFONT hfont, LOGFONT font_info; GetObject(hfont_, sizeof(LOGFONT), &font_info); font_name_ = UTF16ToUTF8(string16(font_info.lfFaceName)); + DCHECK_LT(font_info.lfHeight, 0); + font_size_ = -font_info.lfHeight; } PlatformFontWin::HFontRef::~HFontRef() { diff --git a/ui/gfx/platform_font_win.h b/ui/gfx/platform_font_win.h index 17178de..ce23105 100644 --- a/ui/gfx/platform_font_win.h +++ b/ui/gfx/platform_font_win.h @@ -82,6 +82,7 @@ class UI_EXPORT PlatformFontWin : public PlatformFont { int style() const { return style_; } int dlu_base_x() const { return dlu_base_x_; } const std::string& font_name() const { return font_name_; } + int font_size() const { return font_size_; } private: friend class base::RefCounted<HFontRef>; @@ -96,6 +97,7 @@ class UI_EXPORT PlatformFontWin : public PlatformFont { // Constants used in converting dialog units to pixels. const int dlu_base_x_; std::string font_name_; + int font_size_; DISALLOW_COPY_AND_ASSIGN(HFontRef); }; |