This source file includes following definitions.
- bottom_color_
- Paint
#include "chrome/browser/ui/views/infobars/infobar_background.h"
#include "chrome/browser/infobars/infobar.h"
#include "chrome/browser/ui/views/infobars/infobar_view.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/views/view.h"
InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type)
: separator_color_(SK_ColorBLACK),
top_color_(InfoBar::GetTopColor(infobar_type)),
bottom_color_(InfoBar::GetBottomColor(infobar_type)) {
SetNativeControlColor(
color_utils::AlphaBlend(top_color_, bottom_color_, 128));
}
InfoBarBackground::~InfoBarBackground() {
}
void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
SkPoint gradient_points[2];
gradient_points[0].iset(0, 0);
gradient_points[1].iset(0, view->height());
SkColor gradient_colors[2] = { top_color_, bottom_color_ };
skia::RefPtr<SkShader> gradient_shader = skia::AdoptRef(
SkGradientShader::CreateLinear(gradient_points, gradient_colors, NULL, 2,
SkShader::kClamp_TileMode));
SkPaint paint;
paint.setStrokeWidth(SkIntToScalar(InfoBar::kSeparatorLineHeight));
paint.setStyle(SkPaint::kFill_Style);
paint.setStrokeCap(SkPaint::kRound_Cap);
paint.setShader(gradient_shader.get());
InfoBarView* infobar = static_cast<InfoBarView*>(view);
SkCanvas* canvas_skia = canvas->sk_canvas();
canvas_skia->drawPath(infobar->fill_path(), paint);
paint.setShader(NULL);
paint.setColor(SkColorSetA(separator_color_,
SkColorGetA(gradient_colors[0])));
paint.setStyle(SkPaint::kStroke_Style);
paint.setAntiAlias(true);
canvas_skia->drawPath(infobar->stroke_path(), paint);
paint.setAntiAlias(false);
canvas->FillRect(gfx::Rect(0, view->height() - InfoBar::kSeparatorLineHeight,
view->width(), InfoBar::kSeparatorLineHeight),
separator_color_);
}