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

Side by Side Diff: services/ui/display/platform_screen_ozone.cc

Issue 2324163002: Add FakeDisplayDelegate for off device usage. (Closed)
Patch Set: Rebase and expand. Created 4 years, 3 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/ui/display/platform_screen_ozone.h" 5 #include "services/ui/display/platform_screen_ozone.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 17 matching lines...) Expand all
28 } // namespace 28 } // namespace
29 29
30 // static 30 // static
31 std::unique_ptr<PlatformScreen> PlatformScreen::Create() { 31 std::unique_ptr<PlatformScreen> PlatformScreen::Create() {
32 return base::MakeUnique<PlatformScreenOzone>(); 32 return base::MakeUnique<PlatformScreenOzone>();
33 } 33 }
34 34
35 PlatformScreenOzone::PlatformScreenOzone() {} 35 PlatformScreenOzone::PlatformScreenOzone() {}
36 36
37 PlatformScreenOzone::~PlatformScreenOzone() { 37 PlatformScreenOzone::~PlatformScreenOzone() {
38 // We are shutting down and don't want anymore changes to virtual displays.
39 virtual_display_controller_ = nullptr;
38 display_configurator_.RemoveObserver(this); 40 display_configurator_.RemoveObserver(this);
39 } 41 }
40 42
41 void PlatformScreenOzone::AddInterfaces(shell::InterfaceRegistry* registry) { 43 void PlatformScreenOzone::AddInterfaces(shell::InterfaceRegistry* registry) {
42 registry->AddInterface<mojom::DisplayController>(this); 44 registry->AddInterface<mojom::DisplayController>(this);
43 } 45 }
44 46
45 void PlatformScreenOzone::Init(PlatformScreenDelegate* delegate) { 47 void PlatformScreenOzone::Init(PlatformScreenDelegate* delegate) {
46 DCHECK(delegate); 48 DCHECK(delegate);
47 delegate_ = delegate; 49 delegate_ = delegate;
48 50
51 std::unique_ptr<ui::NativeDisplayDelegate> native_display_delegate =
52 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate();
53
54 if (!base::SysInfo::IsRunningOnChromeOS()) {
55 virtual_display_controller_ =
56 native_display_delegate->GetVirtualDisplayController();
57 }
58
49 // We want display configuration to happen even off device to keep the control 59 // We want display configuration to happen even off device to keep the control
50 // flow similar. 60 // flow similar.
51 display_configurator_.set_configure_display(true); 61 display_configurator_.set_configure_display(true);
52 display_configurator_.AddObserver(this); 62 display_configurator_.AddObserver(this);
53 display_configurator_.Init( 63 display_configurator_.Init(std::move(native_display_delegate), false);
54 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), false); 64 display_configurator_.ForceInitialConfigure(kChromeOsBootColor);
55
56 if (base::SysInfo::IsRunningOnChromeOS()) {
57 display_configurator_.ForceInitialConfigure(kChromeOsBootColor);
58 } else {
59 if (base::CommandLine::ForCurrentProcess()->HasSwitch("multi-display")) {
60 // This really doesn't work properly. Use at your own risk.
61 display_configurator_.AddVirtualDisplay(gfx::Size(800, 800));
62 display_configurator_.AddVirtualDisplay(gfx::Size(800, 800));
63 } else {
64 display_configurator_.AddVirtualDisplay(gfx::Size(1024, 768));
65 }
66 }
67 } 65 }
68 66
69 int64_t PlatformScreenOzone::GetPrimaryDisplayId() const { 67 int64_t PlatformScreenOzone::GetPrimaryDisplayId() const {
70 return primary_display_id_; 68 return primary_display_id_;
71 } 69 }
72 70
73 void PlatformScreenOzone::ToggleVirtualDisplay() { 71 void PlatformScreenOzone::ToggleVirtualDisplay() {
74 if (base::SysInfo::IsRunningOnChromeOS()) 72 if (!virtual_display_controller_)
75 return; 73 return;
76 74
77 // TODO(kylechar): Convert to use VirtualDisplayDelegate once landed.
78 if (cached_displays_.size() == 1) { 75 if (cached_displays_.size() == 1) {
79 display_configurator_.AddVirtualDisplay(cached_displays_[0].bounds.size()); 76 virtual_display_controller_->AddVirtualDisplay(
77 cached_displays_[0].bounds.size());
80 } else if (cached_displays_.size() > 1) { 78 } else if (cached_displays_.size() > 1) {
81 display_configurator_.RemoveVirtualDisplay(cached_displays_.back().id); 79 virtual_display_controller_->RemoveVirtualDisplay(
80 cached_displays_.back().id);
82 } else { 81 } else {
83 NOTREACHED(); 82 NOTREACHED();
84 } 83 }
85 } 84 }
86 85
87 void PlatformScreenOzone::ProcessRemovedDisplays( 86 void PlatformScreenOzone::ProcessRemovedDisplays(
88 const ui::DisplayConfigurator::DisplayStateList& snapshots) { 87 const ui::DisplayConfigurator::DisplayStateList& snapshots) {
89 std::vector<int64_t> current_ids; 88 std::vector<int64_t> current_ids;
90 for (ui::DisplaySnapshot* snapshot : snapshots) 89 for (ui::DisplaySnapshot* snapshot : snapshots)
91 current_ids.push_back(snapshot->display_id()); 90 current_ids.push_back(snapshot->display_id());
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 ui::MultipleDisplayState failed_new_state) { 199 ui::MultipleDisplayState failed_new_state) {
201 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator"; 200 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator";
202 } 201 }
203 202
204 void PlatformScreenOzone::Create(const shell::Identity& remote_identity, 203 void PlatformScreenOzone::Create(const shell::Identity& remote_identity,
205 mojom::DisplayControllerRequest request) { 204 mojom::DisplayControllerRequest request) {
206 bindings_.AddBinding(this, std::move(request)); 205 bindings_.AddBinding(this, std::move(request));
207 } 206 }
208 207
209 } // namespace display 208 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698