| 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/native_viewport/native_viewport.h" |
| 14 #include "components/view_manager/public/interfaces/display.mojom.h" | 15 #include "components/view_manager/public/interfaces/display.mojom.h" |
| 15 #include "components/view_manager/public/interfaces/native_viewport.mojom.h" | |
| 16 #include "components/view_manager/public/interfaces/view_manager.mojom.h" | 16 #include "components/view_manager/public/interfaces/view_manager.mojom.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 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 class SurfaceIdAllocator; | 21 class SurfaceIdAllocator; |
| 22 } | 22 } // namespace cc |
| 23 |
| 24 namespace gles2 { |
| 25 class GpuState; |
| 26 } // namespace gles2 |
| 23 | 27 |
| 24 namespace mojo { | 28 namespace mojo { |
| 25 class ApplicationImpl; | 29 class ApplicationImpl; |
| 26 } | 30 } // namespace mojo |
| 27 | 31 |
| 28 namespace view_manager { | 32 namespace view_manager { |
| 29 | 33 |
| 30 class ConnectionManager; | 34 class ConnectionManager; |
| 31 class ServerView; | 35 class ServerView; |
| 32 | 36 |
| 33 // DisplayManager is used to connect the root ServerView to a display. | 37 // DisplayManager is used to connect the root ServerView to a display. |
| 34 class DisplayManager { | 38 class DisplayManager { |
| 35 public: | 39 public: |
| 36 virtual ~DisplayManager() {} | 40 virtual ~DisplayManager() {} |
| 37 | 41 |
| 38 virtual void Init( | 42 virtual void Init( |
| 39 ConnectionManager* connection_manager, | 43 ConnectionManager* connection_manager, |
| 40 mojo::NativeViewportEventDispatcherPtr event_dispatcher) = 0; | 44 EventDispatcher* event_dispatcher) = 0; |
| 41 | 45 |
| 42 // Schedules a paint for the specified region in the coordinates of |view|. | 46 // Schedules a paint for the specified region in the coordinates of |view|. |
| 43 virtual void SchedulePaint(const ServerView* view, | 47 virtual void SchedulePaint(const ServerView* view, |
| 44 const gfx::Rect& bounds) = 0; | 48 const gfx::Rect& bounds) = 0; |
| 45 | 49 |
| 46 virtual void SetViewportSize(const gfx::Size& size) = 0; | 50 virtual void SetViewportSize(const gfx::Size& size) = 0; |
| 47 | 51 |
| 48 virtual const mojo::ViewportMetrics& GetViewportMetrics() = 0; | 52 virtual const mojo::ViewportMetrics& GetViewportMetrics() = 0; |
| 49 }; | 53 }; |
| 50 | 54 |
| 51 // DisplayManager implementation that connects to the services necessary to | 55 // DisplayManager implementation that connects to the services necessary to |
| 52 // actually display. | 56 // actually display. |
| 53 class DefaultDisplayManager : public DisplayManager, | 57 class DefaultDisplayManager : public DisplayManager, |
| 54 public mojo::ErrorHandler { | 58 public mojo::ErrorHandler { |
| 55 public: | 59 public: |
| 56 DefaultDisplayManager( | 60 DefaultDisplayManager( |
| 57 mojo::ApplicationImpl* app_impl, | 61 mojo::ApplicationImpl* app_impl, |
| 62 const scoped_refptr<gles2::GpuState>& gpu_state, |
| 58 const mojo::Callback<void()>& native_viewport_closed_callback); | 63 const mojo::Callback<void()>& native_viewport_closed_callback); |
| 59 ~DefaultDisplayManager() override; | 64 ~DefaultDisplayManager() override; |
| 60 | 65 |
| 61 // DisplayManager: | 66 // DisplayManager: |
| 62 void Init(ConnectionManager* connection_manager, | 67 void Init(ConnectionManager* connection_manager, |
| 63 mojo::NativeViewportEventDispatcherPtr event_dispatcher) override; | 68 EventDispatcher* event_dispatcher) override; |
| 64 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override; | 69 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override; |
| 65 void SetViewportSize(const gfx::Size& size) override; | 70 void SetViewportSize(const gfx::Size& size) override; |
| 66 const mojo::ViewportMetrics& GetViewportMetrics() override; | 71 const mojo::ViewportMetrics& GetViewportMetrics() override; |
| 67 | 72 |
| 68 private: | 73 private: |
| 69 void WantToDraw(); | 74 void WantToDraw(); |
| 70 void Draw(); | 75 void Draw(); |
| 71 void DidDraw(); | 76 void DidDraw(); |
| 72 | 77 |
| 73 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics); | 78 void OnMetricsChanged(const gfx::Size& size, float device_scale_factor); |
| 74 | 79 |
| 75 // ErrorHandler: | 80 // ErrorHandler: |
| 76 void OnConnectionError() override; | 81 void OnConnectionError() override; |
| 77 | 82 |
| 78 mojo::ApplicationImpl* app_impl_; | 83 mojo::ApplicationImpl* app_impl_; |
| 84 scoped_refptr<gles2::GpuState> gpu_state_; |
| 79 ConnectionManager* connection_manager_; | 85 ConnectionManager* connection_manager_; |
| 80 | 86 |
| 81 mojo::ViewportMetrics metrics_; | 87 mojo::ViewportMetrics metrics_; |
| 82 gfx::Rect dirty_rect_; | 88 gfx::Rect dirty_rect_; |
| 83 base::Timer draw_timer_; | 89 base::Timer draw_timer_; |
| 84 bool frame_pending_; | 90 bool frame_pending_; |
| 85 | 91 |
| 86 mojo::DisplayPtr display_; | 92 mojo::DisplayPtr display_; |
| 87 mojo::NativeViewportPtr native_viewport_; | 93 scoped_ptr<NativeViewport> native_viewport_; |
| 88 mojo::Callback<void()> native_viewport_closed_callback_; | 94 mojo::Callback<void()> native_viewport_closed_callback_; |
| 95 |
| 89 base::WeakPtrFactory<DefaultDisplayManager> weak_factory_; | 96 base::WeakPtrFactory<DefaultDisplayManager> weak_factory_; |
| 90 | 97 |
| 91 DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager); | 98 DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager); |
| 92 }; | 99 }; |
| 93 | 100 |
| 94 } // namespace view_manager | 101 } // namespace view_manager |
| 95 | 102 |
| 96 #endif // COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ | 103 #endif // COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ |
| OLD | NEW |