Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: ui/views/round_rect_painter.cc

Issue 12041085: Fix menu corners: the menu background was being painted as a rect when in fact, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/round_rect_painter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/round_rect_painter.h" 5 #include "ui/views/round_rect_painter.h"
6 6
7 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/path.h" 8 #include "ui/gfx/path.h"
9 #include "ui/gfx/skia_util.h" 9 #include "ui/gfx/skia_util.h"
10 10
11 namespace views { 11 namespace views {
12 12
13 static const int kRadius = 2; 13 RoundRectPainter::RoundRectPainter(SkColor border_color, int corner_radius)
14 14 : border_color_(border_color),
15 RoundRectPainter::RoundRectPainter(SkColor border_color) 15 corner_radius_(corner_radius) {
16 : border_color_(border_color) {
17 } 16 }
18 17
19 RoundRectPainter::~RoundRectPainter() { 18 RoundRectPainter::~RoundRectPainter() {
20 } 19 }
21 20
22 void RoundRectPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { 21 void RoundRectPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
23 SkPaint paint; 22 SkPaint paint;
24 paint.setColor(border_color_); 23 paint.setColor(border_color_);
25 paint.setStyle(SkPaint::kStroke_Style); 24 paint.setStyle(SkPaint::kStroke_Style);
26 paint.setStrokeWidth(1); 25 paint.setStrokeWidth(1);
27 paint.setFlags(SkPaint::kAntiAlias_Flag); 26 paint.setFlags(SkPaint::kAntiAlias_Flag);
28 gfx::Rect rect(size); 27 gfx::Rect rect(size);
29 rect.Inset(0, 0, 1, 1); 28 rect.Inset(0, 0, 1, 1);
30 SkRect skia_rect = gfx::RectToSkRect(rect); 29 SkRect skia_rect = gfx::RectToSkRect(rect);
31 skia_rect.offset(.5, .5); 30 skia_rect.offset(.5, .5);
32 canvas->sk_canvas()->drawRoundRect(skia_rect, SkIntToScalar(kRadius), 31 canvas->sk_canvas()->drawRoundRect(skia_rect, SkIntToScalar(corner_radius_),
33 SkIntToScalar(kRadius), paint); 32 SkIntToScalar(corner_radius_), paint);
34 }
35
36 // static
37 void RoundRectPainter::CreateRoundRectPath(const gfx::Rect& bounds,
38 gfx::Path* path) {
39 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()),
40 SkIntToScalar(bounds.height()));
41 SkScalar radius = SkIntToScalar(kRadius);
42 SkScalar radii[8] = {radius, radius, radius, radius,
43 radius, radius, radius, radius};
44 path->addRoundRect(rect, radii);
45 } 33 }
46 34
47 } // namespace views 35 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/round_rect_painter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698