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

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

Issue 2128333002: Move PlatformSceen to services/ui/display. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « services/ui/ws/platform_screen_impl_ozone.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "services/ui/ws/platform_screen_impl_ozone.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "base/sys_info.h"
9 #include "base/threading/thread_task_runner_handle.h"
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/display/types/display_constants.h"
12 #include "ui/display/types/display_snapshot.h"
13 #include "ui/display/types/native_display_delegate.h"
14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/ozone/public/ozone_platform.h"
16
17 namespace ui {
18
19 namespace ws {
20 namespace {
21
22 // TODO(rjkroege): Remove this code once ozone headless has the same
23 // display creation semantics as ozone drm.
24 // Some ozone platforms do not configure physical displays and so do not
25 // callback into this class via the implementation of NativeDisplayObserver.
26 // FixedSizeScreenConfiguration() short-circuits the implementation of display
27 // configuration in this case by calling the |callback| provided to
28 // ConfigurePhysicalDisplay() with a hard-coded |id| and |bounds|.
29 void FixedSizeScreenConfiguration(
30 const PlatformScreen::ConfiguredDisplayCallback& callback) {
31 callback.Run(1, gfx::Rect(1024, 768));
32 }
33
34 // Needed for DisplayConfigurator::ForceInitialConfigure.
35 const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe);
36
37 } // namespace
38
39 // static
40 std::unique_ptr<PlatformScreen> PlatformScreen::Create() {
41 return base::MakeUnique<PlatformScreenImplOzone>();
42 }
43
44 PlatformScreenImplOzone::PlatformScreenImplOzone() {}
45
46 PlatformScreenImplOzone::~PlatformScreenImplOzone() {
47 display_configurator_.RemoveObserver(this);
48 }
49
50 void PlatformScreenImplOzone::Init() {
51 display_configurator_.AddObserver(this);
52 display_configurator_.Init(
53 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), false);
54 }
55
56 void PlatformScreenImplOzone::ConfigurePhysicalDisplay(
57 const PlatformScreen::ConfiguredDisplayCallback& callback) {
58 if (base::SysInfo::IsRunningOnChromeOS()) {
59 callback_ = callback;
60 display_configurator_.ForceInitialConfigure(kChromeOsBootColor);
61 } else {
62 // PostTask()ed to maximize control flow similarity with the ChromeOS case.
63 base::ThreadTaskRunnerHandle::Get()->PostTask(
64 FROM_HERE, base::Bind(&FixedSizeScreenConfiguration, callback));
65 }
66 }
67
68 void PlatformScreenImplOzone::OnDisplayModeChanged(
69 const ui::DisplayConfigurator::DisplayStateList& displays) {
70 // TODO(kylechar): Remove checks when multiple display support is added.
71 CHECK(displays.size() == 1) << "Mus only supports one 1 display";
72 CHECK(!callback_.is_null());
73
74 gfx::Point origin;
75 for (auto display : displays) {
76 const ui::DisplayMode* current_mode = display->current_mode();
77 gfx::Rect bounds(origin, current_mode->size());
78
79 callback_.Run(display->display_id(), bounds);
80
81 // Move the origin so that next display is to the right of current display.
82 origin.Offset(current_mode->size().width(), 0);
83 }
84
85 callback_.Reset();
86 }
87
88 void PlatformScreenImplOzone::OnDisplayModeChangeFailed(
89 const ui::DisplayConfigurator::DisplayStateList& displays,
90 MultipleDisplayState failed_new_state) {
91 LOG(ERROR) << "OnDisplayModeChangeFailed from DisplayConfigurator";
92 callback_.Reset();
93 }
94
95 } // namespace ws
96 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/platform_screen_impl_ozone.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698