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

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

Issue 2508063004: Take size in ink drop masks instead of bounds (Closed)
Patch Set: Rebased Created 4 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_mask.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_mask.h" 5 #include "ui/views/animation/ink_drop_mask.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/canvas.h" 9 #include "ui/gfx/canvas.h"
10 10
11 namespace views { 11 namespace views {
12 12
13 // InkDropMask 13 // InkDropMask
14 14
15 InkDropMask::InkDropMask(const gfx::Rect& layer_bounds) 15 InkDropMask::InkDropMask(const gfx::Size& layer_size)
16 : layer_(ui::LAYER_TEXTURED) { 16 : layer_(ui::LAYER_TEXTURED) {
17 layer_.set_delegate(this); 17 layer_.set_delegate(this);
18 layer_.SetBounds(layer_bounds); 18 layer_.SetBounds(gfx::Rect(layer_size));
19 layer_.SetFillsBoundsOpaquely(false); 19 layer_.SetFillsBoundsOpaquely(false);
20 layer_.set_name("InkDropMaskLayer"); 20 layer_.set_name("InkDropMaskLayer");
21 } 21 }
22 22
23 InkDropMask::~InkDropMask() { 23 InkDropMask::~InkDropMask() {
24 layer_.set_delegate(nullptr); 24 layer_.set_delegate(nullptr);
25 } 25 }
26 26
27 void InkDropMask::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) {} 27 void InkDropMask::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) {}
28 28
29 void InkDropMask::OnDeviceScaleFactorChanged(float device_scale_factor) {} 29 void InkDropMask::OnDeviceScaleFactorChanged(float device_scale_factor) {}
30 30
31 // RoundRectInkDropMask 31 // RoundRectInkDropMask
32 32
33 RoundRectInkDropMask::RoundRectInkDropMask(const gfx::Rect& layer_bounds, 33 RoundRectInkDropMask::RoundRectInkDropMask(const gfx::Size& layer_size,
34 const gfx::Rect& mask_bounds, 34 const gfx::Rect& mask_bounds,
35 int corner_radius) 35 int corner_radius)
36 : InkDropMask(layer_bounds), 36 : InkDropMask(layer_size),
37 mask_bounds_(mask_bounds), 37 mask_bounds_(mask_bounds),
38 corner_radius_(corner_radius) {} 38 corner_radius_(corner_radius) {}
39 39
40 void RoundRectInkDropMask::OnPaintLayer(const ui::PaintContext& context) { 40 void RoundRectInkDropMask::OnPaintLayer(const ui::PaintContext& context) {
41 SkPaint paint; 41 SkPaint paint;
42 paint.setAlpha(255); 42 paint.setAlpha(255);
43 paint.setStyle(SkPaint::kFill_Style); 43 paint.setStyle(SkPaint::kFill_Style);
44 paint.setAntiAlias(true); 44 paint.setAntiAlias(true);
45 45
46 ui::PaintRecorder recorder(context, layer()->size()); 46 ui::PaintRecorder recorder(context, layer()->size());
47 recorder.canvas()->DrawRoundRect(mask_bounds_, corner_radius_, paint); 47 recorder.canvas()->DrawRoundRect(mask_bounds_, corner_radius_, paint);
48 } 48 }
49 49
50 // CircleInkDropMask 50 // CircleInkDropMask
51 51
52 CircleInkDropMask::CircleInkDropMask(const gfx::Rect& layer_bounds, 52 CircleInkDropMask::CircleInkDropMask(const gfx::Size& layer_size,
53 const gfx::Point& mask_center, 53 const gfx::Point& mask_center,
54 int mask_radius) 54 int mask_radius)
55 : InkDropMask(layer_bounds), 55 : InkDropMask(layer_size),
56 mask_center_(mask_center), 56 mask_center_(mask_center),
57 mask_radius_(mask_radius) {} 57 mask_radius_(mask_radius) {}
58 58
59 void CircleInkDropMask::OnPaintLayer(const ui::PaintContext& context) { 59 void CircleInkDropMask::OnPaintLayer(const ui::PaintContext& context) {
60 SkPaint paint; 60 SkPaint paint;
61 paint.setAlpha(255); 61 paint.setAlpha(255);
62 paint.setStyle(SkPaint::kFill_Style); 62 paint.setStyle(SkPaint::kFill_Style);
63 paint.setAntiAlias(true); 63 paint.setAntiAlias(true);
64 64
65 ui::PaintRecorder recorder(context, layer()->size()); 65 ui::PaintRecorder recorder(context, layer()->size());
66 recorder.canvas()->DrawCircle(mask_center_, mask_radius_, paint); 66 recorder.canvas()->DrawCircle(mask_center_, mask_radius_, paint);
67 } 67 }
68 68
69 } // namespace views 69 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_mask.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698