| 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/extensions/extension_action.h" | 5 #include "chrome/common/extensions/extension_action.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/app/chrome_dll_resource.h" | |
| 12 #include "gfx/canvas_skia.h" | 11 #include "gfx/canvas_skia.h" |
| 13 #include "gfx/font.h" | 12 #include "gfx/font.h" |
| 14 #include "gfx/rect.h" | 13 #include "gfx/rect.h" |
| 15 #include "grit/app_resources.h" | 14 #include "grit/app_resources.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 #include "third_party/skia/include/core/SkTypeface.h" | 16 #include "third_party/skia/include/core/SkTypeface.h" |
| 18 #include "third_party/skia/include/effects/SkGradientShader.h" | 17 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 19 | 18 |
| 20 namespace { | 19 namespace { |
| 21 | 20 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 rect.fRight = rect.fLeft + SkIntToScalar(badge_width); | 150 rect.fRight = rect.fLeft + SkIntToScalar(badge_width); |
| 152 } else { | 151 } else { |
| 153 rect.fRight = SkIntToScalar(bounds.right()); | 152 rect.fRight = SkIntToScalar(bounds.right()); |
| 154 rect.fLeft = rect.fRight - badge_width; | 153 rect.fLeft = rect.fRight - badge_width; |
| 155 } | 154 } |
| 156 | 155 |
| 157 SkPaint rect_paint; | 156 SkPaint rect_paint; |
| 158 rect_paint.setStyle(SkPaint::kFill_Style); | 157 rect_paint.setStyle(SkPaint::kFill_Style); |
| 159 rect_paint.setAntiAlias(true); | 158 rect_paint.setAntiAlias(true); |
| 160 rect_paint.setColor(background_color); | 159 rect_paint.setColor(background_color); |
| 161 canvas->AsCanvasSkia()->drawRoundRect(rect, SkIntToScalar(2), SkIntToScalar(2)
, | 160 canvas->AsCanvasSkia()->drawRoundRect(rect, SkIntToScalar(2), |
| 161 SkIntToScalar(2), |
| 162 rect_paint); | 162 rect_paint); |
| 163 | 163 |
| 164 // Overlay the gradient. It is stretchy, so we do this in three parts. | 164 // Overlay the gradient. It is stretchy, so we do this in three parts. |
| 165 ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance(); | 165 ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance(); |
| 166 SkBitmap* gradient_left = resource_bundle.GetBitmapNamed( | 166 SkBitmap* gradient_left = resource_bundle.GetBitmapNamed( |
| 167 IDR_BROWSER_ACTION_BADGE_LEFT); | 167 IDR_BROWSER_ACTION_BADGE_LEFT); |
| 168 SkBitmap* gradient_right = resource_bundle.GetBitmapNamed( | 168 SkBitmap* gradient_right = resource_bundle.GetBitmapNamed( |
| 169 IDR_BROWSER_ACTION_BADGE_RIGHT); | 169 IDR_BROWSER_ACTION_BADGE_RIGHT); |
| 170 SkBitmap* gradient_center = resource_bundle.GetBitmapNamed( | 170 SkBitmap* gradient_center = resource_bundle.GetBitmapNamed( |
| 171 IDR_BROWSER_ACTION_BADGE_CENTER); | 171 IDR_BROWSER_ACTION_BADGE_CENTER); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 184 // text was too large. | 184 // text was too large. |
| 185 rect.fLeft += kPadding; | 185 rect.fLeft += kPadding; |
| 186 rect.fRight -= kPadding; | 186 rect.fRight -= kPadding; |
| 187 canvas->AsCanvasSkia()->clipRect(rect); | 187 canvas->AsCanvasSkia()->clipRect(rect); |
| 188 canvas->AsCanvasSkia()->drawText(text.c_str(), text.size(), | 188 canvas->AsCanvasSkia()->drawText(text.c_str(), text.size(), |
| 189 rect.fLeft + (rect.width() - text_width) / 2, | 189 rect.fLeft + (rect.width() - text_width) / 2, |
| 190 rect.fTop + kTextSize + kTopTextPadding, | 190 rect.fTop + kTextSize + kTopTextPadding, |
| 191 *text_paint); | 191 *text_paint); |
| 192 canvas->AsCanvasSkia()->restore(); | 192 canvas->AsCanvasSkia()->restore(); |
| 193 } | 193 } |
| OLD | NEW |