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

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

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem Created 3 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
« no previous file with comments | « ui/views/animation/ink_drop_mask.cc ('k') | ui/views/border.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/paint/paint_canvas.h"
8 #include "cc/paint/paint_flags.h"
7 #include "third_party/skia/include/core/SkDrawLooper.h" 9 #include "third_party/skia/include/core/SkDrawLooper.h"
8 #include "third_party/skia/include/core/SkPaint.h"
9 #include "third_party/skia/include/core/SkRRect.h" 10 #include "third_party/skia/include/core/SkRRect.h"
10 #include "ui/compositor/paint_recorder.h" 11 #include "ui/compositor/paint_recorder.h"
11 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/color_palette.h" 13 #include "ui/gfx/color_palette.h"
13 #include "ui/gfx/geometry/insets.h" 14 #include "ui/gfx/geometry/insets.h"
14 #include "ui/gfx/geometry/point.h" 15 #include "ui/gfx/geometry/point.h"
15 #include "ui/gfx/geometry/point_conversions.h" 16 #include "ui/gfx/geometry/point_conversions.h"
16 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/geometry/rect_f.h" 18 #include "ui/gfx/geometry/rect_f.h"
18 #include "ui/gfx/skia_paint_util.h" 19 #include "ui/gfx/skia_paint_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 : BasePaintedLayerDelegate(color), radius_(radius) {} 51 : BasePaintedLayerDelegate(color), radius_(radius) {}
51 52
52 CircleLayerDelegate::~CircleLayerDelegate() {} 53 CircleLayerDelegate::~CircleLayerDelegate() {}
53 54
54 gfx::Rect CircleLayerDelegate::GetPaintedBounds() const { 55 gfx::Rect CircleLayerDelegate::GetPaintedBounds() const {
55 const int diameter = radius_ * 2; 56 const int diameter = radius_ * 2;
56 return gfx::Rect(0, 0, diameter, diameter); 57 return gfx::Rect(0, 0, diameter, diameter);
57 } 58 }
58 59
59 void CircleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) { 60 void CircleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
60 SkPaint paint; 61 cc::PaintFlags paint;
61 paint.setColor(color()); 62 paint.setColor(color());
62 paint.setFlags(SkPaint::kAntiAlias_Flag); 63 paint.setAntiAlias(true);
63 paint.setStyle(SkPaint::kFill_Style); 64 paint.setStyle(cc::PaintFlags::kFill_Style);
64 65
65 ui::PaintRecorder recorder(context, GetPaintedBounds().size()); 66 ui::PaintRecorder recorder(context, GetPaintedBounds().size());
66 gfx::Canvas* canvas = recorder.canvas(); 67 gfx::Canvas* canvas = recorder.canvas();
67 68
68 canvas->DrawCircle(GetPaintedBounds().CenterPoint(), radius_, paint); 69 canvas->DrawCircle(GetPaintedBounds().CenterPoint(), radius_, paint);
69 } 70 }
70 71
71 //////////////////////////////////////////////////////////////////////////////// 72 ////////////////////////////////////////////////////////////////////////////////
72 // 73 //
73 // RectangleLayerDelegate 74 // RectangleLayerDelegate
74 // 75 //
75 76
76 RectangleLayerDelegate::RectangleLayerDelegate(SkColor color, gfx::Size size) 77 RectangleLayerDelegate::RectangleLayerDelegate(SkColor color, gfx::Size size)
77 : BasePaintedLayerDelegate(color), size_(size) {} 78 : BasePaintedLayerDelegate(color), size_(size) {}
78 79
79 RectangleLayerDelegate::~RectangleLayerDelegate() {} 80 RectangleLayerDelegate::~RectangleLayerDelegate() {}
80 81
81 gfx::Rect RectangleLayerDelegate::GetPaintedBounds() const { 82 gfx::Rect RectangleLayerDelegate::GetPaintedBounds() const {
82 return gfx::Rect(size_); 83 return gfx::Rect(size_);
83 } 84 }
84 85
85 void RectangleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) { 86 void RectangleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
86 SkPaint paint; 87 cc::PaintFlags paint;
87 paint.setColor(color()); 88 paint.setColor(color());
88 paint.setFlags(SkPaint::kAntiAlias_Flag); 89 paint.setAntiAlias(true);
89 paint.setStyle(SkPaint::kFill_Style); 90 paint.setStyle(cc::PaintFlags::kFill_Style);
90 91
91 ui::PaintRecorder recorder(context, size_); 92 ui::PaintRecorder recorder(context, size_);
92 gfx::Canvas* canvas = recorder.canvas(); 93 gfx::Canvas* canvas = recorder.canvas();
93 canvas->DrawRect(GetPaintedBounds(), paint); 94 canvas->DrawRect(GetPaintedBounds(), paint);
94 } 95 }
95 96
96 //////////////////////////////////////////////////////////////////////////////// 97 ////////////////////////////////////////////////////////////////////////////////
97 // 98 //
98 // RoundedRectangleLayerDelegate 99 // RoundedRectangleLayerDelegate
99 // 100 //
100 101
101 RoundedRectangleLayerDelegate::RoundedRectangleLayerDelegate( 102 RoundedRectangleLayerDelegate::RoundedRectangleLayerDelegate(
102 SkColor color, 103 SkColor color,
103 const gfx::Size& size, 104 const gfx::Size& size,
104 int corner_radius) 105 int corner_radius)
105 : BasePaintedLayerDelegate(color), 106 : BasePaintedLayerDelegate(color),
106 size_(size), 107 size_(size),
107 corner_radius_(corner_radius) {} 108 corner_radius_(corner_radius) {}
108 109
109 RoundedRectangleLayerDelegate::~RoundedRectangleLayerDelegate() {} 110 RoundedRectangleLayerDelegate::~RoundedRectangleLayerDelegate() {}
110 111
111 gfx::Rect RoundedRectangleLayerDelegate::GetPaintedBounds() const { 112 gfx::Rect RoundedRectangleLayerDelegate::GetPaintedBounds() const {
112 return gfx::Rect(size_); 113 return gfx::Rect(size_);
113 } 114 }
114 115
115 void RoundedRectangleLayerDelegate::OnPaintLayer( 116 void RoundedRectangleLayerDelegate::OnPaintLayer(
116 const ui::PaintContext& context) { 117 const ui::PaintContext& context) {
117 SkPaint paint; 118 cc::PaintFlags paint;
118 paint.setColor(color()); 119 paint.setColor(color());
119 paint.setFlags(SkPaint::kAntiAlias_Flag); 120 paint.setAntiAlias(true);
120 paint.setStyle(SkPaint::kFill_Style); 121 paint.setStyle(cc::PaintFlags::kFill_Style);
121 122
122 ui::PaintRecorder recorder(context, size_); 123 ui::PaintRecorder recorder(context, size_);
123 recorder.canvas()->DrawRoundRect(GetPaintedBounds(), corner_radius_, paint); 124 recorder.canvas()->DrawRoundRect(GetPaintedBounds(), corner_radius_, paint);
124 } 125 }
125 126
126 //////////////////////////////////////////////////////////////////////////////// 127 ////////////////////////////////////////////////////////////////////////////////
127 // 128 //
128 // BorderShadowLayerDelegate 129 // BorderShadowLayerDelegate
129 // 130 //
130 131
(...skipping 14 matching lines...) Expand all
145 gfx::Rect total_rect(bounds_); 146 gfx::Rect total_rect(bounds_);
146 total_rect.Inset(gfx::ShadowValue::GetMargin(shadows_)); 147 total_rect.Inset(gfx::ShadowValue::GetMargin(shadows_));
147 return total_rect; 148 return total_rect;
148 } 149 }
149 150
150 gfx::Vector2dF BorderShadowLayerDelegate::GetCenteringOffset() const { 151 gfx::Vector2dF BorderShadowLayerDelegate::GetCenteringOffset() const {
151 return gfx::RectF(bounds_).CenterPoint().OffsetFromOrigin(); 152 return gfx::RectF(bounds_).CenterPoint().OffsetFromOrigin();
152 } 153 }
153 154
154 void BorderShadowLayerDelegate::OnPaintLayer(const ui::PaintContext& context) { 155 void BorderShadowLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
155 SkPaint paint; 156 cc::PaintFlags paint;
156 paint.setStyle(SkPaint::kFill_Style); 157 paint.setStyle(cc::PaintFlags::kFill_Style);
157 paint.setAntiAlias(true); 158 paint.setAntiAlias(true);
158 paint.setColor(fill_color_); 159 paint.setColor(fill_color_);
159 160
160 gfx::RectF rrect_bounds = 161 gfx::RectF rrect_bounds =
161 gfx::RectF(bounds_ - GetPaintedBounds().OffsetFromOrigin()); 162 gfx::RectF(bounds_ - GetPaintedBounds().OffsetFromOrigin());
162 SkRRect r_rect = SkRRect::MakeRectXY(gfx::RectFToSkRect(rrect_bounds), 163 SkRRect r_rect = SkRRect::MakeRectXY(gfx::RectFToSkRect(rrect_bounds),
163 corner_radius_, corner_radius_); 164 corner_radius_, corner_radius_);
164 165
165 // First the fill color. 166 // First the fill color.
166 ui::PaintRecorder recorder(context, GetPaintedBounds().size()); 167 ui::PaintRecorder recorder(context, GetPaintedBounds().size());
167 recorder.canvas()->sk_canvas()->drawRRect(r_rect, paint); 168 recorder.canvas()->sk_canvas()->drawRRect(r_rect, paint);
168 169
169 // Now the shadow. 170 // Now the shadow.
170 paint.setLooper(gfx::CreateShadowDrawLooperCorrectBlur(shadows_)); 171 paint.setLooper(gfx::CreateShadowDrawLooperCorrectBlur(shadows_));
171 recorder.canvas()->sk_canvas()->clipRRect(r_rect, SkClipOp::kDifference, 172 recorder.canvas()->sk_canvas()->clipRRect(r_rect, SkClipOp::kDifference,
172 true); 173 true);
173 recorder.canvas()->sk_canvas()->drawRRect(r_rect, paint); 174 recorder.canvas()->sk_canvas()->drawRRect(r_rect, paint);
174 } 175 }
175 176
176 } // namespace views 177 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_mask.cc ('k') | ui/views/border.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698