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