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

Unified 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 side-by-side diff with in-line comments
Download patch
« ui/views/animation/ink_drop_mask.h ('K') | « ui/views/animation/ink_drop_mask.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/ink_drop_mask.cc
diff --git a/ui/views/animation/ink_drop_mask.cc b/ui/views/animation/ink_drop_mask.cc
new file mode 100644
index 0000000000000000000000000000000000000000..15aca7e5d630754ae21b06f13fa664f93c05d8b7
--- /dev/null
+++ b/ui/views/animation/ink_drop_mask.cc
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/animation/ink_drop_mask.h"
+
+#include "third_party/skia/include/core/SkPaint.h"
+#include "ui/compositor/paint_recorder.h"
+#include "ui/gfx/canvas.h"
+
+namespace views {
+
+// InkDropMask
+
+InkDropMask::InkDropMask(const gfx::Rect& layer_bounds)
+ : layer_(ui::LAYER_TEXTURED) {
+ layer_.set_delegate(this);
+ layer_.SetBounds(layer_bounds);
+ layer_.SetFillsBoundsOpaquely(false);
+ layer_.set_name("InkDropMaskLayer");
+}
+
+InkDropMask::~InkDropMask() {
+ layer_.set_delegate(nullptr);
+}
+
+void InkDropMask::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) {}
+
+void InkDropMask::OnDeviceScaleFactorChanged(float device_scale_factor) {}
+
+// RoundRectInkDropMask
+
+RoundRectInkDropMask::RoundRectInkDropMask(const gfx::Rect& layer_bounds,
+ const gfx::Rect& bounds,
+ int corner_radius)
+ : InkDropMask(layer_bounds),
+ bounds_(bounds),
+ corner_radius_(corner_radius) {}
+
+void RoundRectInkDropMask::OnPaintLayer(const ui::PaintContext& context) {
+ SkPaint paint;
+ paint.setAlpha(255);
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setAntiAlias(true);
+
+ ui::PaintRecorder recorder(context, layer()->size());
+ recorder.canvas()->DrawRoundRect(bounds_, corner_radius_, paint);
+}
+
+// CircleInkDropMask
+
+CircleInkDropMask::CircleInkDropMask(const gfx::Rect& layer_bounds,
+ const gfx::Point& center,
+ int radius)
+ : InkDropMask(layer_bounds), center_(center), radius_(radius) {}
+
+void CircleInkDropMask::OnPaintLayer(const ui::PaintContext& context) {
+ SkPaint paint;
+ paint.setAlpha(255);
+ paint.setStyle(SkPaint::kFill_Style);
+
+ ui::PaintRecorder recorder(context, layer()->size());
+ recorder.canvas()->DrawCircle(center_, radius_, paint);
+}
+
+} // namespace views
« 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