| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_MUS_WS_VIEW_TREE_HOST_IMPL_H_ | 5 #ifndef COMPONENTS_MUS_WS_VIEW_TREE_HOST_IMPL_H_ |
| 6 #define COMPONENTS_MUS_WS_VIEW_TREE_HOST_IMPL_H_ | 6 #define COMPONENTS_MUS_WS_VIEW_TREE_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "components/mus/public/cpp/types.h" | 9 #include "components/mus/public/cpp/types.h" |
| 10 #include "components/mus/public/interfaces/view_tree_host.mojom.h" | 10 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| 11 #include "components/mus/ws/display_manager.h" | 11 #include "components/mus/ws/display_manager.h" |
| 12 #include "components/mus/ws/event_dispatcher.h" | 12 #include "components/mus/ws/event_dispatcher.h" |
| 13 #include "components/mus/ws/focus_controller_delegate.h" | 13 #include "components/mus/ws/focus_controller_delegate.h" |
| 14 #include "components/mus/ws/server_view.h" | 14 #include "components/mus/ws/server_view.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 class SurfaceManager; | 17 class SurfaceManager; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace mus { | 20 namespace mus { |
| 21 class SurfacesScheduler; | 21 class SurfacesScheduler; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace mus { | 24 namespace mus { |
| 25 | 25 |
| 26 class ConnectionManager; | 26 class ConnectionManager; |
| 27 class FocusController; | 27 class FocusController; |
| 28 class ViewTreeHostDelegate; | 28 class ViewTreeHostDelegate; |
| 29 class ViewTreeImpl; | 29 class ViewTreeImpl; |
| 30 | 30 |
| 31 // ViewTreeHostImpl is an implementation of the ViewTreeHost interface. | 31 // ViewTreeHostImpl is an implementation of the ViewTreeHost interface. |
| 32 // It serves as a top level root view for a window. Its lifetime is managed by | 32 // It serves as a top level root view for a window. Its lifetime is managed by |
| 33 // ConnectionManager. If the connection to the client breaks or if the user | 33 // ConnectionManager. If the connection to the client breaks or if the user |
| 34 // closes the associated window, then this object and related state will be | 34 // closes the associated window, then this object and related state will be |
| 35 // deleted. | 35 // deleted. |
| 36 class ViewTreeHostImpl : public DisplayManagerDelegate, | 36 class ViewTreeHostImpl : public DisplayManagerDelegate, |
| 37 public mojo::ViewTreeHost, | 37 public mojom::WindowTreeHost, |
| 38 public FocusControllerDelegate { | 38 public FocusControllerDelegate { |
| 39 public: | 39 public: |
| 40 // TODO(fsamuel): All these parameters are just plumbing for creating | 40 // TODO(fsamuel): All these parameters are just plumbing for creating |
| 41 // DisplayManagers. We should probably just store these common parameters | 41 // DisplayManagers. We should probably just store these common parameters |
| 42 // in the DisplayManagerFactory and pass them along on DisplayManager::Create. | 42 // in the DisplayManagerFactory and pass them along on DisplayManager::Create. |
| 43 ViewTreeHostImpl(mojo::ViewTreeHostClientPtr client, | 43 ViewTreeHostImpl(mojom::WindowTreeHostClientPtr client, |
| 44 ConnectionManager* connection_manager, | 44 ConnectionManager* connection_manager, |
| 45 mojo::ApplicationImpl* app_impl, | 45 mojo::ApplicationImpl* app_impl, |
| 46 const scoped_refptr<GpuState>& gpu_state, | 46 const scoped_refptr<GpuState>& gpu_state, |
| 47 const scoped_refptr<SurfacesState>& surfaces_state); | 47 const scoped_refptr<SurfacesState>& surfaces_state); |
| 48 ~ViewTreeHostImpl() override; | 48 ~ViewTreeHostImpl() override; |
| 49 | 49 |
| 50 // Initializes state that depends on the existence of a ViewTreeHostImpl. | 50 // Initializes state that depends on the existence of a ViewTreeHostImpl. |
| 51 void Init(ViewTreeHostDelegate* delegate); | 51 void Init(ViewTreeHostDelegate* delegate); |
| 52 | 52 |
| 53 ViewTreeImpl* GetViewTree(); | 53 ViewTreeImpl* GetWindowTree(); |
| 54 | 54 |
| 55 mojo::ViewTreeHostClient* client() const { return client_.get(); } | 55 mojom::WindowTreeHostClient* client() const { return client_.get(); } |
| 56 | 56 |
| 57 cc::SurfaceId surface_id() const { return surface_id_; } | 57 cc::SurfaceId surface_id() const { return surface_id_; } |
| 58 | 58 |
| 59 // Returns whether |view| is a descendant of this root but not itself a | 59 // Returns whether |view| is a descendant of this root but not itself a |
| 60 // root view. | 60 // root view. |
| 61 bool IsViewAttachedToRoot(const ServerView* view) const; | 61 bool IsViewAttachedToRoot(const ServerView* view) const; |
| 62 | 62 |
| 63 // Schedules a paint for the specified region in the coordinates of |view| if | 63 // Schedules a paint for the specified region in the coordinates of |view| if |
| 64 // the |view| is in this viewport. Returns whether |view| is in the viewport. | 64 // the |view| is in this viewport. Returns whether |view| is in the viewport. |
| 65 bool SchedulePaintIfInViewport(const ServerView* view, | 65 bool SchedulePaintIfInViewport(const ServerView* view, |
| 66 const gfx::Rect& bounds); | 66 const gfx::Rect& bounds); |
| 67 | 67 |
| 68 // Returns the metrics for this viewport. | 68 // Returns the metrics for this viewport. |
| 69 const mojo::ViewportMetrics& GetViewportMetrics() const; | 69 const mojom::ViewportMetrics& GetViewportMetrics() const; |
| 70 | 70 |
| 71 ConnectionManager* connection_manager() { return connection_manager_; } | 71 ConnectionManager* connection_manager() { return connection_manager_; } |
| 72 | 72 |
| 73 // Returns the root ServerView of this viewport. | 73 // Returns the root ServerView of this viewport. |
| 74 ServerView* root_view() { return root_.get(); } | 74 ServerView* root_view() { return root_.get(); } |
| 75 const ServerView* root_view() const { return root_.get(); } | 75 const ServerView* root_view() const { return root_.get(); } |
| 76 | 76 |
| 77 void SetFocusedView(ServerView* view); | 77 void SetFocusedView(ServerView* view); |
| 78 ServerView* GetFocusedView(); | 78 ServerView* GetFocusedView(); |
| 79 void DestroyFocusController(); | 79 void DestroyFocusController(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 void RemoveAccelerator(uint32_t id) override; | 93 void RemoveAccelerator(uint32_t id) override; |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 void OnClientClosed(); | 96 void OnClientClosed(); |
| 97 | 97 |
| 98 // DisplayManagerDelegate: | 98 // DisplayManagerDelegate: |
| 99 ServerView* GetRootView() override; | 99 ServerView* GetRootView() override; |
| 100 void OnEvent(mojo::EventPtr event) override; | 100 void OnEvent(mojo::EventPtr event) override; |
| 101 void OnDisplayClosed() override; | 101 void OnDisplayClosed() override; |
| 102 void OnViewportMetricsChanged( | 102 void OnViewportMetricsChanged( |
| 103 const mojo::ViewportMetrics& old_metrics, | 103 const mojom::ViewportMetrics& old_metrics, |
| 104 const mojo::ViewportMetrics& new_metrics) override; | 104 const mojom::ViewportMetrics& new_metrics) override; |
| 105 void OnTopLevelSurfaceChanged(cc::SurfaceId surface_id) override; | 105 void OnTopLevelSurfaceChanged(cc::SurfaceId surface_id) override; |
| 106 | 106 |
| 107 // FocusControllerDelegate: | 107 // FocusControllerDelegate: |
| 108 void OnFocusChanged(ServerView* old_focused_view, | 108 void OnFocusChanged(ServerView* old_focused_view, |
| 109 ServerView* new_focused_view) override; | 109 ServerView* new_focused_view) override; |
| 110 | 110 |
| 111 ViewTreeHostDelegate* delegate_; | 111 ViewTreeHostDelegate* delegate_; |
| 112 ConnectionManager* const connection_manager_; | 112 ConnectionManager* const connection_manager_; |
| 113 mojo::ViewTreeHostClientPtr client_; | 113 mojom::WindowTreeHostClientPtr client_; |
| 114 EventDispatcher event_dispatcher_; | 114 EventDispatcher event_dispatcher_; |
| 115 scoped_ptr<ServerView> root_; | 115 scoped_ptr<ServerView> root_; |
| 116 scoped_ptr<DisplayManager> display_manager_; | 116 scoped_ptr<DisplayManager> display_manager_; |
| 117 scoped_ptr<FocusController> focus_controller_; | 117 scoped_ptr<FocusController> focus_controller_; |
| 118 cc::SurfaceId surface_id_; | 118 cc::SurfaceId surface_id_; |
| 119 | 119 |
| 120 DISALLOW_COPY_AND_ASSIGN(ViewTreeHostImpl); | 120 DISALLOW_COPY_AND_ASSIGN(ViewTreeHostImpl); |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 } // namespace mus | 123 } // namespace mus |
| 124 | 124 |
| 125 #endif // COMPONENTS_MUS_WS_VIEW_TREE_HOST_IMPL_H_ | 125 #endif // COMPONENTS_MUS_WS_VIEW_TREE_HOST_IMPL_H_ |
| OLD | NEW |