OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 ASH_WM_WINDOW_MIRROR_VIEW_H_ | 5 #ifndef ASH_WM_WINDOW_MIRROR_VIEW_H_ |
6 #define ASH_WM_WINDOW_MIRROR_VIEW_H_ | 6 #define ASH_WM_WINDOW_MIRROR_VIEW_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | |
10 | 9 |
11 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
12 #include "base/macros.h" | 11 #include "base/macros.h" |
13 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
14 #include "ui/wm/core/window_util.h" | 13 |
| 14 namespace ui { |
| 15 class LayerTreeOwner; |
| 16 } |
15 | 17 |
16 namespace ash { | 18 namespace ash { |
17 | 19 |
18 class WmWindowAura; | 20 class WmWindowAura; |
19 | 21 |
20 namespace wm { | 22 namespace wm { |
21 | 23 |
22 class ForwardingLayerDelegate; | 24 // A view that mirrors the client area of a single window. |
23 | 25 class WindowMirrorView : public views::View { |
24 // A view that mirrors the client area of a single window. Layers are lifted | |
25 // from the underlying window (which gets new ones in their place). New paint | |
26 // calls, if any, are forwarded to the underlying window. | |
27 class WindowMirrorView : public views::View, public ::wm::LayerDelegateFactory { | |
28 public: | 26 public: |
29 explicit WindowMirrorView(WmWindowAura* window); | 27 explicit WindowMirrorView(WmWindowAura* window); |
30 ~WindowMirrorView() override; | 28 ~WindowMirrorView() override; |
31 | 29 |
32 // views::View: | 30 // views::View: |
33 gfx::Size GetPreferredSize() const override; | 31 gfx::Size GetPreferredSize() const override; |
34 void Layout() override; | 32 void Layout() override; |
35 bool GetNeedsNotificationWhenVisibleBoundsChange() const override; | 33 bool GetNeedsNotificationWhenVisibleBoundsChange() const override; |
36 void OnVisibleBoundsChanged() override; | 34 void OnVisibleBoundsChanged() override; |
37 | 35 |
38 // ::wm::LayerDelegateFactory: | |
39 ui::LayerDelegate* CreateDelegate(ui::Layer* new_layer, | |
40 ui::Layer* layer) override; | |
41 | |
42 private: | 36 private: |
43 void InitLayerOwner(); | 37 void InitLayerOwner(); |
44 | 38 |
45 // Gets the root of the layer tree that was lifted from |target_| (and is now | 39 // Gets the root of the layer tree that was lifted from |target_| (and is now |
46 // a child of |this->layer()|). | 40 // a child of |this->layer()|). |
47 ui::Layer* GetMirrorLayer(); | 41 ui::Layer* GetMirrorLayer(); |
48 | 42 |
49 // Calculates the bounds of the client area of the Window in the widget | 43 // Calculates the bounds of the client area of the Window in the widget |
50 // coordinate space. | 44 // coordinate space. |
51 gfx::Rect GetClientAreaBounds() const; | 45 gfx::Rect GetClientAreaBounds() const; |
52 | 46 |
53 // The original window that is being represented by |this|. | 47 // The original window that is being represented by |this|. |
54 WmWindowAura* target_; | 48 WmWindowAura* target_; |
55 | 49 |
56 // Retains ownership of the mirror layer tree. This is lazily initialized | 50 // Retains ownership of the mirror layer tree. This is lazily initialized |
57 // the first time the view becomes visible. | 51 // the first time the view becomes visible. |
58 std::unique_ptr<ui::LayerTreeOwner> layer_owner_; | 52 std::unique_ptr<ui::LayerTreeOwner> layer_owner_; |
59 | 53 |
60 std::vector<std::unique_ptr<ForwardingLayerDelegate>> delegates_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(WindowMirrorView); | 54 DISALLOW_COPY_AND_ASSIGN(WindowMirrorView); |
63 }; | 55 }; |
64 | 56 |
65 } // namespace wm | 57 } // namespace wm |
66 } // namespace ash | 58 } // namespace ash |
67 | 59 |
68 #endif // ASH_WM_WINDOW_MIRROR_VIEW_H_ | 60 #endif // ASH_WM_WINDOW_MIRROR_VIEW_H_ |
OLD | NEW |