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.
5 #include "base/callback.h"
6 #include "base/macros.h"
7 #include "third_party/skia/include/core/SkColor.h"
8 #include "ui/compositor/layer_delegate.h"
9 #include "ui/compositor/paint_context.h"
10 #include "ui/gfx/geometry/rect.h"
18 // Renders the visual feedback for an ink drop animation. Will render a circle
19 // if |circle_| is true, otherwise renders a rounded rectangle.
20 class InkDropDelegate
: public ui::LayerDelegate
{
22 InkDropDelegate(ui::Layer
* layer
,
25 int rounded_rect_corner_radius
);
26 ~InkDropDelegate() override
;
28 // Sets the visual style of the feedback.
29 void set_should_render_circle(bool should_render_circle
) {
30 should_render_circle_
= should_render_circle
;
33 bool should_render_circle() const { return should_render_circle_
; }
36 void OnPaintLayer(const ui::PaintContext
& context
) override
;
37 void OnDelegatedFrameDamage(const gfx::Rect
& damage_rect_in_dip
) override
;
38 void OnDeviceScaleFactorChanged(float device_scale_factor
) override
;
39 base::Closure
PrepareForLayerBoundsChange() override
;
42 // The ui::Layer being rendered to.
45 // The color to paint.
48 // When true renders a circle, otherwise renders a rounded rectangle.
49 bool should_render_circle_
;
51 // The radius of the circle.
52 const int circle_radius_
;
54 // The radius of the rounded rectangles corners.
55 const int rounded_rect_corner_radius_
;
57 DISALLOW_COPY_AND_ASSIGN(InkDropDelegate
);