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

Side by Side Diff: ui/ozone/platform/drm/host/drm_display_host_manager.cc

Issue 1131813003: [2/2][Ozone-Drm] Scan for displays on browser size during startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@handle-display-init3
Patch Set: rebased Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/drm/host/drm_device_handle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" 5 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <xf86drm.h> 9 #include <xf86drm.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
15 #include "base/threading/worker_pool.h" 15 #include "base/threading/worker_pool.h"
16 #include "ui/display/types/display_snapshot.h"
17 #include "ui/events/ozone/device/device_event.h" 16 #include "ui/events/ozone/device/device_event.h"
18 #include "ui/events/ozone/device/device_manager.h" 17 #include "ui/events/ozone/device/device_manager.h"
19 #include "ui/ozone/common/display_snapshot_proxy.h" 18 #include "ui/ozone/common/display_snapshot_proxy.h"
20 #include "ui/ozone/common/display_util.h" 19 #include "ui/ozone/common/display_util.h"
21 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" 20 #include "ui/ozone/common/gpu/ozone_gpu_messages.h"
21 #include "ui/ozone/platform/drm/common/drm_util.h"
22 #include "ui/ozone/platform/drm/host/drm_device_handle.h" 22 #include "ui/ozone/platform/drm/host/drm_device_handle.h"
23 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" 23 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
24 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" 24 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h"
25 25
26 namespace ui { 26 namespace ui {
27 27
28 namespace { 28 namespace {
29 29
30 typedef base::Callback<void(const base::FilePath&, scoped_ptr<DrmDeviceHandle>)> 30 typedef base::Callback<void(const base::FilePath&, scoped_ptr<DrmDeviceHandle>)>
31 OnOpenDeviceReplyCallback; 31 OnOpenDeviceReplyCallback;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (!handle->Initialize(primary_graphics_card_path_)) { 115 if (!handle->Initialize(primary_graphics_card_path_)) {
116 LOG(FATAL) << "Failed to open primary graphics card"; 116 LOG(FATAL) << "Failed to open primary graphics card";
117 return; 117 return;
118 } 118 }
119 drm_devices_.add(primary_graphics_card_path_, handle.Pass()); 119 drm_devices_.add(primary_graphics_card_path_, handle.Pass());
120 } 120 }
121 121
122 device_manager_->AddObserver(this); 122 device_manager_->AddObserver(this);
123 proxy_->RegisterHandler(this); 123 proxy_->RegisterHandler(this);
124 124
125 DisplaySnapshot_Params params; 125 DrmDeviceHandle* handle = drm_devices_.get(primary_graphics_card_path_);
126 bool success = false; 126 ScopedVector<HardwareDisplayControllerInfo> display_infos =
127 { 127 GetAvailableDisplayControllerInfos(handle->fd());
128 // The file generated by frecon that contains EDID for the 1st display. 128 has_dummy_display_ = !display_infos.empty();
129 const base::FilePath kEDIDFile("/tmp/display_info.bin"); 129 for (size_t i = 0; i < display_infos.size(); ++i) {
130 130 displays_.push_back(new DisplaySnapshotProxy(CreateDisplaySnapshotParams(
131 // Just read it on current thread as this is necessary information 131 display_infos[i], handle->fd(), i, gfx::Point())));
132 // to start. This access only tmpfs, which is fast.
133 // TODO(dnicoara|oshima): crbug.com/450886.
134 base::ThreadRestrictions::ScopedAllowIO allow_io;
135 success = CreateSnapshotFromEDIDFile(kEDIDFile, &params);
136 }
137
138 // Fallback to command line if the file doesn't exit or failed to read.
139 if (success || CreateSnapshotFromCommandLine(&params)) {
140 LOG_IF(ERROR, !success) << "Failed to read display_info.bin.";
141 DCHECK_NE(DISPLAY_CONNECTION_TYPE_NONE, params.type);
142 displays_.push_back(new DisplaySnapshotProxy(params));
143 has_dummy_display_ = true;
144 } else {
145 LOG(ERROR) << "Failed to obtain initial display info";
146 } 132 }
147 } 133 }
148 134
149 DrmDisplayHostManager::~DrmDisplayHostManager() { 135 DrmDisplayHostManager::~DrmDisplayHostManager() {
150 device_manager_->RemoveObserver(this); 136 device_manager_->RemoveObserver(this);
151 proxy_->UnregisterHandler(this); 137 proxy_->UnregisterHandler(this);
152 138
153 for (auto it = drm_devices_.begin(); it != drm_devices_.end(); ++it) { 139 for (auto it = drm_devices_.begin(); it != drm_devices_.end(); ++it) {
154 base::WorkerPool::PostTask(FROM_HERE, 140 base::WorkerPool::PostTask(FROM_HERE,
155 base::Bind(&CloseDeviceOnWorkerThread, 141 base::Bind(&CloseDeviceOnWorkerThread,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 const GetDisplaysCallback& callback) const { 417 const GetDisplaysCallback& callback) const {
432 callback.Run(displays_.get()); 418 callback.Run(displays_.get());
433 } 419 }
434 420
435 void DrmDisplayHostManager::NotifyDisplayDelegate() const { 421 void DrmDisplayHostManager::NotifyDisplayDelegate() const {
436 if (delegate_) 422 if (delegate_)
437 delegate_->OnConfigurationChanged(); 423 delegate_->OnConfigurationChanged();
438 } 424 }
439 425
440 } // namespace ui 426 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/host/drm_device_handle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698