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

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

Issue 2499523003: Add ink drop masking to TrayBackgroundView (Closed)
Patch Set: Addressed review comments 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/animation/ink_drop_mask.h"
6
7 #include "third_party/skia/include/core/SkPaint.h"
8 #include "ui/compositor/paint_recorder.h"
9 #include "ui/gfx/canvas.h"
10
11 namespace views {
12
13 // InkDropMask
14
15 InkDropMask::InkDropMask(const gfx::Rect& layer_bounds)
16 : layer_(ui::LAYER_TEXTURED) {
17 layer_.set_delegate(this);
18 layer_.SetBounds(layer_bounds);
19 layer_.SetFillsBoundsOpaquely(false);
20 layer_.set_name("InkDropMaskLayer");
21 }
22
23 InkDropMask::~InkDropMask() {
24 layer_.set_delegate(nullptr);
25 }
26
27 void InkDropMask::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) {}
28
29 void InkDropMask::OnDeviceScaleFactorChanged(float device_scale_factor) {}
30
31 // RoundRectInkDropMask
32
33 RoundRectInkDropMask::RoundRectInkDropMask(const gfx::Rect& layer_bounds,
34 const gfx::Rect& mask_bounds,
35 int corner_radius)
36 : InkDropMask(layer_bounds),
37 mask_bounds_(mask_bounds),
38 corner_radius_(corner_radius) {}
39
40 void RoundRectInkDropMask::OnPaintLayer(const ui::PaintContext& context) {
41 SkPaint paint;
42 paint.setAlpha(255);
43 paint.setStyle(SkPaint::kFill_Style);
44 paint.setAntiAlias(true);
45
46 ui::PaintRecorder recorder(context, layer()->size());
47 recorder.canvas()->DrawRoundRect(mask_bounds_, corner_radius_, paint);
48 }
49
50 // CircleInkDropMask
51
52 CircleInkDropMask::CircleInkDropMask(const gfx::Rect& layer_bounds,
53 const gfx::Point& mask_center,
54 int mask_radius)
55 : InkDropMask(layer_bounds),
56 mask_center_(mask_center),
57 mask_radius_(mask_radius) {}
58
59 void CircleInkDropMask::OnPaintLayer(const ui::PaintContext& context) {
60 SkPaint paint;
61 paint.setAlpha(255);
62 paint.setStyle(SkPaint::kFill_Style);
63
64 ui::PaintRecorder recorder(context, layer()->size());
65 recorder.canvas()->DrawCircle(mask_center_, mask_radius_, paint);
66 }
67
68 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698