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

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

Issue 2503923003: Demonstrate external-window-mode in mus-demo (Closed)
Patch Set: Determine external window mode in mus-ws based on if a WM is connected Created 4 years 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"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/sys_info.h" 12 #include "base/sys_info.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "services/service_manager/public/cpp/interface_registry.h" 14 #include "services/service_manager/public/cpp/interface_registry.h"
15 #include "third_party/skia/include/core/SkColor.h" 15 #include "third_party/skia/include/core/SkColor.h"
16 #include "ui/display/types/display_constants.h" 16 #include "ui/display/types/display_constants.h"
17 #include "ui/display/types/display_snapshot.h" 17 #include "ui/display/types/display_snapshot.h"
18 #include "ui/display/types/native_display_delegate.h" 18 #include "ui/display/types/native_display_delegate.h"
19 #include "ui/gfx/geometry/rect.h" 19 #include "ui/gfx/geometry/rect.h"
20 #include "ui/ozone/public/ozone_platform.h" 20 #include "ui/ozone/public/ozone_platform.h"
21 #include "ui/ozone/public/ozone_switches.h"
21 22
22 namespace display { 23 namespace display {
23 namespace { 24 namespace {
24 25
25 // Needed for DisplayConfigurator::ForceInitialConfigure. 26 // Needed for DisplayConfigurator::ForceInitialConfigure.
26 const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); 27 const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe);
27 28
28 const float kInchInMm = 25.4f; 29 const float kInchInMm = 25.4f;
29 30
30 float ComputeDisplayDPI(const gfx::Size& pixel_size, 31 float ComputeDisplayDPI(const gfx::Size& pixel_size,
(...skipping 30 matching lines...) Expand all
61 fake_display_controller_ = nullptr; 62 fake_display_controller_ = nullptr;
62 display_configurator_.RemoveObserver(this); 63 display_configurator_.RemoveObserver(this);
63 } 64 }
64 65
65 void PlatformScreenOzone::AddInterfaces( 66 void PlatformScreenOzone::AddInterfaces(
66 service_manager::InterfaceRegistry* registry) { 67 service_manager::InterfaceRegistry* registry) {
67 registry->AddInterface<mojom::DisplayController>(this); 68 registry->AddInterface<mojom::DisplayController>(this);
68 registry->AddInterface<mojom::TestDisplayController>(this); 69 registry->AddInterface<mojom::TestDisplayController>(this);
69 } 70 }
70 71
71 void PlatformScreenOzone::Init(PlatformScreenDelegate* delegate) { 72 void PlatformScreenOzone::Init(PlatformScreenDelegate* delegate,
73 bool external_window_mode) {
72 DCHECK(delegate); 74 DCHECK(delegate);
73 delegate_ = delegate; 75 delegate_ = delegate;
74 76
75 std::unique_ptr<ui::NativeDisplayDelegate> native_display_delegate = 77 std::unique_ptr<ui::NativeDisplayDelegate> native_display_delegate =
76 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(); 78 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate();
77 79
78 // The FakeDisplayController gives us a way to make the NativeDisplayDelegate 80 // The FakeDisplayController gives us a way to make the NativeDisplayDelegate
79 // pretend something display related has happened. 81 // pretend something display related has happened.
80 if (!base::SysInfo::IsRunningOnChromeOS()) { 82 if (!base::SysInfo::IsRunningOnChromeOS()) {
81 fake_display_controller_ = 83 fake_display_controller_ =
82 native_display_delegate->GetFakeDisplayController(); 84 native_display_delegate->GetFakeDisplayController();
83 } 85 }
84 86
85 // We want display configuration to happen even off device to keep the control 87 if (!external_window_mode) {
86 // flow similar. 88 // We want display configuration to happen even off device to keep the
87 display_configurator_.set_configure_display(true); 89 // control
88 display_configurator_.AddObserver(this); 90 // flow similar.
89 display_configurator_.set_state_controller(this); 91 display_configurator_.set_configure_display(true);
90 display_configurator_.Init(std::move(native_display_delegate), false); 92 display_configurator_.AddObserver(this);
91 display_configurator_.ForceInitialConfigure(kChromeOsBootColor); 93 display_configurator_.set_state_controller(this);
94 display_configurator_.Init(std::move(native_display_delegate), false);
95 display_configurator_.ForceInitialConfigure(kChromeOsBootColor);
96 }
92 } 97 }
93 98
94 void PlatformScreenOzone::RequestCloseDisplay(int64_t display_id) { 99 void PlatformScreenOzone::RequestCloseDisplay(int64_t display_id) {
95 if (!fake_display_controller_ || wait_for_display_config_update_) 100 if (!fake_display_controller_ || wait_for_display_config_update_)
96 return; 101 return;
97 102
98 CachedDisplayIterator iter = GetCachedDisplayIterator(display_id); 103 CachedDisplayIterator iter = GetCachedDisplayIterator(display_id);
99 if (iter != cached_displays_.end()) { 104 if (iter != cached_displays_.end()) {
100 // Tell the NDD to remove the display. PlatformScreen will get an update 105 // Tell the NDD to remove the display. PlatformScreen will get an update
101 // that the display configuration has changed and the display will be gone. 106 // that the display configuration has changed and the display will be gone.
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 return false; 381 return false;
377 } 382 }
378 383
379 void PlatformScreenOzone::Create( 384 void PlatformScreenOzone::Create(
380 const service_manager::Identity& remote_identity, 385 const service_manager::Identity& remote_identity,
381 mojom::TestDisplayControllerRequest request) { 386 mojom::TestDisplayControllerRequest request) {
382 test_bindings_.AddBinding(this, std::move(request)); 387 test_bindings_.AddBinding(this, std::move(request));
383 } 388 }
384 389
385 } // namespace display 390 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698