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 "ui/views/animation/ink_drop_delegate.h"
7 #include "third_party/skia/include/core/SkPaint.h"
8 #include "ui/compositor/layer.h"
9 #include "ui/compositor/paint_recorder.h"
10 #include "ui/gfx/canvas.h"
14 InkDropDelegate::InkDropDelegate(ui::Layer
* layer
,
17 int rounded_rect_corner_radius
)
20 should_render_circle_(true),
21 circle_radius_(circle_radius
),
22 rounded_rect_corner_radius_(rounded_rect_corner_radius
) {}
24 InkDropDelegate::~InkDropDelegate() {}
26 void InkDropDelegate::OnPaintLayer(const ui::PaintContext
& context
) {
28 paint
.setColor(color_
);
29 paint
.setFlags(SkPaint::kAntiAlias_Flag
);
30 paint
.setStyle(SkPaint::kFill_Style
);
32 gfx::Rect bounds
= layer_
->bounds();
34 ui::PaintRecorder
recorder(context
, layer_
->size());
35 gfx::Canvas
* canvas
= recorder
.canvas();
36 if (should_render_circle()) {
37 gfx::Point
midpoint(bounds
.width() * 0.5f
, bounds
.height() * 0.5f
);
38 canvas
->DrawCircle(midpoint
, circle_radius_
, paint
);
40 canvas
->DrawRoundRect(bounds
, rounded_rect_corner_radius_
, paint
);
44 void InkDropDelegate::OnDelegatedFrameDamage(
45 const gfx::Rect
& damage_rect_in_dip
) {}
47 void InkDropDelegate::OnDeviceScaleFactorChanged(float device_scale_factor
) {}
49 base::Closure
InkDropDelegate::PrepareForLayerBoundsChange() {
50 return base::Closure();