OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/app_list/views/pulsing_block_view.h" | 5 #include "ui/app_list/views/pulsing_block_view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
12 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
13 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
14 #include "ui/compositor/layer.h" | 16 #include "ui/compositor/layer.h" |
15 #include "ui/compositor/layer_animation_element.h" | 17 #include "ui/compositor/layer_animation_element.h" |
16 #include "ui/compositor/layer_animation_sequence.h" | 18 #include "ui/compositor/layer_animation_sequence.h" |
17 #include "ui/compositor/layer_animator.h" | 19 #include "ui/compositor/layer_animator.h" |
18 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
19 #include "ui/gfx/transform_util.h" | 21 #include "ui/gfx/transform_util.h" |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 const SkColor kBlockColor = SkColorSetRGB(225, 225, 225); | 25 const SkColor kBlockColor = SkColorSetRGB(225, 225, 225); |
24 const int kBlockSize = 64; | 26 const int kBlockSize = 64; |
25 | 27 |
26 const int kAnimationDurationInMs = 600; | 28 const int kAnimationDurationInMs = 600; |
27 const float kAnimationOpacity[] = { 0.4f, 0.8f, 0.4f }; | 29 const float kAnimationOpacity[] = { 0.4f, 0.8f, 0.4f }; |
28 const float kAnimationScale[] = { 0.8f, 1.0f, 0.8f }; | 30 const float kAnimationScale[] = { 0.8f, 1.0f, 0.8f }; |
29 | 31 |
30 void SchedulePulsingAnimation(ui::Layer* layer) { | 32 void SchedulePulsingAnimation(ui::Layer* layer) { |
31 DCHECK(layer); | 33 DCHECK(layer); |
32 DCHECK_EQ(arraysize(kAnimationOpacity), arraysize(kAnimationScale)); | 34 DCHECK_EQ(arraysize(kAnimationOpacity), arraysize(kAnimationScale)); |
33 | 35 |
34 std::unique_ptr<ui::LayerAnimationSequence> opacity_sequence( | 36 std::unique_ptr<ui::LayerAnimationSequence> opacity_sequence = |
35 new ui::LayerAnimationSequence()); | 37 base::MakeUnique<ui::LayerAnimationSequence>(); |
36 std::unique_ptr<ui::LayerAnimationSequence> transform_sequence( | 38 std::unique_ptr<ui::LayerAnimationSequence> transform_sequence = |
37 new ui::LayerAnimationSequence()); | 39 base::MakeUnique<ui::LayerAnimationSequence>(); |
38 | 40 |
39 // The animations loop infinitely. | 41 // The animations loop infinitely. |
40 opacity_sequence->set_is_cyclic(true); | 42 opacity_sequence->set_is_cyclic(true); |
41 transform_sequence->set_is_cyclic(true); | 43 transform_sequence->set_is_cyclic(true); |
42 | 44 |
43 const gfx::Rect local_bounds(layer->bounds().size()); | 45 const gfx::Rect local_bounds(layer->bounds().size()); |
44 for (size_t i = 0; i < arraysize(kAnimationOpacity); ++i) { | 46 for (size_t i = 0; i < arraysize(kAnimationOpacity); ++i) { |
45 opacity_sequence->AddElement( | 47 opacity_sequence->AddElement( |
46 ui::LayerAnimationElement::CreateOpacityElement( | 48 ui::LayerAnimationElement::CreateOpacityElement( |
47 kAnimationOpacity[i], | 49 kAnimationOpacity[i], |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 SchedulePulsingAnimation(layer()); | 94 SchedulePulsingAnimation(layer()); |
93 } | 95 } |
94 | 96 |
95 void PulsingBlockView::OnPaint(gfx::Canvas* canvas) { | 97 void PulsingBlockView::OnPaint(gfx::Canvas* canvas) { |
96 gfx::Rect rect(GetContentsBounds()); | 98 gfx::Rect rect(GetContentsBounds()); |
97 rect.ClampToCenteredSize(gfx::Size(kBlockSize, kBlockSize)); | 99 rect.ClampToCenteredSize(gfx::Size(kBlockSize, kBlockSize)); |
98 canvas->FillRect(rect, kBlockColor); | 100 canvas->FillRect(rect, kBlockColor); |
99 } | 101 } |
100 | 102 |
101 } // namespace app_list | 103 } // namespace app_list |
OLD | NEW |