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..e72f9e5f33c880c90f9795cf3dc9f719a5005057 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,36 @@ 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 = |
| + SkGradientShader::CreateLinear(gradient_points, gradient_colors, |
| + NULL, 2, SkShader::kMirror_TileMode); |
|
Peter Kasting
2011/03/04 22:23:42
Nit: Seems like kClamp_TileMode would make it clea
Sheridan Rawlins
2011/03/05 18:06:54
Yes, this agrees with views/painter.cc
Done.
|
| + SkPaint paint; |
| + paint.setStrokeWidth(1); |
| + 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.setStrokeCap(SkPaint::kSquare_Cap); |
|
Peter Kasting
2011/03/04 22:23:42
Why do this? The default (no) cap seems better.
Sheridan Rawlins
2011/03/05 18:06:54
It's how the mac is implemented:
http://codesearch
|
| + 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); |