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.
5 #ifndef MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_
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 "mojo/services/view_manager/view_manager_export.h"
20 #include "ui/gfx/rect.h"
23 class SurfaceIdAllocator;
28 class ApplicationConnection;
32 class ConnectionManager;
35 // DisplayManager binds the root node to an actual display.
36 class MOJO_VIEW_MANAGER_EXPORT DisplayManager
37 : NON_EXPORTED_BASE(public NativeViewportClient),
38 NON_EXPORTED_BASE(public SurfaceClient) {
40 DisplayManager(ApplicationConnection* app_connection,
41 ConnectionManager* connection_manager,
42 const Callback<void()>& native_viewport_closed_callback);
43 virtual ~DisplayManager();
45 // Schedules a paint for the specified region of the specified view.
46 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds);
48 // See description above field for details.
49 bool in_setup() const { return in_setup_; }
52 void OnSurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace);
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;
62 // SurfaceClient implementation.
63 virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE;
65 ConnectionManager* connection_manager_;
67 // Returns true if adding the root view's window to |window_tree_host_|.
71 gfx::Rect dirty_rect_;
72 base::Timer draw_timer_;
74 SurfacesServicePtr surfaces_service_;
76 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
77 cc::SurfaceId surface_id_;
78 NativeViewportPtr native_viewport_;
79 Callback<void()> native_viewport_closed_callback_;
80 base::WeakPtrFactory<DisplayManager> weak_factory_;
82 DISALLOW_COPY_AND_ASSIGN(DisplayManager);
85 } // namespace service
88 #endif // MOJO_SERVICES_VIEW_MANAGER_DISPLAY_MANAGER_H_