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 : public NativeViewportClient, |
| 37 public SurfaceClient { |
44 public: | 38 public: |
45 DisplayManager(ApplicationConnection* app_connection, | 39 DisplayManager(ApplicationConnection* app_connection, |
46 ConnectionManager* connection_manager, | 40 ConnectionManager* connection_manager, |
47 DisplayManagerDelegate* delegate, | |
48 const Callback<void()>& native_viewport_closed_callback); | 41 const Callback<void()>& native_viewport_closed_callback); |
49 virtual ~DisplayManager(); | 42 virtual ~DisplayManager(); |
50 | 43 |
51 // Schedules a paint for the specified region of the specified view. | 44 // Schedules a paint for the specified region of the specified view. |
52 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds); | 45 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds); |
53 | 46 |
54 // See description above field for details. | 47 // See description above field for details. |
55 bool in_setup() const { return in_setup_; } | 48 bool in_setup() const { return in_setup_; } |
56 | 49 |
57 private: | 50 private: |
58 class RootWindowDelegateImpl; | 51 void OnSurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); |
| 52 void Draw(); |
59 | 53 |
60 void OnCompositorCreated(); | 54 // NativeViewportClient implementation. |
| 55 virtual void OnCreated(uint64_t native_viewport_id) OVERRIDE; |
| 56 virtual void OnDestroyed() OVERRIDE; |
| 57 virtual void OnBoundsChanged(RectPtr bounds) OVERRIDE; |
| 58 virtual void OnEvent(EventPtr event, |
| 59 const mojo::Callback<void()>& callback) OVERRIDE; |
61 | 60 |
62 DisplayManagerDelegate* delegate_; | 61 // SurfaceClient implementation. |
| 62 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; |
63 | 63 |
64 ConnectionManager* connection_manager_; | 64 ConnectionManager* connection_manager_; |
65 | 65 |
66 // Returns true if adding the root view's window to |window_tree_host_|. | 66 // Returns true if adding the root view's window to |window_tree_host_|. |
67 bool in_setup_; | 67 bool in_setup_; |
68 | 68 |
69 scoped_ptr<RootWindowDelegateImpl> window_delegate_; | 69 gfx::Rect bounds_; |
| 70 gfx::Rect dirty_rect_; |
| 71 base::Timer draw_timer_; |
70 | 72 |
71 // Owned by its parent aura::Window. | 73 SurfacesServicePtr surfaces_service_; |
72 aura::Window* root_window_; | 74 SurfacePtr surface_; |
73 | 75 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
74 scoped_ptr<gfx::Screen> screen_; | 76 cc::SurfaceId surface_id_; |
75 scoped_ptr<aura::WindowTreeHost> window_tree_host_; | 77 NativeViewportPtr native_viewport_; |
76 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 78 Callback<void()> native_viewport_closed_callback_; |
77 scoped_ptr<aura::client::FocusClient> focus_client_; | 79 base::WeakPtrFactory<DisplayManager> weak_factory_; |
78 | 80 |
79 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | 81 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
80 }; | 82 }; |
81 | 83 |
82 } // namespace service | 84 } // namespace service |
83 } // namespace mojo | 85 } // namespace mojo |
84 | 86 |
85 #endif // MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 87 #endif // MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ |
OLD | NEW |