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

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

Issue 1430153003: Moved the *PaintedLayerDelegates from ink_drop_animation.cc to ink_drop_painted_layer_delegates.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added use of BasePaintedLayerDelegate::GetCenterPoint(). 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
« no previous file with comments | « ui/views/animation/ink_drop_painted_layer_delegates.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/animation/ink_drop_painted_layer_delegates.h"
6
7 #include "third_party/skia/include/core/SkPaint.h"
8 #include "ui/compositor/paint_recorder.h"
9 #include "ui/gfx/geometry/point.h"
10 #include "ui/gfx/geometry/point_conversions.h"
11
12 namespace views {
13
14 ////////////////////////////////////////////////////////////////////////////////
15 //
16 // BasePaintedLayerDelegate
17 //
18
19 BasePaintedLayerDelegate::BasePaintedLayerDelegate(SkColor color)
20 : color_(color) {}
21
22 BasePaintedLayerDelegate::~BasePaintedLayerDelegate() {}
23
24 void BasePaintedLayerDelegate::OnDelegatedFrameDamage(
25 const gfx::Rect& damage_rect_in_dip) {}
26
27 void BasePaintedLayerDelegate::OnDeviceScaleFactorChanged(
28 float device_scale_factor) {}
29
30 base::Closure BasePaintedLayerDelegate::PrepareForLayerBoundsChange() {
31 return base::Closure();
32 }
33
34 ////////////////////////////////////////////////////////////////////////////////
35 //
36 // CircleLayerDelegate
37 //
38
39 CircleLayerDelegate::CircleLayerDelegate(SkColor color, int radius)
40 : BasePaintedLayerDelegate(color), radius_(radius) {}
41
42 CircleLayerDelegate::~CircleLayerDelegate() {}
43
44 gfx::PointF CircleLayerDelegate::GetCenterPoint() const {
45 return gfx::PointF(radius_, radius_);
46 }
47
48 void CircleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
49 SkPaint paint;
50 paint.setColor(color());
51 paint.setFlags(SkPaint::kAntiAlias_Flag);
52 paint.setStyle(SkPaint::kFill_Style);
53
54 ui::PaintRecorder recorder(context, gfx::Size(radius_, radius_));
55 gfx::Canvas* canvas = recorder.canvas();
56
57 canvas->DrawCircle(ToRoundedPoint(GetCenterPoint()), radius_, paint);
58 }
59
60 ////////////////////////////////////////////////////////////////////////////////
61 //
62 // RectangleLayerDelegate
63 //
64
65 RectangleLayerDelegate::RectangleLayerDelegate(SkColor color, gfx::Size size)
66 : BasePaintedLayerDelegate(color), size_(size) {}
67
68 RectangleLayerDelegate::~RectangleLayerDelegate() {}
69
70 gfx::PointF RectangleLayerDelegate::GetCenterPoint() const {
71 return gfx::PointF(size_.width() / 2.0f, size_.height() / 2.0f);
72 }
73
74 void RectangleLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
75 SkPaint paint;
76 paint.setColor(color());
77 paint.setFlags(SkPaint::kAntiAlias_Flag);
78 paint.setStyle(SkPaint::kFill_Style);
79
80 ui::PaintRecorder recorder(context, size_);
81 gfx::Canvas* canvas = recorder.canvas();
82 canvas->DrawRect(gfx::Rect(size_), paint);
83 }
84
85 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_painted_layer_delegates.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698