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