OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "third_party/skia/include/core/SkPaint.h" | 11 #include "third_party/skia/include/core/SkPaint.h" |
12 #include "third_party/skia/include/core/SkTypeface.h" | 12 #include "third_party/skia/include/core/SkTypeface.h" |
13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
15 #include "ui/gfx/font.h" | 15 #include "ui/gfx/font.h" |
16 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
17 #include "ui/gfx/size.h" | 17 #include "ui/gfx/geometry/size.h" |
18 #include "ui/resources/grit/ui_resources.h" | 18 #include "ui/resources/grit/ui_resources.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // Different platforms need slightly different constants to look good. | 22 // Different platforms need slightly different constants to look good. |
23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
24 const float kTextSize = 10; | 24 const float kTextSize = 10; |
25 const int kBottomMarginBrowserAction = 0; | 25 const int kBottomMarginBrowserAction = 0; |
26 const int kBottomMarginPageAction = 2; | 26 const int kBottomMarginPageAction = 2; |
27 const int kPadding = 2; | 27 const int kPadding = 2; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 canvas->sk_canvas()->drawText( | 187 canvas->sk_canvas()->drawText( |
188 text.c_str(), text.size(), | 188 text.c_str(), text.size(), |
189 SkFloatToScalar(rect.x() + | 189 SkFloatToScalar(rect.x() + |
190 static_cast<float>(rect.width() - text_width) / 2), | 190 static_cast<float>(rect.width() - text_width) / 2), |
191 SkFloatToScalar(rect.y() + kTextSize + kTopTextPadding), | 191 SkFloatToScalar(rect.y() + kTextSize + kTopTextPadding), |
192 *text_paint); | 192 *text_paint); |
193 canvas->Restore(); | 193 canvas->Restore(); |
194 } | 194 } |
195 | 195 |
196 } // namespace badge_util | 196 } // namespace badge_util |
OLD | NEW |