| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/badge_util.h" | 5 #include "chrome/common/badge_util.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "gfx/canvas_skia.h" | |
| 9 #include "gfx/font.h" | |
| 10 #include "third_party/skia/include/core/SkPaint.h" | 8 #include "third_party/skia/include/core/SkPaint.h" |
| 11 #include "third_party/skia/include/core/SkTypeface.h" | 9 #include "third_party/skia/include/core/SkTypeface.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| 11 #include "ui/gfx/canvas_skia.h" |
| 12 #include "ui/gfx/font.h" |
| 13 | 13 |
| 14 namespace badge_util { | 14 namespace badge_util { |
| 15 | 15 |
| 16 SkPaint* GetBadgeTextPaintSingleton() { | 16 SkPaint* GetBadgeTextPaintSingleton() { |
| 17 #if defined(OS_MACOSX) | 17 #if defined(OS_MACOSX) |
| 18 const char kPreferredTypeface[] = "Helvetica Bold"; | 18 const char kPreferredTypeface[] = "Helvetica Bold"; |
| 19 #else | 19 #else |
| 20 const char kPreferredTypeface[] = "Arial"; | 20 const char kPreferredTypeface[] = "Arial"; |
| 21 #endif | 21 #endif |
| 22 | 22 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // add 'font_size - 1' to the height. | 90 // add 'font_size - 1' to the height. |
| 91 SkScalar x = (badge_width - text_width)/2; | 91 SkScalar x = (badge_width - text_width)/2; |
| 92 SkScalar y = (icon.height() - font_size)/2 + font_size - 1; | 92 SkScalar y = (icon.height() - font_size)/2 + font_size - 1; |
| 93 canvas->drawText(badge_text.c_str(), badge_text.size(), x, y, *paint); | 93 canvas->drawText(badge_text.c_str(), badge_text.size(), x, y, *paint); |
| 94 | 94 |
| 95 // Return the generated image. | 95 // Return the generated image. |
| 96 return canvas->ExtractBitmap(); | 96 return canvas->ExtractBitmap(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace badge_util | 99 } // namespace badge_util |
| OLD | NEW |