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 COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 5 #ifndef COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ |
6 #define COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 6 #define COMPONENTS_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" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "components/view_manager/display_manager_delegate.h" | 14 #include "components/view_manager/display_manager_delegate.h" |
15 #include "components/view_manager/native_viewport/platform_viewport.h" | |
16 #include "components/view_manager/public/interfaces/display.mojom.h" | 15 #include "components/view_manager/public/interfaces/display.mojom.h" |
17 #include "components/view_manager/public/interfaces/view_manager.mojom.h" | 16 #include "components/view_manager/public/interfaces/view_manager.mojom.h" |
18 #include "third_party/mojo/src/mojo/public/cpp/bindings/callback.h" | 17 #include "third_party/mojo/src/mojo/public/cpp/bindings/callback.h" |
19 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/platform_window/platform_window_delegate.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 class SurfaceIdAllocator; | 22 class SurfaceIdAllocator; |
23 } // namespace cc | 23 } // namespace cc |
24 | 24 |
25 namespace gles2 { | 25 namespace gles2 { |
26 class GpuState; | 26 class GpuState; |
27 } // namespace gles2 | 27 } // namespace gles2 |
28 | 28 |
29 namespace native_viewport { | 29 namespace native_viewport { |
30 class OnscreenContextProvider; | 30 class OnscreenContextProvider; |
31 } // namespace native_viewport | 31 } // namespace native_viewport |
32 | 32 |
33 namespace mojo { | 33 namespace mojo { |
34 class ApplicationImpl; | 34 class ApplicationImpl; |
35 } // namespace mojo | 35 } // namespace mojo |
36 | 36 |
| 37 namespace ui { |
| 38 class PlatformWindow; |
| 39 } |
| 40 |
37 namespace view_manager { | 41 namespace view_manager { |
38 | 42 |
39 class DisplayManagerFactory; | 43 class DisplayManagerFactory; |
40 class EventDispatcher; | 44 class EventDispatcher; |
41 class ServerView; | 45 class ServerView; |
42 | 46 |
43 // DisplayManager is used to connect the root ServerView to a display. | 47 // DisplayManager is used to connect the root ServerView to a display. |
44 class DisplayManager { | 48 class DisplayManager { |
45 public: | 49 public: |
46 virtual ~DisplayManager() {} | 50 virtual ~DisplayManager() {} |
(...skipping 21 matching lines...) Expand all Loading... |
68 | 72 |
69 private: | 73 private: |
70 // Static factory instance (always NULL for non-test). | 74 // Static factory instance (always NULL for non-test). |
71 static DisplayManagerFactory* factory_; | 75 static DisplayManagerFactory* factory_; |
72 }; | 76 }; |
73 | 77 |
74 // DisplayManager implementation that connects to the services necessary to | 78 // DisplayManager implementation that connects to the services necessary to |
75 // actually display. | 79 // actually display. |
76 class DefaultDisplayManager : | 80 class DefaultDisplayManager : |
77 public DisplayManager, | 81 public DisplayManager, |
78 public native_viewport::PlatformViewport::Delegate { | 82 public ui::PlatformWindowDelegate { |
79 public: | 83 public: |
80 DefaultDisplayManager(bool is_headless, | 84 DefaultDisplayManager(bool is_headless, |
81 mojo::ApplicationImpl* app_impl, | 85 mojo::ApplicationImpl* app_impl, |
82 const scoped_refptr<gles2::GpuState>& gpu_state); | 86 const scoped_refptr<gles2::GpuState>& gpu_state); |
83 ~DefaultDisplayManager() override; | 87 ~DefaultDisplayManager() override; |
84 | 88 |
85 // DisplayManager: | 89 // DisplayManager: |
86 void Init(DisplayManagerDelegate* delegate) override; | 90 void Init(DisplayManagerDelegate* delegate) override; |
87 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override; | 91 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override; |
88 void SetViewportSize(const gfx::Size& size) override; | 92 void SetViewportSize(const gfx::Size& size) override; |
89 const mojo::ViewportMetrics& GetViewportMetrics() override; | 93 const mojo::ViewportMetrics& GetViewportMetrics() override; |
90 | 94 |
91 private: | 95 private: |
92 void WantToDraw(); | 96 void WantToDraw(); |
93 void Draw(); | 97 void Draw(); |
94 void DidDraw(); | 98 void DidDraw(); |
| 99 void UpdateMetrics(const gfx::Size& size, float device_pixel_ratio); |
95 | 100 |
96 // PlatformViewport::Delegate implementation: | 101 // ui::PlatformWindowDelegate: |
| 102 void OnBoundsChanged(const gfx::Rect& new_bounds) override; |
| 103 void OnDamageRect(const gfx::Rect& damaged_region) override; |
| 104 void DispatchEvent(ui::Event* event) override; |
| 105 void OnCloseRequest() override; |
| 106 void OnClosed() override; |
| 107 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; |
| 108 void OnLostCapture() override; |
97 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, | 109 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, |
98 float device_pixel_ratio) override; | 110 float device_pixel_ratio) override; |
99 void OnAcceleratedWidgetDestroyed() override; | 111 void OnActivationChanged(bool active) override; |
100 void OnEvent(mojo::EventPtr event) override; | |
101 void OnMetricsChanged(const gfx::Size& size, | |
102 float device_scale_factor) override; | |
103 void OnDestroyed() override; | |
104 | 112 |
105 bool is_headless_; | 113 bool is_headless_; |
106 mojo::ApplicationImpl* app_impl_; | 114 mojo::ApplicationImpl* app_impl_; |
107 scoped_refptr<gles2::GpuState> gpu_state_; | 115 scoped_refptr<gles2::GpuState> gpu_state_; |
108 DisplayManagerDelegate* delegate_; | 116 DisplayManagerDelegate* delegate_; |
109 | 117 |
110 mojo::ViewportMetrics metrics_; | 118 mojo::ViewportMetrics metrics_; |
111 gfx::Rect dirty_rect_; | 119 gfx::Rect dirty_rect_; |
112 base::Timer draw_timer_; | 120 base::Timer draw_timer_; |
113 bool frame_pending_; | 121 bool frame_pending_; |
114 | 122 |
115 mojo::DisplayPtr display_; | 123 mojo::DisplayPtr display_; |
116 scoped_ptr<native_viewport::OnscreenContextProvider> context_provider_; | 124 scoped_ptr<native_viewport::OnscreenContextProvider> context_provider_; |
117 scoped_ptr<native_viewport::PlatformViewport> platform_viewport_; | 125 scoped_ptr<ui::PlatformWindow> platform_window_; |
118 | 126 |
119 base::WeakPtrFactory<DefaultDisplayManager> weak_factory_; | 127 base::WeakPtrFactory<DefaultDisplayManager> weak_factory_; |
120 | 128 |
121 DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager); | 129 DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager); |
122 }; | 130 }; |
123 | 131 |
124 } // namespace view_manager | 132 } // namespace view_manager |
125 | 133 |
126 #endif // COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 134 #endif // COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ |
OLD | NEW |