Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: services/native_viewport/ozone/display_manager.cc

Issue 1309273005: native_viewport support for ozone (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/native_viewport/ozone/display_manager.cc
diff --git a/services/native_viewport/ozone/display_manager.cc b/services/native_viewport/ozone/display_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9a7f4365201b9fca7f4fe8b114b5c531b09905e3
--- /dev/null
+++ b/services/native_viewport/ozone/display_manager.cc
@@ -0,0 +1,85 @@
+// Copyright 2015 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.
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/thread_task_runner_handle.h"
+#include "services/native_viewport/ozone/display_manager.h"
+#include "ui/display/types/display_snapshot.h"
+#include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
+#include "ui/ozone/platform/drm/host/drm_window_host.h"
+#include "ui/ozone/public/ozone_platform.h"
+
+namespace native_viewport {
+
+DisplayManager::DisplayManager()
+ : delegate_(ui::OzonePlatform::GetInstance()
+ ->CreateNativeDisplayDelegate()),
+ is_configuring_(false),
+ should_configure_(false),
+ weak_factory_(this) {
+ delegate_->AddObserver(this);
+ delegate_->Initialize();
+ OnConfigurationChanged();
+}
+
+DisplayManager::~DisplayManager() {
+ if (delegate_)
+ delegate_->RemoveObserver(this);
+}
+
+void DisplayManager::OnConfigurationChanged() {
+ VLOG(1) << "DisplayManager::OnConfigurationChanged is_configuring_ "
+ << is_configuring_;
+ if (is_configuring_) {
+ should_configure_ = true;
+ return;
+ }
+
+ is_configuring_ = true;
+ delegate_->GrabServer();
+ delegate_->GetDisplays(base::Bind(&DisplayManager::OnDisplaysAcquired,
+ weak_factory_.GetWeakPtr()));
+}
+
+void DisplayManager::OnDisplaysAcquired(
+ const std::vector<ui::DisplaySnapshot*>& displays) {
+ gfx::Point origin;
+ VLOG(1) << "OnDisplaysAcquired displays " << displays.size();
+
+ for (auto display : displays) {
+ if (!display->native_mode()) {
+ LOG(ERROR) << "Display " << display->display_id()
+ << " doesn't have a native mode";
+ continue;
+ }
+
+ delegate_->Configure(
+ *display, display->native_mode(), origin,
+ base::Bind(&DisplayManager::OnDisplayConfigured,
+ weak_factory_.GetWeakPtr(),
+ gfx::Rect(origin, display->native_mode()->size())));
+ origin.Offset(display->native_mode()->size().width(), 0);
+ }
+ delegate_->UngrabServer();
+ is_configuring_ = false;
+
+ VLOG(1) << "OnDisplaysAcquired should_configure_ " << should_configure_;
+ if (should_configure_) {
+ should_configure_ = false;
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&DisplayManager::OnConfigurationChanged,
+ base::Unretained(this)));
+ }
+}
+
+void DisplayManager::OnDisplayConfigured(const gfx::Rect& bounds,
+ bool success) {
+ auto platform_support_host = static_cast<ui::DrmGpuPlatformSupportHost*>(
+ ui::OzonePlatform::GetInstance()->GetGpuPlatformSupportHost());
+ platform_support_host->get_window_manager()->GetPrimaryWindow()->SetBounds(
+ bounds);
+}
+
+} // namespace native_viewport
« no previous file with comments | « services/native_viewport/ozone/display_manager.h ('k') | services/native_viewport/ozone/platform_viewport_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698