Chromium Code Reviews| 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 "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 Loading... | |
| 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) | |
|
sky
2016/07/27 15:36:43
Add {}
kylechar
2016/07/27 17:25:55
Done.
| |
| 81 LOG(ERROR) | |
| 82 << "Mus doesn't really support multiple displays, expect it to crash"; | |
| 83 | |
| 74 gfx::Point origin; | 84 gfx::Point origin; |
| 75 for (auto display : displays) { | 85 for (auto display : displays) { |
| 76 const ui::DisplayMode* current_mode = display->current_mode(); | 86 const ui::DisplayMode* current_mode = display->current_mode(); |
| 77 gfx::Rect bounds(origin, current_mode->size()); | 87 gfx::Rect bounds(origin, current_mode->size()); |
| 78 | 88 |
| 79 callback_.Run(display->display_id(), bounds); | 89 callback_.Run(display->display_id(), bounds); |
| 80 | 90 |
| 81 // Move the origin so that next display is to the right of current display. | 91 // Move the origin so that next display is to the right of current display. |
| 82 origin.Offset(current_mode->size().width(), 0); | 92 origin.Offset(current_mode->size().width(), 0); |
| 83 } | 93 } |
| 84 | 94 |
| 85 callback_.Reset(); | 95 callback_.Reset(); |
| 86 } | 96 } |
| 87 | 97 |
| 88 void PlatformScreenImplOzone::OnDisplayModeChangeFailed( | 98 void PlatformScreenImplOzone::OnDisplayModeChangeFailed( |
| 89 const ui::DisplayConfigurator::DisplayStateList& displays, | 99 const ui::DisplayConfigurator::DisplayStateList& displays, |
| 90 MultipleDisplayState failed_new_state) { | 100 MultipleDisplayState failed_new_state) { |
| 91 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator"; | 101 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator"; |
| 92 callback_.Reset(); | 102 callback_.Reset(); |
| 93 } | 103 } |
| 94 | 104 |
| 95 } // namespace display | 105 } // namespace display |
| 96 } // namespace ui | 106 } // namespace ui |
| OLD | NEW |