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 SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 5 #ifndef SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ |
6 #define SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 6 #define 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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const gfx::Rect& bounds) = 0; | 43 const gfx::Rect& bounds) = 0; |
44 | 44 |
45 virtual void SetViewportSize(const gfx::Size& size) = 0; | 45 virtual void SetViewportSize(const gfx::Size& size) = 0; |
46 | 46 |
47 virtual const mojo::ViewportMetrics& GetViewportMetrics() = 0; | 47 virtual const mojo::ViewportMetrics& GetViewportMetrics() = 0; |
48 }; | 48 }; |
49 | 49 |
50 // DisplayManager implementation that connects to the services necessary to | 50 // DisplayManager implementation that connects to the services necessary to |
51 // actually display. | 51 // actually display. |
52 class DefaultDisplayManager : public DisplayManager, | 52 class DefaultDisplayManager : public DisplayManager, |
53 public mojo::SurfaceClient, | |
54 public mojo::ErrorHandler { | 53 public mojo::ErrorHandler { |
55 public: | 54 public: |
56 DefaultDisplayManager( | 55 DefaultDisplayManager( |
57 mojo::ApplicationConnection* app_connection, | 56 mojo::ApplicationConnection* app_connection, |
58 const mojo::Callback<void()>& native_viewport_closed_callback); | 57 const mojo::Callback<void()>& native_viewport_closed_callback); |
59 ~DefaultDisplayManager() override; | 58 ~DefaultDisplayManager() override; |
60 | 59 |
61 // DisplayManager: | 60 // DisplayManager: |
62 void Init(ConnectionManager* connection_manager) override; | 61 void Init(ConnectionManager* connection_manager) override; |
63 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override; | 62 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override; |
64 void SetViewportSize(const gfx::Size& size) override; | 63 void SetViewportSize(const gfx::Size& size) override; |
65 const mojo::ViewportMetrics& GetViewportMetrics() override; | 64 const mojo::ViewportMetrics& GetViewportMetrics() override; |
66 | 65 |
67 private: | 66 private: |
68 void OnCreatedNativeViewport(uint64_t native_viewport_id, | 67 void OnCreatedNativeViewport(uint64_t native_viewport_id, |
69 mojo::ViewportMetricsPtr metrics); | 68 mojo::ViewportMetricsPtr metrics); |
70 void Draw(); | 69 void Draw(); |
71 | 70 |
72 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics); | 71 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics); |
73 | 72 |
74 // SurfaceClient: | 73 void SetIdNamespace(uint32_t id_namespace); |
75 void SetIdNamespace(uint32_t id_namespace) override; | |
76 void ReturnResources( | |
77 mojo::Array<mojo::ReturnedResourcePtr> resources) override; | |
78 | 74 |
79 // ErrorHandler: | 75 // ErrorHandler: |
80 void OnConnectionError() override; | 76 void OnConnectionError() override; |
81 | 77 |
82 mojo::ApplicationConnection* app_connection_; | 78 mojo::ApplicationConnection* app_connection_; |
83 ConnectionManager* connection_manager_; | 79 ConnectionManager* connection_manager_; |
84 | 80 |
85 mojo::ViewportMetrics metrics_; | 81 mojo::ViewportMetrics metrics_; |
86 gfx::Rect dirty_rect_; | 82 gfx::Rect dirty_rect_; |
87 base::Timer draw_timer_; | 83 base::Timer draw_timer_; |
88 | 84 |
89 mojo::SurfacePtr surface_; | 85 mojo::SurfacePtr surface_; |
90 uint32_t id_namespace_; | 86 uint32_t id_namespace_; |
91 bool surface_allocated_; | 87 bool surface_allocated_; |
92 mojo::NativeViewportPtr native_viewport_; | 88 mojo::NativeViewportPtr native_viewport_; |
93 mojo::Callback<void()> native_viewport_closed_callback_; | 89 mojo::Callback<void()> native_viewport_closed_callback_; |
94 base::WeakPtrFactory<DefaultDisplayManager> weak_factory_; | 90 base::WeakPtrFactory<DefaultDisplayManager> weak_factory_; |
95 | 91 |
96 DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager); | 92 DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager); |
97 }; | 93 }; |
98 | 94 |
99 } // namespace view_manager | 95 } // namespace view_manager |
100 | 96 |
101 #endif // SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 97 #endif // SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ |
OLD | NEW |