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

Side by Side Diff: ui/compositor/layer_owner.h

Issue 2383263002: Generalize layer mirroring for phantom windows (Closed)
Patch Set: Revert layer renaming Created 4 years, 2 months 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 unified diff | Download patch
OLDNEW
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> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "ui/compositor/compositor_export.h" 12 #include "ui/compositor/compositor_export.h"
13 #include "ui/compositor/layer.h" 13 #include "ui/compositor/layer.h"
14 14
15 namespace ui { 15 namespace ui {
16 class LayerOwnerDelegate; 16 class LayerOwnerDelegate;
17 17
18 class COMPOSITOR_EXPORT LayerOwner { 18 class COMPOSITOR_EXPORT LayerOwner {
19 public: 19 public:
20 LayerOwner(); 20 LayerOwner();
21 virtual ~LayerOwner(); 21 virtual ~LayerOwner();
22 22
23 void SetLayer(Layer* layer); 23 void SetLayer(std::unique_ptr<Layer> layer);
24 24
25 // Releases the owning reference to its layer, and returns it. 25 // Releases the owning reference to its layer, and returns it.
26 // 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
27 // 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
28 // 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
29 // 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
30 // end of ~LayerOwner(). 30 // end of ~LayerOwner().
31 std::unique_ptr<Layer> AcquireLayer(); 31 std::unique_ptr<Layer> AcquireLayer();
32 32
33 // 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
34 // 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.
35 // 35 //
36 // 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
37 // layer. 37 // layer.
38 virtual std::unique_ptr<Layer> RecreateLayer(); 38 virtual std::unique_ptr<Layer> RecreateLayer();
39 39
40 ui::Layer* layer() { return layer_; } 40 ui::Layer* layer() { return layer_; }
41 const ui::Layer* layer() const { return layer_; } 41 const ui::Layer* layer() const { return layer_; }
42 42
43 void set_layer_owner_delegate(LayerOwnerDelegate* delegate) { 43 void set_layer_owner_delegate(LayerOwnerDelegate* delegate) {
44 layer_owner_delegate_ = delegate; 44 layer_owner_delegate_ = delegate;
45 } 45 }
46 46
47 bool OwnsLayer() const;
sky 2016/10/19 19:27:14 Why does this need to be public?
Dominik Laskowski 2016/10/19 22:46:38 For the DCHECK in wm::RecreateLayers, which I thin
48
47 protected: 49 protected:
48 void DestroyLayer(); 50 void DestroyLayer();
49 51
50 bool OwnsLayer() const;
51
52 private: 52 private:
53 // 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
54 // to AcquireLayer(). After that moment |layer_| will still be valid but 54 // to AcquireLayer(). After that moment |layer_| will still be valid but
55 // |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
56 // 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,
57 // e.g. fading it out when it is destroyed. 57 // e.g. fading it out when it is destroyed.
58 std::unique_ptr<Layer> layer_owner_; 58 std::unique_ptr<Layer> layer_owner_;
59 Layer* layer_; 59 Layer* layer_;
60 60
61 LayerOwnerDelegate* layer_owner_delegate_; 61 LayerOwnerDelegate* layer_owner_delegate_;
62 62
63 DISALLOW_COPY_AND_ASSIGN(LayerOwner); 63 DISALLOW_COPY_AND_ASSIGN(LayerOwner);
64 }; 64 };
65 65
66 } // namespace ui 66 } // namespace ui
67 67
68 #endif // UI_COMPOSITOR_LAYER_OWNER_H_ 68 #endif // UI_COMPOSITOR_LAYER_OWNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698