Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: components/mus/display_manager.h

Issue 1377493002: mus: move View Manager to components/mus/vm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/default_access_policy.cc ('k') | components/mus/display_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 COMPONENTS_MUS_DISPLAY_MANAGER_H_
6 #define COMPONENTS_MUS_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 "components/mus/display_manager_delegate.h"
15 #include "components/mus/public/interfaces/view_tree.mojom.h"
16 #include "components/mus/surfaces/top_level_display_client.h"
17 #include "third_party/mojo/src/mojo/public/cpp/bindings/callback.h"
18 #include "ui/gfx/geometry/rect.h"
19 #include "ui/platform_window/platform_window_delegate.h"
20
21 namespace cc {
22 class SurfaceIdAllocator;
23 class SurfaceManager;
24 } // namespace cc
25
26 namespace gles2 {
27 class GpuState;
28 } // namespace gles2
29
30 namespace mojo {
31 class ApplicationImpl;
32 } // namespace mojo
33
34 namespace ui {
35 class PlatformWindow;
36 struct TextInputState;
37 } // namespace ui
38
39 namespace mus {
40
41 class DisplayManagerFactory;
42 class EventDispatcher;
43 class ServerView;
44 class SurfacesScheduler;
45 class SurfacesState;
46
47 // DisplayManager is used to connect the root ServerView to a display.
48 class DisplayManager {
49 public:
50 virtual ~DisplayManager() {}
51
52 static DisplayManager* Create(
53 mojo::ApplicationImpl* app_impl,
54 const scoped_refptr<GpuState>& gpu_state,
55 const scoped_refptr<SurfacesState>& surfaces_state);
56
57 virtual void Init(DisplayManagerDelegate* delegate) = 0;
58
59 // Schedules a paint for the specified region in the coordinates of |view|.
60 virtual void SchedulePaint(const ServerView* view,
61 const gfx::Rect& bounds) = 0;
62
63 virtual void SetViewportSize(const gfx::Size& size) = 0;
64
65 virtual void SetTitle(const base::string16& title) = 0;
66
67 virtual const mojo::ViewportMetrics& GetViewportMetrics() = 0;
68
69 virtual void UpdateTextInputState(const ui::TextInputState& state) = 0;
70 virtual void SetImeVisibility(bool visible) = 0;
71
72 // Overrides factory for testing. Default (NULL) value indicates regular
73 // (non-test) environment.
74 static void set_factory_for_testing(DisplayManagerFactory* factory) {
75 DisplayManager::factory_ = factory;
76 }
77
78 private:
79 // Static factory instance (always NULL for non-test).
80 static DisplayManagerFactory* factory_;
81 };
82
83 // DisplayManager implementation that connects to the services necessary to
84 // actually display.
85 class DefaultDisplayManager : public DisplayManager,
86 public ui::PlatformWindowDelegate {
87 public:
88 DefaultDisplayManager(mojo::ApplicationImpl* app_impl,
89 const scoped_refptr<GpuState>& gpu_state,
90 const scoped_refptr<SurfacesState>& surfaces_state);
91 ~DefaultDisplayManager() override;
92
93 // DisplayManager:
94 void Init(DisplayManagerDelegate* delegate) override;
95 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override;
96 void SetViewportSize(const gfx::Size& size) override;
97 void SetTitle(const base::string16& title) override;
98 const mojo::ViewportMetrics& GetViewportMetrics() override;
99 void UpdateTextInputState(const ui::TextInputState& state) override;
100 void SetImeVisibility(bool visible) override;
101
102 private:
103 void WantToDraw();
104
105 // This method initiates a top level redraw of the display.
106 // TODO(fsamuel): This should use vblank as a signal rather than a timer
107 // http://crbug.com/533042
108 void Draw();
109
110 // This is called after cc::Display has completed generating a new frame
111 // for the display. TODO(fsamuel): Idle time processing should happen here
112 // if there is budget for it.
113 void DidDraw();
114 void UpdateMetrics(const gfx::Size& size, float device_pixel_ratio);
115 scoped_ptr<cc::CompositorFrame> GenerateCompositorFrame();
116
117 // ui::PlatformWindowDelegate:
118 void OnBoundsChanged(const gfx::Rect& new_bounds) override;
119 void OnDamageRect(const gfx::Rect& damaged_region) override;
120 void DispatchEvent(ui::Event* event) override;
121 void OnCloseRequest() override;
122 void OnClosed() override;
123 void OnWindowStateChanged(ui::PlatformWindowState new_state) override;
124 void OnLostCapture() override;
125 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
126 float device_pixel_ratio) override;
127 void OnActivationChanged(bool active) override;
128
129 mojo::ApplicationImpl* app_impl_;
130 scoped_refptr<GpuState> gpu_state_;
131 scoped_refptr<SurfacesState> surfaces_state_;
132 DisplayManagerDelegate* delegate_;
133
134 mojo::ViewportMetrics metrics_;
135 gfx::Rect dirty_rect_;
136 base::Timer draw_timer_;
137 bool frame_pending_;
138
139 scoped_ptr<TopLevelDisplayClient> top_level_display_client_;
140 scoped_ptr<ui::PlatformWindow> platform_window_;
141
142 base::WeakPtrFactory<DefaultDisplayManager> weak_factory_;
143
144 DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager);
145 };
146
147 } // namespace mus
148
149 #endif // COMPONENTS_MUS_DISPLAY_MANAGER_H_
OLDNEW
« no previous file with comments | « components/mus/default_access_policy.cc ('k') | components/mus/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698