OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ | |
6 #define MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/basictypes.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" | |
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" | |
19 #include "ui/gfx/rect.h" | |
20 | |
21 namespace cc { | |
22 class SurfaceIdAllocator; | |
23 } | |
24 | |
25 namespace mojo { | |
26 | |
27 class ApplicationConnection; | |
28 | |
29 namespace service { | |
30 | |
31 class ConnectionManager; | |
32 class ServerView; | |
33 | |
34 // DisplayManager is used to connect the root ServerView to a display. | |
35 class DisplayManager { | |
36 public: | |
37 virtual ~DisplayManager() {} | |
38 | |
39 virtual void Init(ConnectionManager* connection_manager) = 0; | |
40 | |
41 // Schedules a paint for the specified region in the coordinates of |view|. | |
42 virtual void SchedulePaint(const ServerView* view, | |
43 const gfx::Rect& bounds) = 0; | |
44 | |
45 virtual void SetViewportSize(const gfx::Size& size) = 0; | |
46 }; | |
47 | |
48 // DisplayManager implementation that connects to the services necessary to | |
49 // actually display. | |
50 class DefaultDisplayManager : public DisplayManager, | |
51 public NativeViewportClient, | |
52 public SurfaceClient { | |
53 public: | |
54 DefaultDisplayManager( | |
55 ApplicationConnection* app_connection, | |
56 const Callback<void()>& native_viewport_closed_callback); | |
57 ~DefaultDisplayManager() override; | |
58 | |
59 // DisplayManager: | |
60 void Init(ConnectionManager* connection_manager) override; | |
61 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override; | |
62 void SetViewportSize(const gfx::Size& size) override; | |
63 | |
64 private: | |
65 void OnCreatedNativeViewport(uint64_t native_viewport_id); | |
66 void OnSurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); | |
67 void Draw(); | |
68 | |
69 // NativeViewportClient: | |
70 void OnDestroyed() override; | |
71 void OnSizeChanged(SizePtr size) override; | |
72 | |
73 // SurfaceClient: | |
74 void ReturnResources(Array<ReturnedResourcePtr> resources) override; | |
75 | |
76 ApplicationConnection* app_connection_; | |
77 ConnectionManager* connection_manager_; | |
78 | |
79 gfx::Size size_; | |
80 gfx::Rect dirty_rect_; | |
81 base::Timer draw_timer_; | |
82 | |
83 SurfacesServicePtr surfaces_service_; | |
84 SurfacePtr surface_; | |
85 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | |
86 cc::SurfaceId surface_id_; | |
87 NativeViewportPtr native_viewport_; | |
88 Callback<void()> native_viewport_closed_callback_; | |
89 base::WeakPtrFactory<DefaultDisplayManager> weak_factory_; | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager); | |
92 }; | |
93 | |
94 } // namespace service | |
95 } // namespace mojo | |
96 | |
97 #endif // MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_ | |
OLD | NEW |