| OLD | NEW |
| 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/border.h" | 5 #include "ui/views/border.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "third_party/skia/include/core/SkPaint.h" | 12 #include "cc/paint/paint_flags.h" |
| 13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
| 14 #include "ui/gfx/geometry/rect_f.h" | 14 #include "ui/gfx/geometry/rect_f.h" |
| 15 #include "ui/views/painter.h" | 15 #include "ui/views/painter.h" |
| 16 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // A simple border with different thicknesses on each side and single color. | 22 // A simple border with different thicknesses on each side and single color. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(RoundedRectBorder); | 82 DISALLOW_COPY_AND_ASSIGN(RoundedRectBorder); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 RoundedRectBorder::RoundedRectBorder(int thickness, | 85 RoundedRectBorder::RoundedRectBorder(int thickness, |
| 86 int corner_radius, | 86 int corner_radius, |
| 87 SkColor color) | 87 SkColor color) |
| 88 : thickness_(thickness), corner_radius_(corner_radius), color_(color) {} | 88 : thickness_(thickness), corner_radius_(corner_radius), color_(color) {} |
| 89 | 89 |
| 90 void RoundedRectBorder::Paint(const View& view, gfx::Canvas* canvas) { | 90 void RoundedRectBorder::Paint(const View& view, gfx::Canvas* canvas) { |
| 91 SkPaint paint; | 91 cc::PaintFlags paint; |
| 92 paint.setStrokeWidth(thickness_); | 92 paint.setStrokeWidth(thickness_); |
| 93 paint.setColor(color_); | 93 paint.setColor(color_); |
| 94 paint.setStyle(SkPaint::kStroke_Style); | 94 paint.setStyle(cc::PaintFlags::kStroke_Style); |
| 95 paint.setAntiAlias(true); | 95 paint.setAntiAlias(true); |
| 96 | 96 |
| 97 float half_thickness = thickness_ / 2.0f; | 97 float half_thickness = thickness_ / 2.0f; |
| 98 gfx::RectF bounds(view.GetLocalBounds()); | 98 gfx::RectF bounds(view.GetLocalBounds()); |
| 99 bounds.Inset(half_thickness, half_thickness); | 99 bounds.Inset(half_thickness, half_thickness); |
| 100 canvas->DrawRoundRect(bounds, corner_radius_, paint); | 100 canvas->DrawRoundRect(bounds, corner_radius_, paint); |
| 101 } | 101 } |
| 102 | 102 |
| 103 gfx::Insets RoundedRectBorder::GetInsets() const { | 103 gfx::Insets RoundedRectBorder::GetInsets() const { |
| 104 return gfx::Insets(thickness_); | 104 return gfx::Insets(thickness_); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 const gfx::Insets& insets) { | 249 const gfx::Insets& insets) { |
| 250 return base::MakeUnique<ExtraInsetsBorder>(std::move(border), insets); | 250 return base::MakeUnique<ExtraInsetsBorder>(std::move(border), insets); |
| 251 } | 251 } |
| 252 | 252 |
| 253 std::unique_ptr<Border> CreateBorderPainter(std::unique_ptr<Painter> painter, | 253 std::unique_ptr<Border> CreateBorderPainter(std::unique_ptr<Painter> painter, |
| 254 const gfx::Insets& insets) { | 254 const gfx::Insets& insets) { |
| 255 return base::WrapUnique(new BorderPainter(std::move(painter), insets)); | 255 return base::WrapUnique(new BorderPainter(std::move(painter), insets)); |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace views | 258 } // namespace views |
| OLD | NEW |