Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/extension_action_util.h" | |
| 6 | |
| 7 #include "chrome/browser/themes/theme_service.h" | |
| 8 #include "chrome/common/extensions/extension_action.h" | |
| 9 #include "third_party/skia/include/core/SkPaint.h" | |
| 10 #include "third_party/skia/include/effects/SkGradientShader.h" | |
| 11 #include "ui/gfx/canvas.h" | |
| 12 #include "ui/gfx/color_utils.h" | |
| 13 #include "ui/gfx/rect.h" | |
| 14 | |
| 15 namespace extensions { | |
| 16 | |
| 17 void PaintBackground(const ExtensionAction& action, | |
| 18 int tab_id, | |
| 19 gfx::Canvas* canvas, | |
| 20 const gfx::Rect& bounds, | |
| 21 const ui::ThemeProvider& theme) { | |
| 22 if (action.WantsAttention(tab_id)) { | |
| 23 SkPoint gradient_bounds[2] = { {SkIntToScalar(bounds.x()), | |
| 24 SkIntToScalar(bounds.y())}, | |
| 25 {SkIntToScalar(bounds.x()), | |
| 26 SkIntToScalar(bounds.bottom())} }; | |
| 27 const SkColor text_color = theme.GetColor(ThemeService::COLOR_NTP_TEXT); | |
|
Jeffrey Yasskin
2012/09/05 21:10:19
This isn't exactly right, since chrome-themes can
| |
| 28 const SkColor background_color = | |
| 29 theme.GetColor(ThemeService::COLOR_NTP_BACKGROUND); | |
| 30 SkColor gradient_colors[2] = { | |
| 31 color_utils::AlphaBlend(text_color, background_color, 0x13), | |
| 32 color_utils::AlphaBlend(text_color, background_color, 0x1d) | |
| 33 }; | |
| 34 SkShader* gradient = SkGradientShader::CreateLinear( | |
| 35 gradient_bounds, gradient_colors, NULL, 2, SkShader::kClamp_TileMode); | |
| 36 SkPaint paint; | |
| 37 paint.setShader(gradient); | |
| 38 gradient->unref(); | |
| 39 canvas->DrawRect(bounds, paint); | |
| 40 | |
| 41 SkColor border_color = | |
| 42 color_utils::AlphaBlend(text_color, background_color, 0x55); | |
| 43 canvas->DrawLine(gfx::Point(bounds.x(), bounds.y()), | |
| 44 gfx::Point(bounds.x(), bounds.bottom()), | |
| 45 border_color); | |
| 46 // "-1" because gfx::Rects are half-open, not including their right or | |
| 47 // bottom edges. | |
| 48 canvas->DrawLine(gfx::Point(bounds.right() - 1, bounds.y()), | |
| 49 gfx::Point(bounds.right() - 1, bounds.bottom()), | |
| 50 border_color); | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 } // namespace extensions | |
| OLD | NEW |