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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 #include "base/bind.h"
6 #include "base/location.h"
7 #include "base/thread_task_runner_handle.h"
8 #include "services/native_viewport/ozone/display_manager.h"
9 #include "ui/display/types/display_snapshot.h"
10 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
11 #include "ui/ozone/platform/drm/host/drm_window_host.h"
12 #include "ui/ozone/public/ozone_platform.h"
13
14 namespace native_viewport {
15
16 DisplayManager::DisplayManager()
17 : delegate_(ui::OzonePlatform::GetInstance()
18 ->CreateNativeDisplayDelegate()) {
19 delegate_->AddObserver(this);
20 delegate_->Initialize();
21 OnConfigurationChanged();
22 }
23
24 DisplayManager::~DisplayManager() {
25 if (delegate_)
26 delegate_->RemoveObserver(this);
jamesr 2015/08/25 00:30:28 does this ensure that |delegate_| won't try to cal
cdotstout 2015/08/27 19:10:21 It ensures that OnConfigurationChanged won't be ca
27 }
28
29 void DisplayManager::OnConfigurationChanged() {
30 if (is_configuring_) {
31 should_configure_ = true;
32 return;
33 }
34
35 is_configuring_ = true;
36 delegate_->GrabServer();
37 delegate_->GetDisplays(
38 base::Bind(&DisplayManager::OnDisplaysAquired, base::Unretained(this)));
39 }
40
41 void DisplayManager::OnDisplaysAquired(
jamesr 2015/08/25 00:30:28 nit: i think it's spelled 'acquired'
cdotstout 2015/08/27 19:10:21 Done.
42 const std::vector<ui::DisplaySnapshot*>& displays) {
43 gfx::Point origin;
44 for (auto display : displays) {
45 if (!display->native_mode()) {
46 LOG(ERROR) << "Display " << display->display_id()
47 << " doesn't have a native mode";
48 continue;
49 }
50
51 delegate_->Configure(
52 *display, display->native_mode(), origin,
53 base::Bind(&DisplayManager::OnDisplayConfigured, base::Unretained(this),
54 gfx::Rect(origin, display->native_mode()->size())));
55 origin.Offset(display->native_mode()->size().width(), 0);
56 }
57 delegate_->UngrabServer();
58 is_configuring_ = false;
59
60 if (should_configure_) {
61 should_configure_ = false;
62 base::ThreadTaskRunnerHandle::Get()->PostTask(
63 FROM_HERE, base::Bind(&DisplayManager::OnConfigurationChanged,
64 base::Unretained(this)));
65 }
66 }
67
68 void DisplayManager::OnDisplayConfigured(const gfx::Rect& bounds,
69 bool success) {
70 auto platform_support_host = static_cast<ui::DrmGpuPlatformSupportHost*>(
71 ui::OzonePlatform::GetInstance()->GetGpuPlatformSupportHost());
72 platform_support_host->get_window_manager()->GetPrimaryWindow()->SetBounds(
73 bounds);
74 }
75
76 } // namespace
jamesr 2015/08/25 00:30:28 ditto
cdotstout 2015/08/27 19:10:21 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698