diff options
author | sky <sky@chromium.org> | 2015-04-20 20:08:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-21 03:08:28 +0000 |
commit | ba75ded669862381ab3885197562fe05982df6ad (patch) | |
tree | 70f5da5f668e6282aa8013c230633a1bcbb5bb25 /components/view_manager/display_manager.h | |
parent | c2a1922419f12248bf72a1ea744e66ced39b4cd5 (diff) | |
download | chromium_src-ba75ded669862381ab3885197562fe05982df6ad.zip chromium_src-ba75ded669862381ab3885197562fe05982df6ad.tar.gz chromium_src-ba75ded669862381ab3885197562fe05982df6ad.tar.bz2 |
Moves mojo/services/* to components/* part 3
Moves view_manager
R=ben@chromium.org
TBR=ben@chromium.org
BUG=none
TEST=none
Review URL: https://codereview.chromium.org/1100603004
Cr-Commit-Position: refs/heads/master@{#325973}
Diffstat (limited to 'components/view_manager/display_manager.h')
-rw-r--r-- | components/view_manager/display_manager.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/components/view_manager/display_manager.h b/components/view_manager/display_manager.h new file mode 100644 index 0000000..92026eb --- /dev/null +++ b/components/view_manager/display_manager.h @@ -0,0 +1,96 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ +#define COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ + +#include <map> + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" +#include "base/timer/timer.h" +#include "third_party/mojo/src/mojo/public/cpp/bindings/callback.h" +#include "third_party/mojo_services/src/native_viewport/public/interfaces/native_viewport.mojom.h" +#include "third_party/mojo_services/src/surfaces/public/interfaces/display.mojom.h" +#include "third_party/mojo_services/src/view_manager/public/interfaces/view_manager.mojom.h" +#include "ui/gfx/geometry/rect.h" + +namespace cc { +class SurfaceIdAllocator; +} + +namespace mojo { +class ApplicationConnection; +class ApplicationImpl; +} + +namespace view_manager { + +class ConnectionManager; +class ServerView; + +// DisplayManager is used to connect the root ServerView to a display. +class DisplayManager { + public: + virtual ~DisplayManager() {} + + virtual void Init(ConnectionManager* connection_manager) = 0; + + // Schedules a paint for the specified region in the coordinates of |view|. + virtual void SchedulePaint(const ServerView* view, + const gfx::Rect& bounds) = 0; + + virtual void SetViewportSize(const gfx::Size& size) = 0; + + virtual const mojo::ViewportMetrics& GetViewportMetrics() = 0; +}; + +// DisplayManager implementation that connects to the services necessary to +// actually display. +class DefaultDisplayManager : public DisplayManager, + public mojo::ErrorHandler { + public: + DefaultDisplayManager( + mojo::ApplicationImpl* app_impl, + mojo::ApplicationConnection* app_connection, + const mojo::Callback<void()>& native_viewport_closed_callback); + ~DefaultDisplayManager() override; + + // DisplayManager: + void Init(ConnectionManager* connection_manager) override; + void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override; + void SetViewportSize(const gfx::Size& size) override; + const mojo::ViewportMetrics& GetViewportMetrics() override; + + private: + void WantToDraw(); + void Draw(); + void DidDraw(); + + void OnMetricsChanged(mojo::ViewportMetricsPtr metrics); + + // ErrorHandler: + void OnConnectionError() override; + + mojo::ApplicationImpl* app_impl_; + mojo::ApplicationConnection* app_connection_; + ConnectionManager* connection_manager_; + + mojo::ViewportMetrics metrics_; + gfx::Rect dirty_rect_; + base::Timer draw_timer_; + bool frame_pending_; + + mojo::DisplayPtr display_; + mojo::NativeViewportPtr native_viewport_; + mojo::Callback<void()> native_viewport_closed_callback_; + base::WeakPtrFactory<DefaultDisplayManager> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(DefaultDisplayManager); +}; + +} // namespace view_manager + +#endif // COMPONENTS_VIEW_MANAGER_DISPLAY_MANAGER_H_ |