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 #ifndef UI_COMPOSITOR_LAYER_OWNER_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_OWNER_H_ |
6 #define UI_COMPOSITOR_LAYER_OWNER_H_ | 6 #define UI_COMPOSITOR_LAYER_OWNER_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "ui/compositor/compositor_export.h" | 12 #include "ui/compositor/compositor_export.h" |
12 #include "ui/compositor/layer.h" | 13 #include "ui/compositor/layer.h" |
13 | 14 |
14 namespace ui { | 15 namespace ui { |
15 class LayerOwnerDelegate; | 16 class LayerOwnerDelegate; |
16 | 17 |
17 class COMPOSITOR_EXPORT LayerOwner { | 18 class COMPOSITOR_EXPORT LayerOwner { |
18 public: | 19 public: |
19 LayerOwner(); | 20 LayerOwner(); |
20 virtual ~LayerOwner(); | 21 virtual ~LayerOwner(); |
21 | 22 |
22 void SetLayer(Layer* layer); | 23 void SetLayer(Layer* layer); |
23 | 24 |
24 // Releases the owning reference to its layer, and returns it. | 25 // Releases the owning reference to its layer, and returns it. |
25 // This is used when you need to animate the presentation of the owner just | 26 // This is used when you need to animate the presentation of the owner just |
26 // prior to destroying it. The Owner can be destroyed soon after calling this | 27 // prior to destroying it. The Owner can be destroyed soon after calling this |
27 // function, and the caller is then responsible for disposing of the layer | 28 // function, and the caller is then responsible for disposing of the layer |
28 // once any animation completes. Note that layer() will remain valid until the | 29 // once any animation completes. Note that layer() will remain valid until the |
29 // end of ~LayerOwner(). | 30 // end of ~LayerOwner(). |
30 scoped_ptr<Layer> AcquireLayer(); | 31 std::unique_ptr<Layer> AcquireLayer(); |
31 | 32 |
32 // Asks the owner to recreate the layer, returning the old Layer. NULL is | 33 // Asks the owner to recreate the layer, returning the old Layer. NULL is |
33 // returned if there is no existing layer, or recreate is not supported. | 34 // returned if there is no existing layer, or recreate is not supported. |
34 // | 35 // |
35 // This does not recurse. Existing children of the layer are moved to the new | 36 // This does not recurse. Existing children of the layer are moved to the new |
36 // layer. | 37 // layer. |
37 virtual scoped_ptr<Layer> RecreateLayer(); | 38 virtual std::unique_ptr<Layer> RecreateLayer(); |
38 | 39 |
39 ui::Layer* layer() { return layer_; } | 40 ui::Layer* layer() { return layer_; } |
40 const ui::Layer* layer() const { return layer_; } | 41 const ui::Layer* layer() const { return layer_; } |
41 | 42 |
42 void set_layer_owner_delegate(LayerOwnerDelegate* delegate) { | 43 void set_layer_owner_delegate(LayerOwnerDelegate* delegate) { |
43 layer_owner_delegate_ = delegate; | 44 layer_owner_delegate_ = delegate; |
44 } | 45 } |
45 | 46 |
46 protected: | 47 protected: |
47 void DestroyLayer(); | 48 void DestroyLayer(); |
48 | 49 |
49 bool OwnsLayer() const; | 50 bool OwnsLayer() const; |
50 | 51 |
51 private: | 52 private: |
52 // The LayerOwner owns its layer unless ownership is relinquished via a call | 53 // The LayerOwner owns its layer unless ownership is relinquished via a call |
53 // to AcquireLayer(). After that moment |layer_| will still be valid but | 54 // to AcquireLayer(). After that moment |layer_| will still be valid but |
54 // |layer_owner_| will be NULL. The reason for releasing ownership is that | 55 // |layer_owner_| will be NULL. The reason for releasing ownership is that |
55 // the client may wish to animate the layer beyond the lifetime of the owner, | 56 // the client may wish to animate the layer beyond the lifetime of the owner, |
56 // e.g. fading it out when it is destroyed. | 57 // e.g. fading it out when it is destroyed. |
57 scoped_ptr<Layer> layer_owner_; | 58 std::unique_ptr<Layer> layer_owner_; |
58 Layer* layer_; | 59 Layer* layer_; |
59 | 60 |
60 LayerOwnerDelegate* layer_owner_delegate_; | 61 LayerOwnerDelegate* layer_owner_delegate_; |
61 | 62 |
62 DISALLOW_COPY_AND_ASSIGN(LayerOwner); | 63 DISALLOW_COPY_AND_ASSIGN(LayerOwner); |
63 }; | 64 }; |
64 | 65 |
65 } // namespace ui | 66 } // namespace ui |
66 | 67 |
67 #endif // UI_COMPOSITOR_LAYER_OWNER_H_ | 68 #endif // UI_COMPOSITOR_LAYER_OWNER_H_ |
OLD | NEW |