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

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

Issue 2499523003: Add ink drop masking to TrayBackgroundView (Closed)
Patch Set: 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& bounds,
35 int corner_radius)
36 : InkDropMask(layer_bounds),
37 bounds_(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(bounds_, corner_radius_, paint);
48 }
49
50 // CircleInkDropMask
51
52 CircleInkDropMask::CircleInkDropMask(const gfx::Rect& layer_bounds,
53 const gfx::Point& center,
54 int radius)
55 : InkDropMask(layer_bounds), center_(center), radius_(radius) {}
56
57 void CircleInkDropMask::OnPaintLayer(const ui::PaintContext& context) {
58 SkPaint paint;
59 paint.setAlpha(255);
60 paint.setStyle(SkPaint::kFill_Style);
61
62 ui::PaintRecorder recorder(context, layer()->size());
63 recorder.canvas()->DrawCircle(center_, radius_, paint);
64 }
65
66 } // namespace views
OLDNEW
« ui/views/animation/ink_drop_mask.h ('K') | « 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