Index: chrome/common/badge_util.cc |
diff --git a/chrome/common/badge_util.cc b/chrome/common/badge_util.cc |
index 7ef0b5af40fe4f8b3e5e995929f28fabc7a9cc7e..29b197771575c5664d5d4b88105839e339100950 100644 |
--- a/chrome/common/badge_util.cc |
+++ b/chrome/common/badge_util.cc |
@@ -18,18 +18,18 @@ |
namespace { |
// Different platforms need slightly different constants to look good. |
-#if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) |
-const float kTextSize = 9.0; |
+#if defined(OS_CHROMEOS) |
Lei Zhang
2014/05/23 21:23:02
Can we restructure this?
#if defined(OS_WIN)
#eli
|
+const float kTextSize = 8.0; |
const int kBottomMarginBrowserAction = 0; |
const int kBottomMarginPageAction = 2; |
const int kPadding = 2; |
-const int kTopTextPadding = 0; |
-#elif defined(OS_LINUX) && defined(TOOLKIT_VIEWS) |
-const float kTextSize = 8.0; |
+const int kTopTextPadding = 1; |
+#elif defined(OS_LINUX) |
+const float kTextSize = 9.0; |
const int kBottomMarginBrowserAction = 0; |
const int kBottomMarginPageAction = 2; |
const int kPadding = 2; |
-const int kTopTextPadding = 1; |
+const int kTopTextPadding = 0; |
#elif defined(OS_MACOSX) |
const float kTextSize = 9.0; |
const int kBottomMarginBrowserAction = 5; |
@@ -92,53 +92,6 @@ SkPaint* GetBadgeTextPaintSingleton() { |
return text_paint; |
} |
-SkBitmap DrawBadgeIconOverlay(const SkBitmap& icon, |
- float font_size, |
- const base::string16& text, |
- const base::string16& fallback) { |
- const int kMinPadding = 1; |
- |
- // Calculate the proper style/text overlay to render on the badge. |
- SkPaint* paint = badge_util::GetBadgeTextPaintSingleton(); |
- paint->setTextSize(SkFloatToScalar(font_size)); |
- paint->setColor(SK_ColorWHITE); |
- |
- std::string badge_text = base::UTF16ToUTF8(text); |
- |
- // See if the text will fit - otherwise use a default. |
- SkScalar text_width = paint->measureText(badge_text.c_str(), |
- badge_text.size()); |
- |
- if (SkScalarRoundToInt(text_width) > (icon.width() - kMinPadding * 2)) { |
- // String is too large - use the alternate text. |
- badge_text = base::UTF16ToUTF8(fallback); |
- text_width = paint->measureText(badge_text.c_str(), badge_text.size()); |
- } |
- |
- // When centering the text, we need to make sure there are an equal number |
- // of pixels on each side as otherwise the text looks off-center. So if the |
- // padding would be uneven, clip one pixel off the right side. |
- int badge_width = icon.width(); |
- if ((SkScalarRoundToInt(text_width) % 1) != (badge_width % 1)) |
- badge_width--; |
- |
- // Render the badge bitmap and overlay into a canvas. |
- scoped_ptr<gfx::Canvas> canvas(new gfx::Canvas( |
- gfx::Size(badge_width, icon.height()), 1.0f, false)); |
- canvas->DrawImageInt(gfx::ImageSkia::CreateFrom1xBitmap(icon), 0, 0); |
- |
- // Draw the text overlay centered horizontally and vertically. Skia expects |
- // us to specify the lower left coordinate of the text box, which is why we |
- // add 'font_size - 1' to the height. |
- SkScalar x = (badge_width - text_width)/2; |
- SkScalar y = (icon.height() - font_size)/2 + font_size - 1; |
- canvas->sk_canvas()->drawText( |
- badge_text.c_str(), badge_text.size(), x, y, *paint); |
- |
- // Return the generated image. |
- return canvas->ExtractImageRep().sk_bitmap(); |
-} |
- |
void PaintBadge(gfx::Canvas* canvas, |
const gfx::Rect& bounds, |
const std::string& text, |