summaryrefslogtreecommitdiffstats
path: root/ui/gfx/canvas_skia_win.cc
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-09 01:56:04 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-09 01:56:04 +0000
commite0cf664f805d83c64e648e011786de1dc29c9f21 (patch)
tree0992e4e35bd056d4b9c4042538da3e03522c4c5d /ui/gfx/canvas_skia_win.cc
parent021506c928c6b699a5ca59cd722517f7be497234 (diff)
downloadchromium_src-e0cf664f805d83c64e648e011786de1dc29c9f21.zip
chromium_src-e0cf664f805d83c64e648e011786de1dc29c9f21.tar.gz
chromium_src-e0cf664f805d83c64e648e011786de1dc29c9f21.tar.bz2
Fix crash in fade tab title change
The fade tab title change is causing the browser to crash on some computers. It looks like the problem is in BitmapPlatformDevice::create(). For some reason it's returning NULL. This change just adds a NULL check and falls back to the old drawing code. Once this is checked in I'll investigate what the root cause is. BUG=78857 TEST=Compiled and ran. Review URL: http://codereview.chromium.org/6823020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/canvas_skia_win.cc')
-rw-r--r--ui/gfx/canvas_skia_win.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/ui/gfx/canvas_skia_win.cc b/ui/gfx/canvas_skia_win.cc
index 41a4f44..570e803 100644
--- a/ui/gfx/canvas_skia_win.cc
+++ b/ui/gfx/canvas_skia_win.cc
@@ -469,9 +469,19 @@ void CanvasSkia::DrawFadeTruncatingString(
int total_string_height;
SizeStringInt(text, font, &total_string_width, &total_string_height,
flags | TEXT_VALIGN_TOP);
- if (total_string_width <= display_rect.width()) {
+ 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) {
DrawStringInt(text, font, color, display_rect.x(), display_rect.y(),
- display_rect.width(), display_rect.height(), flags);
+ display_rect.width(), display_rect.height(), 0);
return;
}
@@ -556,9 +566,6 @@ void CanvasSkia::DrawFadeTruncatingString(
HFONT gray_scale_font = CreateFontIndirect(&font_info);
HDC hdc = beginPlatformPaint();
- scoped_ptr<skia::BitmapPlatformDevice> gradient_bitmap(
- skia::BitmapPlatformDevice::create(NULL, display_rect.width(),
- display_rect.height(), false, NULL));
if (is_truncating_head)
DrawTextGradientPart(hdc, *gradient_bitmap, text, color, gray_scale_font,
text_rect, head_part, is_rtl, flags);