| OLD | NEW |
| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 std::unique_ptr<PlatformScreen> PlatformScreen::Create() { | 29 std::unique_ptr<PlatformScreen> PlatformScreen::Create() { |
| 30 return base::MakeUnique<PlatformScreenImplOzone>(); | 30 return base::MakeUnique<PlatformScreenImplOzone>(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 PlatformScreenImplOzone::PlatformScreenImplOzone() {} | 33 PlatformScreenImplOzone::PlatformScreenImplOzone() {} |
| 34 | 34 |
| 35 PlatformScreenImplOzone::~PlatformScreenImplOzone() { | 35 PlatformScreenImplOzone::~PlatformScreenImplOzone() { |
| 36 display_configurator_.RemoveObserver(this); | 36 display_configurator_.RemoveObserver(this); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void PlatformScreenImplOzone::Init() { | 39 void PlatformScreenImplOzone::Init(PlatformScreenDelegate* delegate) { |
| 40 DCHECK(delegate); |
| 41 delegate_ = delegate; |
| 42 |
| 40 // We want display configuration to happen even off device to keep the control | 43 // We want display configuration to happen even off device to keep the control |
| 41 // flow similar. | 44 // flow similar. |
| 42 display_configurator_.set_configure_display(true); | 45 display_configurator_.set_configure_display(true); |
| 43 display_configurator_.AddObserver(this); | 46 display_configurator_.AddObserver(this); |
| 44 display_configurator_.Init( | 47 display_configurator_.Init( |
| 45 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), false); | 48 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), false); |
| 46 } | |
| 47 | |
| 48 void PlatformScreenImplOzone::ConfigurePhysicalDisplay( | |
| 49 const PlatformScreen::ConfiguredDisplayCallback& callback) { | |
| 50 callback_ = callback; | |
| 51 | 49 |
| 52 if (base::SysInfo::IsRunningOnChromeOS()) { | 50 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 53 display_configurator_.ForceInitialConfigure(kChromeOsBootColor); | 51 display_configurator_.ForceInitialConfigure(kChromeOsBootColor); |
| 54 } else { | 52 } else { |
| 55 if (base::CommandLine::ForCurrentProcess()->HasSwitch("multi-display")) { | 53 if (base::CommandLine::ForCurrentProcess()->HasSwitch("multi-display")) { |
| 56 // This really doesn't work properly. Use at your own risk. | 54 // This really doesn't work properly. Use at your own risk. |
| 57 display_configurator_.AddVirtualDisplay(gfx::Size(800, 800)); | 55 display_configurator_.AddVirtualDisplay(gfx::Size(800, 800)); |
| 58 display_configurator_.AddVirtualDisplay(gfx::Size(800, 800)); | 56 display_configurator_.AddVirtualDisplay(gfx::Size(800, 800)); |
| 59 } else { | 57 } else { |
| 60 display_configurator_.AddVirtualDisplay(gfx::Size(1024, 768)); | 58 display_configurator_.AddVirtualDisplay(gfx::Size(1024, 768)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 89 // Move the origin so that next display is to the right of current display. | 87 // Move the origin so that next display is to the right of current display. |
| 90 next_display_origin_.Offset(current_mode->size().width(), 0); | 88 next_display_origin_.Offset(current_mode->size().width(), 0); |
| 91 | 89 |
| 92 // The first display added will be our primary display. | 90 // The first display added will be our primary display. |
| 93 if (displays_.empty()) | 91 if (displays_.empty()) |
| 94 primary_display_id_ = id; | 92 primary_display_id_ = id; |
| 95 | 93 |
| 96 // Keep track of what displays have already been added. | 94 // Keep track of what displays have already been added. |
| 97 displays_.insert(display->display_id()); | 95 displays_.insert(display->display_id()); |
| 98 | 96 |
| 99 callback_.Run(id, bounds); | 97 delegate_->OnDisplayAdded(this, id, bounds); |
| 100 } | 98 } |
| 101 | 99 |
| 102 DCHECK(displays_ == all_displays) << "Removing displays is not supported."; | 100 DCHECK(displays_ == all_displays) << "Removing displays is not supported."; |
| 103 } | 101 } |
| 104 | 102 |
| 105 void PlatformScreenImplOzone::OnDisplayModeChangeFailed( | 103 void PlatformScreenImplOzone::OnDisplayModeChangeFailed( |
| 106 const ui::DisplayConfigurator::DisplayStateList& displays, | 104 const ui::DisplayConfigurator::DisplayStateList& displays, |
| 107 ui::MultipleDisplayState failed_new_state) { | 105 ui::MultipleDisplayState failed_new_state) { |
| 108 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator"; | 106 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator"; |
| 109 } | 107 } |
| 110 | 108 |
| 111 } // namespace display | 109 } // namespace display |
| OLD | NEW |