diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 03:29:59 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 03:29:59 +0000 |
commit | bbc9196df15b084e52332a6be5819c669bf8f405 (patch) | |
tree | 6d9cc51756174e85de24e8b56ac3b202fcbac715 /ui | |
parent | 7ae8d0f9ce244e3851802039cc6f5e7b4870181e (diff) | |
download | chromium_src-bbc9196df15b084e52332a6be5819c669bf8f405.zip chromium_src-bbc9196df15b084e52332a6be5819c669bf8f405.tar.gz chromium_src-bbc9196df15b084e52332a6be5819c669bf8f405.tar.bz2 |
Fix leak in new fade tab title code
My fade tab title code was leaking a HFONT everytime a tab title was drawn.
I think this leak is what's causing the CreateDIBSection() call to fail.
BUG=78857
TEST=Reproduced the original bug by opening lots of tabs. Applied my fix and verified that I could no longer reproduce the bug.
Review URL: http://codereview.chromium.org/6813098
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/canvas_skia_win.cc | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/ui/gfx/canvas_skia_win.cc b/ui/gfx/canvas_skia_win.cc index 570e803..048cbf6 100644 --- a/ui/gfx/canvas_skia_win.cc +++ b/ui/gfx/canvas_skia_win.cc @@ -9,6 +9,7 @@ #include "base/i18n/rtl.h" #include "base/logging.h" #include "base/scoped_ptr.h" +#include "base/win/scoped_gdi_object.h" #include "skia/ext/bitmap_platform_device.h" #include "skia/ext/skia_utils_win.h" #include "third_party/skia/include/core/SkShader.h" @@ -469,17 +470,8 @@ void CanvasSkia::DrawFadeTruncatingString( int total_string_height; SizeStringInt(text, font, &total_string_width, &total_string_height, flags | TEXT_VALIGN_TOP); - bool should_draw_directly = total_string_width <= display_rect.width(); - // Create a temporary bitmap to draw the gradient to. - scoped_ptr<skia::BitmapPlatformDevice> gradient_bitmap; - if (!should_draw_directly) { - gradient_bitmap.reset(skia::BitmapPlatformDevice::create( - NULL, display_rect.width(), display_rect.height(), false, NULL)); - should_draw_directly = gradient_bitmap.get() != NULL; - } - - if (should_draw_directly) { + if (total_string_width <= display_rect.width()) { DrawStringInt(text, font, color, display_rect.x(), display_rect.y(), display_rect.width(), display_rect.height(), 0); return; @@ -563,7 +555,13 @@ void CanvasSkia::DrawFadeTruncatingString( LOGFONT font_info; GetObject(font.GetNativeFont(), sizeof(font_info), &font_info); font_info.lfQuality = ANTIALIASED_QUALITY; - HFONT gray_scale_font = CreateFontIndirect(&font_info); + base::win::ScopedHFONT gray_scale_font(CreateFontIndirect(&font_info)); + + // Create a temporary bitmap to draw the gradient to. + scoped_ptr<skia::BitmapPlatformDevice> gradient_bitmap( + skia::BitmapPlatformDevice::create( + display_rect.width(), display_rect.height(), false, NULL)); + DCHECK(gradient_bitmap.get()); HDC hdc = beginPlatformPaint(); if (is_truncating_head) |