Chromium Code Reviews| Index: chrome/browser/ui/views/infobars/infobar_background.cc |
| diff --git a/chrome/browser/ui/views/infobars/infobar_background.cc b/chrome/browser/ui/views/infobars/infobar_background.cc |
| index 71fa45c835e02c4ce91b8bed2bedef6562335e62..a1f8e0b8620aac01e85005941aee5f9d969cca04 100644 |
| --- a/chrome/browser/ui/views/infobars/infobar_background.cc |
| +++ b/chrome/browser/ui/views/infobars/infobar_background.cc |
| @@ -4,18 +4,19 @@ |
| #include "chrome/browser/ui/views/infobars/infobar_background.h" |
| +#include "chrome/browser/ui/views/infobars/infobar_view.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/canvas.h" |
| +#include "ui/gfx/canvas_skia_paint.h" |
| +#include "third_party/skia/include/effects/SkGradientShader.h" |
| #include "views/view.h" |
| // static |
| const int InfoBarBackground::kSeparatorLineHeight = 1; |
| -InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type) { |
| - gradient_background_.reset( |
| - views::Background::CreateVerticalGradientBackground( |
| - GetTopColor(infobar_type), |
| - GetBottomColor(infobar_type))); |
| +InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type) |
| + : top_color_(GetTopColor(infobar_type)), |
| + bottom_color_(GetBottomColor(infobar_type)) { |
| } |
| InfoBarBackground::~InfoBarBackground() { |
| @@ -42,7 +43,35 @@ SkColor InfoBarBackground::GetBottomColor(InfoBarDelegate::Type infobar_type) { |
| } |
| void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const { |
| - gradient_background_->Paint(canvas, view); |
| + SkPoint gradient_points[2] = { |
| + {SkIntToScalar(0), SkIntToScalar(0)}, |
| + {SkIntToScalar(0), SkIntToScalar(view->height())} |
| + }; |
| + SkColor gradient_colors[2] = { |
| + top_color_, |
| + bottom_color_ |
| + }; |
| + SkShader* gradient_shader = |
|
Peter Kasting
2011/03/08 23:21:31
Nit: Could also wrap like this if you want, and sa
Sheridan Rawlins
2011/03/09 00:18:26
Done.
|
| + SkGradientShader::CreateLinear(gradient_points, gradient_colors, |
| + NULL, 2, SkShader::kClamp_TileMode); |
| + SkPaint paint; |
| + paint.setStrokeWidth(1.0); |
| + paint.setStyle(SkPaint::kFill_Style); |
| + paint.setShader(gradient_shader); |
| + paint.setAntiAlias(true); |
| + gradient_shader->unref(); |
| + |
| + InfoBarView* infobar = static_cast<InfoBarView*>(view); |
| + gfx::CanvasSkia* canvas_skia = canvas->AsCanvasSkia(); |
| + canvas_skia->drawPath(*infobar->fill_path(), paint); |
| + |
| + paint.setShader(NULL); |
| + paint.setColor(SkColorSetA(ResourceBundle::toolbar_separator_color, |
| + SkColorGetA(gradient_colors[0]))); |
| + paint.setStyle(SkPaint::kStroke_Style); |
| + canvas_skia->drawPath(*infobar->stroke_path(), paint); |
| + |
| + // Now draw at the bottom. |
| canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 0, |
| view->height() - kSeparatorLineHeight, view->width(), |
| kSeparatorLineHeight); |