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.
5 #include "ui/views/round_rect_painter.h"
7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/path.h"
9 #include "ui/gfx/skia_util.h"
13 RoundRectPainter::RoundRectPainter(SkColor border_color
, int corner_radius
)
14 : border_color_(border_color
),
15 corner_radius_(corner_radius
) {
18 RoundRectPainter::~RoundRectPainter() {
21 void RoundRectPainter::Paint(gfx::Canvas
* canvas
, const gfx::Size
& size
) {
23 paint
.setColor(border_color_
);
24 paint
.setStyle(SkPaint::kStroke_Style
);
25 paint
.setStrokeWidth(1);
26 paint
.setFlags(SkPaint::kAntiAlias_Flag
);
28 rect
.Inset(0, 0, 1, 1);
29 SkRect skia_rect
= gfx::RectToSkRect(rect
);
30 skia_rect
.offset(.5, .5);
31 canvas
->sk_canvas()->drawRoundRect(skia_rect
, SkIntToScalar(corner_radius_
),
32 SkIntToScalar(corner_radius_
), paint
);