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

Side by Side Diff: ui/views/animation/ink_drop_painted_layer_delegates.cc

Issue 1422593003: Made material design ink drop QUICK_ACTION animation more visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added varkha@'s behavioural changes Created 5 years, 1 month 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
OLDNEW
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 11
11 namespace views { 12 namespace views {
12 13
13 //////////////////////////////////////////////////////////////////////////////// 14 ////////////////////////////////////////////////////////////////////////////////
14 // 15 //
15 // BasePaintedLayerDelegate 16 // BasePaintedLayerDelegate
16 // 17 //
17 18
18 BasePaintedLayerDelegate::BasePaintedLayerDelegate(SkColor color) 19 BasePaintedLayerDelegate::BasePaintedLayerDelegate(SkColor color)
19 : color_(color) {} 20 : color_(color) {}
(...skipping 13 matching lines...) Expand all
33 //////////////////////////////////////////////////////////////////////////////// 34 ////////////////////////////////////////////////////////////////////////////////
34 // 35 //
35 // CircleLayerDelegate 36 // CircleLayerDelegate
36 // 37 //
37 38
38 CircleLayerDelegate::CircleLayerDelegate(SkColor color, int radius) 39 CircleLayerDelegate::CircleLayerDelegate(SkColor color, int radius)
39 : BasePaintedLayerDelegate(color), radius_(radius) {} 40 : BasePaintedLayerDelegate(color), radius_(radius) {}
40 41
41 CircleLayerDelegate::~CircleLayerDelegate() {} 42 CircleLayerDelegate::~CircleLayerDelegate() {}
42 43
44 gfx::PointF CircleLayerDelegate::GetCenterPoint() const {
45 return gfx::PointF(radius_, radius_);
46 }
47
43 void CircleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) { 48 void CircleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
44 SkPaint paint; 49 SkPaint paint;
45 paint.setColor(color()); 50 paint.setColor(color());
46 paint.setFlags(SkPaint::kAntiAlias_Flag); 51 paint.setFlags(SkPaint::kAntiAlias_Flag);
47 paint.setStyle(SkPaint::kFill_Style); 52 paint.setStyle(SkPaint::kFill_Style);
48 53
49 ui::PaintRecorder recorder(context, gfx::Size(radius_, radius_)); 54 ui::PaintRecorder recorder(context, gfx::Size(radius_, radius_));
50 gfx::Canvas* canvas = recorder.canvas(); 55 gfx::Canvas* canvas = recorder.canvas();
51 56
52 gfx::Point center_point = gfx::Point(radius_, radius_); 57 canvas->DrawCircle(ToRoundedPoint(GetCenterPoint()), radius_, paint);
53 canvas->DrawCircle(center_point, radius_, paint);
54 } 58 }
55 59
56 //////////////////////////////////////////////////////////////////////////////// 60 ////////////////////////////////////////////////////////////////////////////////
57 // 61 //
58 // RectangleLayerDelegate 62 // RectangleLayerDelegate
59 // 63 //
60 64
61 RectangleLayerDelegate::RectangleLayerDelegate(SkColor color, gfx::Size size) 65 RectangleLayerDelegate::RectangleLayerDelegate(SkColor color, gfx::Size size)
62 : BasePaintedLayerDelegate(color), size_(size) {} 66 : BasePaintedLayerDelegate(color), size_(size) {}
63 67
64 RectangleLayerDelegate::~RectangleLayerDelegate() {} 68 RectangleLayerDelegate::~RectangleLayerDelegate() {}
65 69
70 gfx::PointF RectangleLayerDelegate::GetCenterPoint() const {
71 return gfx::PointF(size_.width() / 2.0f, size_.height() / 2.0f);
72 }
73
66 void RectangleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) { 74 void RectangleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
67 SkPaint paint; 75 SkPaint paint;
68 paint.setColor(color()); 76 paint.setColor(color());
69 paint.setFlags(SkPaint::kAntiAlias_Flag); 77 paint.setFlags(SkPaint::kAntiAlias_Flag);
70 paint.setStyle(SkPaint::kFill_Style); 78 paint.setStyle(SkPaint::kFill_Style);
71 79
72 ui::PaintRecorder recorder(context, size_); 80 ui::PaintRecorder recorder(context, size_);
73 gfx::Canvas* canvas = recorder.canvas(); 81 gfx::Canvas* canvas = recorder.canvas();
74 canvas->DrawRect(gfx::Rect(size_), paint); 82 canvas->DrawRect(gfx::Rect(size_), paint);
75 } 83 }
76 84
77 //////////////////////////////////////////////////////////////////////////////// 85 ////////////////////////////////////////////////////////////////////////////////
78 // 86 //
79 // RoundedRectangleLayerDelegate 87 // RoundedRectangleLayerDelegate
80 // 88 //
81 89
82 RoundedRectangleLayerDelegate::RoundedRectangleLayerDelegate(SkColor color, 90 RoundedRectangleLayerDelegate::RoundedRectangleLayerDelegate(SkColor color,
83 gfx::Size size, 91 gfx::Size size,
84 int corner_radius) 92 int corner_radius)
85 : BasePaintedLayerDelegate(color), 93 : BasePaintedLayerDelegate(color),
86 size_(size), 94 size_(size),
87 corner_radius_(corner_radius) {} 95 corner_radius_(corner_radius) {}
88 96
89 RoundedRectangleLayerDelegate::~RoundedRectangleLayerDelegate() {} 97 RoundedRectangleLayerDelegate::~RoundedRectangleLayerDelegate() {}
90 98
99 gfx::PointF RoundedRectangleLayerDelegate::GetCenterPoint() const {
100 return gfx::PointF(size_.width() / 2.0f, size_.height() / 2.0f);
101 }
102
91 void RoundedRectangleLayerDelegate::OnPaintLayer( 103 void RoundedRectangleLayerDelegate::OnPaintLayer(
92 const ui::PaintContext& context) { 104 const ui::PaintContext& context) {
93 SkPaint paint; 105 SkPaint paint;
94 paint.setColor(color()); 106 paint.setColor(color());
95 paint.setFlags(SkPaint::kAntiAlias_Flag); 107 paint.setFlags(SkPaint::kAntiAlias_Flag);
96 paint.setStyle(SkPaint::kFill_Style); 108 paint.setStyle(SkPaint::kFill_Style);
97 109
98 ui::PaintRecorder recorder(context, size_); 110 ui::PaintRecorder recorder(context, size_);
99 gfx::Canvas* canvas = recorder.canvas(); 111 gfx::Canvas* canvas = recorder.canvas();
100 canvas->DrawRoundRect(gfx::Rect(size_), corner_radius_, paint); 112 canvas->DrawRoundRect(gfx::Rect(size_), corner_radius_, paint);
101 } 113 }
102 114
103 } // namespace views 115 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698