OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation/ink_drop_painted_layer_delegates.h" | 5 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkPaint.h" | 7 #include "third_party/skia/include/core/SkPaint.h" |
8 #include "ui/compositor/paint_recorder.h" | 8 #include "ui/compositor/paint_recorder.h" |
9 #include "ui/gfx/geometry/point.h" | 9 #include "ui/gfx/geometry/point.h" |
10 #include "ui/gfx/geometry/point_conversions.h" | 10 #include "ui/gfx/geometry/point_conversions.h" |
| 11 #include "ui/gfx/geometry/rect_f.h" |
11 | 12 |
12 namespace views { | 13 namespace views { |
13 | 14 |
14 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
15 // | 16 // |
16 // BasePaintedLayerDelegate | 17 // BasePaintedLayerDelegate |
17 // | 18 // |
18 | 19 |
19 BasePaintedLayerDelegate::BasePaintedLayerDelegate(SkColor color) | 20 BasePaintedLayerDelegate::BasePaintedLayerDelegate(SkColor color) |
20 : color_(color) {} | 21 : color_(color) {} |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 SkPaint paint; | 76 SkPaint paint; |
76 paint.setColor(color()); | 77 paint.setColor(color()); |
77 paint.setFlags(SkPaint::kAntiAlias_Flag); | 78 paint.setFlags(SkPaint::kAntiAlias_Flag); |
78 paint.setStyle(SkPaint::kFill_Style); | 79 paint.setStyle(SkPaint::kFill_Style); |
79 | 80 |
80 ui::PaintRecorder recorder(context, size_); | 81 ui::PaintRecorder recorder(context, size_); |
81 gfx::Canvas* canvas = recorder.canvas(); | 82 gfx::Canvas* canvas = recorder.canvas(); |
82 canvas->DrawRect(gfx::Rect(size_), paint); | 83 canvas->DrawRect(gfx::Rect(size_), paint); |
83 } | 84 } |
84 | 85 |
| 86 //////////////////////////////////////////////////////////////////////////////// |
| 87 // |
| 88 // RoundedRectangleLayerDelegate |
| 89 // |
| 90 |
| 91 RoundedRectangleLayerDelegate::RoundedRectangleLayerDelegate(SkColor color, |
| 92 gfx::Size size, |
| 93 int corner_radius) |
| 94 : BasePaintedLayerDelegate(color), |
| 95 size_(size), |
| 96 corner_radius_(corner_radius) {} |
| 97 |
| 98 RoundedRectangleLayerDelegate::~RoundedRectangleLayerDelegate() {} |
| 99 |
| 100 gfx::PointF RoundedRectangleLayerDelegate::GetCenterPoint() const { |
| 101 return gfx::RectF(gfx::SizeF(size_)).CenterPoint(); |
| 102 } |
| 103 |
| 104 void RoundedRectangleLayerDelegate::OnPaintLayer( |
| 105 const ui::PaintContext& context) { |
| 106 SkPaint paint; |
| 107 paint.setColor(color()); |
| 108 paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 109 paint.setStyle(SkPaint::kFill_Style); |
| 110 |
| 111 ui::PaintRecorder recorder(context, size_); |
| 112 gfx::Canvas* canvas = recorder.canvas(); |
| 113 canvas->DrawRoundRect(gfx::Rect(size_), corner_radius_, paint); |
| 114 } |
| 115 |
85 } // namespace views | 116 } // namespace views |
OLD | NEW |