OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ |
6 #define MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 6 #define MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/timer/timer.h" |
| 14 #include "cc/surfaces/surface_id.h" |
12 #include "mojo/public/cpp/bindings/callback.h" | 15 #include "mojo/public/cpp/bindings/callback.h" |
| 16 #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.
h" |
| 17 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" |
| 18 #include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" |
13 #include "mojo/services/view_manager/view_manager_export.h" | 19 #include "mojo/services/view_manager/view_manager_export.h" |
| 20 #include "ui/gfx/rect.h" |
14 | 21 |
15 namespace gfx { | 22 namespace cc { |
16 class Rect; | 23 class SurfaceIdAllocator; |
17 } | |
18 | |
19 namespace aura { | |
20 namespace client { | |
21 class FocusClient; | |
22 class WindowTreeClient; | |
23 } | |
24 class Window; | |
25 class WindowTreeHost; | |
26 } | |
27 | |
28 namespace gfx { | |
29 class Screen; | |
30 } | 24 } |
31 | 25 |
32 namespace mojo { | 26 namespace mojo { |
33 | 27 |
34 class ApplicationConnection; | 28 class ApplicationConnection; |
35 | 29 |
36 namespace service { | 30 namespace service { |
37 | 31 |
38 class ConnectionManager; | 32 class ConnectionManager; |
39 class DisplayManagerDelegate; | |
40 class ServerView; | 33 class ServerView; |
41 | 34 |
42 // DisplayManager binds the root view to an actual display. | 35 // DisplayManager binds the root node to an actual display. |
43 class MOJO_VIEW_MANAGER_EXPORT DisplayManager { | 36 class MOJO_VIEW_MANAGER_EXPORT DisplayManager |
| 37 : NON_EXPORTED_BASE(public NativeViewportClient), |
| 38 NON_EXPORTED_BASE(public SurfaceClient) { |
44 public: | 39 public: |
45 DisplayManager(ApplicationConnection* app_connection, | 40 DisplayManager(ApplicationConnection* app_connection, |
46 ConnectionManager* connection_manager, | 41 ConnectionManager* connection_manager, |
47 DisplayManagerDelegate* delegate, | |
48 const Callback<void()>& native_viewport_closed_callback); | 42 const Callback<void()>& native_viewport_closed_callback); |
49 virtual ~DisplayManager(); | 43 virtual ~DisplayManager(); |
50 | 44 |
51 // Schedules a paint for the specified region of the specified view. | 45 // Schedules a paint for the specified region of the specified view. |
52 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds); | 46 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds); |
53 | 47 |
54 // See description above field for details. | 48 // See description above field for details. |
55 bool in_setup() const { return in_setup_; } | 49 bool in_setup() const { return in_setup_; } |
56 | 50 |
57 private: | 51 private: |
58 class RootWindowDelegateImpl; | 52 void OnSurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); |
| 53 void Draw(); |
59 | 54 |
60 void OnCompositorCreated(); | 55 // NativeViewportClient implementation. |
| 56 virtual void OnCreated(uint64_t native_viewport_id) OVERRIDE; |
| 57 virtual void OnDestroyed() OVERRIDE; |
| 58 virtual void OnBoundsChanged(SizePtr bounds) OVERRIDE; |
| 59 virtual void OnEvent(EventPtr event, |
| 60 const mojo::Callback<void()>& callback) OVERRIDE; |
61 | 61 |
62 DisplayManagerDelegate* delegate_; | 62 // SurfaceClient implementation. |
| 63 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; |
63 | 64 |
64 ConnectionManager* connection_manager_; | 65 ConnectionManager* connection_manager_; |
65 | 66 |
66 // Returns true if adding the root view's window to |window_tree_host_|. | 67 // Returns true if adding the root view's window to |window_tree_host_|. |
67 bool in_setup_; | 68 bool in_setup_; |
68 | 69 |
69 scoped_ptr<RootWindowDelegateImpl> window_delegate_; | 70 gfx::Size bounds_; |
| 71 gfx::Rect dirty_rect_; |
| 72 base::Timer draw_timer_; |
70 | 73 |
71 // Owned by its parent aura::Window. | 74 SurfacesServicePtr surfaces_service_; |
72 aura::Window* root_window_; | 75 SurfacePtr surface_; |
73 | 76 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
74 scoped_ptr<gfx::Screen> screen_; | 77 cc::SurfaceId surface_id_; |
75 scoped_ptr<aura::WindowTreeHost> window_tree_host_; | 78 NativeViewportPtr native_viewport_; |
76 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 79 Callback<void()> native_viewport_closed_callback_; |
77 scoped_ptr<aura::client::FocusClient> focus_client_; | 80 base::WeakPtrFactory<DisplayManager> weak_factory_; |
78 | 81 |
79 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | 82 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
80 }; | 83 }; |
81 | 84 |
82 } // namespace service | 85 } // namespace service |
83 } // namespace mojo | 86 } // namespace mojo |
84 | 87 |
85 #endif // MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 88 #endif // MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ |
OLD | NEW |