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" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 SkPaint paint; | 75 SkPaint paint; |
76 paint.setColor(color()); | 76 paint.setColor(color()); |
77 paint.setFlags(SkPaint::kAntiAlias_Flag); | 77 paint.setFlags(SkPaint::kAntiAlias_Flag); |
78 paint.setStyle(SkPaint::kFill_Style); | 78 paint.setStyle(SkPaint::kFill_Style); |
79 | 79 |
80 ui::PaintRecorder recorder(context, size_); | 80 ui::PaintRecorder recorder(context, size_); |
81 gfx::Canvas* canvas = recorder.canvas(); | 81 gfx::Canvas* canvas = recorder.canvas(); |
82 canvas->DrawRect(gfx::Rect(size_), paint); | 82 canvas->DrawRect(gfx::Rect(size_), paint); |
83 } | 83 } |
84 | 84 |
85 //////////////////////////////////////////////////////////////////////////////// | |
86 // | |
87 // RoundedRectangleLayerDelegate | |
88 // | |
89 | |
90 RoundedRectangleLayerDelegate::RoundedRectangleLayerDelegate(SkColor color, | |
91 gfx::Size size, | |
92 int corner_radius) | |
93 : BasePaintedLayerDelegate(color), | |
94 size_(size), | |
95 corner_radius_(corner_radius) {} | |
96 | |
97 RoundedRectangleLayerDelegate::~RoundedRectangleLayerDelegate() {} | |
98 | |
99 gfx::PointF RoundedRectangleLayerDelegate::GetCenterPoint() const { | |
100 return gfx::PointF(size_.width() / 2.0f, size_.height() / 2.0f); | |
varkha
2016/01/22 15:45:32
Could use gfx::Rect(size_)::CenterPoint().
bruthig
2016/01/25 22:39:17
Done.
| |
101 } | |
102 | |
103 void RoundedRectangleLayerDelegate::OnPaintLayer( | |
104 const ui::PaintContext& context) { | |
105 SkPaint paint; | |
106 paint.setColor(color()); | |
107 paint.setFlags(SkPaint::kAntiAlias_Flag); | |
108 paint.setStyle(SkPaint::kFill_Style); | |
109 | |
110 ui::PaintRecorder recorder(context, size_); | |
111 gfx::Canvas* canvas = recorder.canvas(); | |
112 canvas->DrawRoundRect(gfx::Rect(size_), corner_radius_, paint); | |
113 } | |
114 | |
85 } // namespace views | 115 } // namespace views |
OLD | NEW |