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

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

Issue 2190633002: Add flag to launch two displays for mus+ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix. Created 4 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
« no previous file with comments | « no previous file | services/ui/ws/display.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_impl_ozone.h" 5 #include "services/ui/display/platform_screen_impl_ozone.h"
6 6
7 #include "base/command_line.h"
7 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
8 #include "base/sys_info.h" 9 #include "base/sys_info.h"
9 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
10 #include "third_party/skia/include/core/SkColor.h" 11 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/display/types/display_constants.h" 12 #include "ui/display/types/display_constants.h"
12 #include "ui/display/types/display_snapshot.h" 13 #include "ui/display/types/display_snapshot.h"
13 #include "ui/display/types/native_display_delegate.h" 14 #include "ui/display/types/native_display_delegate.h"
14 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
15 #include "ui/ozone/public/ozone_platform.h" 16 #include "ui/ozone/public/ozone_platform.h"
16 17
17 namespace ui { 18 namespace ui {
18 19
19 namespace display { 20 namespace display {
20 namespace { 21 namespace {
21 22
22 // TODO(rjkroege): Remove this code once ozone headless has the same 23 // TODO(rjkroege): Remove this code once ozone headless has the same
23 // display creation semantics as ozone drm. 24 // display creation semantics as ozone drm.
24 // Some ozone platforms do not configure physical displays and so do not 25 // Some ozone platforms do not configure physical displays and so do not
25 // callback into this class via the implementation of NativeDisplayObserver. 26 // callback into this class via the implementation of NativeDisplayObserver.
26 // FixedSizeScreenConfiguration() short-circuits the implementation of display 27 // FixedSizeScreenConfiguration() short-circuits the implementation of display
27 // configuration in this case by calling the |callback| provided to 28 // configuration in this case by calling the |callback| provided to
28 // ConfigurePhysicalDisplay() with a hard-coded |id| and |bounds|. 29 // ConfigurePhysicalDisplay() with a hard-coded |id| and |bounds|.
29 void FixedSizeScreenConfiguration( 30 void FixedSizeScreenConfiguration(
30 const PlatformScreen::ConfiguredDisplayCallback& callback) { 31 const PlatformScreen::ConfiguredDisplayCallback& callback) {
31 callback.Run(1, gfx::Rect(1024, 768)); 32 if (base::CommandLine::ForCurrentProcess()->HasSwitch("multi-display")) {
33 // This really doesn't work properly. Use at your own risk.
34 callback.Run(100, gfx::Rect(800, 800));
35 callback.Run(200, gfx::Rect(800, 0, 800, 800));
36 } else {
37 callback.Run(100, gfx::Rect(0, 0, 1024, 768));
38 }
32 } 39 }
33 40
34 // Needed for DisplayConfigurator::ForceInitialConfigure. 41 // Needed for DisplayConfigurator::ForceInitialConfigure.
35 const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); 42 const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe);
36 43
37 } // namespace 44 } // namespace
38 45
39 // static 46 // static
40 std::unique_ptr<PlatformScreen> PlatformScreen::Create() { 47 std::unique_ptr<PlatformScreen> PlatformScreen::Create() {
41 return base::MakeUnique<PlatformScreenImplOzone>(); 48 return base::MakeUnique<PlatformScreenImplOzone>();
(...skipping 18 matching lines...) Expand all
60 display_configurator_.ForceInitialConfigure(kChromeOsBootColor); 67 display_configurator_.ForceInitialConfigure(kChromeOsBootColor);
61 } else { 68 } else {
62 // PostTask()ed to maximize control flow similarity with the ChromeOS case. 69 // PostTask()ed to maximize control flow similarity with the ChromeOS case.
63 base::ThreadTaskRunnerHandle::Get()->PostTask( 70 base::ThreadTaskRunnerHandle::Get()->PostTask(
64 FROM_HERE, base::Bind(&FixedSizeScreenConfiguration, callback)); 71 FROM_HERE, base::Bind(&FixedSizeScreenConfiguration, callback));
65 } 72 }
66 } 73 }
67 74
68 void PlatformScreenImplOzone::OnDisplayModeChanged( 75 void PlatformScreenImplOzone::OnDisplayModeChanged(
69 const ui::DisplayConfigurator::DisplayStateList& displays) { 76 const ui::DisplayConfigurator::DisplayStateList& displays) {
70 // TODO(kylechar): Remove checks when multiple display support is added. 77 // TODO(kylechar): Remove check when adding/removing displays is supported.
71 CHECK(displays.size() == 1) << "Mus only supports one 1 display";
72 CHECK(!callback_.is_null()); 78 CHECK(!callback_.is_null());
73 79
80 if (displays.size() > 1) {
81 LOG(ERROR)
82 << "Mus doesn't really support multiple displays, expect it to crash";
83 }
84
74 gfx::Point origin; 85 gfx::Point origin;
75 for (auto* display : displays) { 86 for (auto* display : displays) {
76 const ui::DisplayMode* current_mode = display->current_mode(); 87 const ui::DisplayMode* current_mode = display->current_mode();
77 gfx::Rect bounds(origin, current_mode->size()); 88 gfx::Rect bounds(origin, current_mode->size());
78 89
79 callback_.Run(display->display_id(), bounds); 90 callback_.Run(display->display_id(), bounds);
80 91
81 // Move the origin so that next display is to the right of current display. 92 // Move the origin so that next display is to the right of current display.
82 origin.Offset(current_mode->size().width(), 0); 93 origin.Offset(current_mode->size().width(), 0);
83 } 94 }
84 95
85 callback_.Reset(); 96 callback_.Reset();
86 } 97 }
87 98
88 void PlatformScreenImplOzone::OnDisplayModeChangeFailed( 99 void PlatformScreenImplOzone::OnDisplayModeChangeFailed(
89 const ui::DisplayConfigurator::DisplayStateList& displays, 100 const ui::DisplayConfigurator::DisplayStateList& displays,
90 MultipleDisplayState failed_new_state) { 101 MultipleDisplayState failed_new_state) {
91 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator"; 102 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator";
92 callback_.Reset(); 103 callback_.Reset();
93 } 104 }
94 105
95 } // namespace display 106 } // namespace display
96 } // namespace ui 107 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | services/ui/ws/display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698