| 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/public/interfaces/display.mojom.h" | |
| 16 #include "components/view_manager/public/interfaces/view_manager.mojom.h" | 15 #include "components/view_manager/public/interfaces/view_manager.mojom.h" |
| 16 #include "components/view_manager/surfaces/top_level_display_client.h" |
| 17 #include "third_party/mojo/src/mojo/public/cpp/bindings/callback.h" | 17 #include "third_party/mojo/src/mojo/public/cpp/bindings/callback.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/platform_window/platform_window_delegate.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 class SurfaceManager; |
| 23 } // namespace cc | 24 } // namespace cc |
| 24 | 25 |
| 25 namespace gles2 { | 26 namespace gles2 { |
| 26 class GpuState; | 27 class GpuState; |
| 27 } // namespace gles2 | 28 } // namespace gles2 |
| 28 | 29 |
| 29 namespace native_viewport { | |
| 30 class OnscreenContextProvider; | |
| 31 } // namespace native_viewport | |
| 32 | |
| 33 namespace mojo { | 30 namespace mojo { |
| 34 class ApplicationImpl; | 31 class ApplicationImpl; |
| 35 } // namespace mojo | 32 } // namespace mojo |
| 36 | 33 |
| 34 namespace surfaces { |
| 35 class SurfacesScheduler; |
| 36 class SurfacesState; |
| 37 } // namespace surfaces |
| 38 |
| 37 namespace ui { | 39 namespace ui { |
| 38 class PlatformWindow; | 40 class PlatformWindow; |
| 39 struct TextInputState; | 41 struct TextInputState; |
| 40 } | 42 } // namespace ui |
| 41 | 43 |
| 42 namespace view_manager { | 44 namespace view_manager { |
| 43 | 45 |
| 44 class DisplayManagerFactory; | 46 class DisplayManagerFactory; |
| 45 class EventDispatcher; | 47 class EventDispatcher; |
| 46 class ServerView; | 48 class ServerView; |
| 47 | 49 |
| 48 // DisplayManager is used to connect the root ServerView to a display. | 50 // DisplayManager is used to connect the root ServerView to a display. |
| 49 class DisplayManager { | 51 class DisplayManager { |
| 50 public: | 52 public: |
| 51 virtual ~DisplayManager() {} | 53 virtual ~DisplayManager() {} |
| 52 | 54 |
| 53 static DisplayManager* Create( | 55 static DisplayManager* Create( |
| 54 bool is_headless, | 56 bool is_headless, |
| 55 mojo::ApplicationImpl* app_impl, | 57 mojo::ApplicationImpl* app_impl, |
| 56 const scoped_refptr<gles2::GpuState>& gpu_state); | 58 const scoped_refptr<gles2::GpuState>& gpu_state, |
| 59 const scoped_refptr<surfaces::SurfacesState>& surfaces_state); |
| 57 | 60 |
| 58 virtual void Init(DisplayManagerDelegate* delegate) = 0; | 61 virtual void Init(DisplayManagerDelegate* delegate) = 0; |
| 59 | 62 |
| 60 // Schedules a paint for the specified region in the coordinates of |view|. | 63 // Schedules a paint for the specified region in the coordinates of |view|. |
| 61 virtual void SchedulePaint(const ServerView* view, | 64 virtual void SchedulePaint(const ServerView* view, |
| 62 const gfx::Rect& bounds) = 0; | 65 const gfx::Rect& bounds) = 0; |
| 63 | 66 |
| 64 virtual void SetViewportSize(const gfx::Size& size) = 0; | 67 virtual void SetViewportSize(const gfx::Size& size) = 0; |
| 65 | 68 |
| 66 virtual const mojo::ViewportMetrics& GetViewportMetrics() = 0; | 69 virtual const mojo::ViewportMetrics& GetViewportMetrics() = 0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 78 // Static factory instance (always NULL for non-test). | 81 // Static factory instance (always NULL for non-test). |
| 79 static DisplayManagerFactory* factory_; | 82 static DisplayManagerFactory* factory_; |
| 80 }; | 83 }; |
| 81 | 84 |
| 82 // DisplayManager implementation that connects to the services necessary to | 85 // DisplayManager implementation that connects to the services necessary to |
| 83 // actually display. | 86 // actually display. |
| 84 class DefaultDisplayManager : | 87 class DefaultDisplayManager : |
| 85 public DisplayManager, | 88 public DisplayManager, |
| 86 public ui::PlatformWindowDelegate { | 89 public ui::PlatformWindowDelegate { |
| 87 public: | 90 public: |
| 88 DefaultDisplayManager(bool is_headless, | 91 DefaultDisplayManager( |
| 89 mojo::ApplicationImpl* app_impl, | 92 bool is_headless, |
| 90 const scoped_refptr<gles2::GpuState>& gpu_state); | 93 mojo::ApplicationImpl* app_impl, |
| 94 const scoped_refptr<gles2::GpuState>& gpu_state, |
| 95 const scoped_refptr<surfaces::SurfacesState>& surfaces_state); |
| 91 ~DefaultDisplayManager() override; | 96 ~DefaultDisplayManager() override; |
| 92 | 97 |
| 93 // DisplayManager: | 98 // DisplayManager: |
| 94 void Init(DisplayManagerDelegate* delegate) override; | 99 void Init(DisplayManagerDelegate* delegate) override; |
| 95 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override; | 100 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override; |
| 96 void SetViewportSize(const gfx::Size& size) override; | 101 void SetViewportSize(const gfx::Size& size) override; |
| 97 const mojo::ViewportMetrics& GetViewportMetrics() override; | 102 const mojo::ViewportMetrics& GetViewportMetrics() override; |
| 98 void UpdateTextInputState(const ui::TextInputState& state) override; | 103 void UpdateTextInputState(const ui::TextInputState& state) override; |
| 99 void SetImeVisibility(bool visible) override; | 104 void SetImeVisibility(bool visible) override; |
| 100 | 105 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 112 void OnClosed() override; | 117 void OnClosed() override; |
| 113 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; | 118 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; |
| 114 void OnLostCapture() override; | 119 void OnLostCapture() override; |
| 115 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, | 120 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, |
| 116 float device_pixel_ratio) override; | 121 float device_pixel_ratio) override; |
| 117 void OnActivationChanged(bool active) override; | 122 void OnActivationChanged(bool active) override; |
| 118 | 123 |
| 119 bool is_headless_; | 124 bool is_headless_; |
| 120 mojo::ApplicationImpl* app_impl_; | 125 mojo::ApplicationImpl* app_impl_; |
| 121 scoped_refptr<gles2::GpuState> gpu_state_; | 126 scoped_refptr<gles2::GpuState> gpu_state_; |
| 127 scoped_refptr<surfaces::SurfacesState> surfaces_state_; |
| 122 DisplayManagerDelegate* delegate_; | 128 DisplayManagerDelegate* delegate_; |
| 123 | 129 |
| 124 mojo::ViewportMetrics metrics_; | 130 mojo::ViewportMetrics metrics_; |
| 125 gfx::Rect dirty_rect_; | 131 gfx::Rect dirty_rect_; |
| 126 base::Timer draw_timer_; | 132 base::Timer draw_timer_; |
| 127 bool frame_pending_; | 133 bool frame_pending_; |
| 128 | 134 |
| 129 mojo::DisplayPtr display_; | 135 scoped_ptr<surfaces::TopLevelDisplayClient> top_level_display_client_; |
| 130 scoped_ptr<native_viewport::OnscreenContextProvider> context_provider_; | |
| 131 scoped_ptr<ui::PlatformWindow> platform_window_; | 136 scoped_ptr<ui::PlatformWindow> platform_window_; |
| 132 | 137 |
| 133 base::WeakPtrFactory<DefaultDisplayManager> weak_factory_; | 138 base::WeakPtrFactory<DefaultDisplayManager> weak_factory_; |
| 134 | 139 |
| 135 DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager); | 140 DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager); |
| 136 }; | 141 }; |
| 137 | 142 |
| 138 } // namespace view_manager | 143 } // namespace view_manager |
| 139 | 144 |
| 140 #endif // COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 145 #endif // COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ |
| OLD | NEW |