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

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

Issue 2549503002: Rename PlatformScreen to ScreenManager. (Closed)
Patch Set: Rebase. 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
« no previous file with comments | « services/ui/display/platform_screen_stub.h ('k') | services/ui/display/screen_manager.h » ('j') | 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/display/platform_screen_stub.h"
6
7 #include <memory>
8
9 #include "base/bind.h"
10 #include "base/location.h"
11 #include "base/memory/ptr_util.h"
12 #include "base/threading/thread_task_runner_handle.h"
13 #include "services/service_manager/public/cpp/interface_registry.h"
14 #include "ui/display/display.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/geometry/size.h"
17
18 namespace display {
19 namespace {
20
21 // Build a ViewportMetric for a 1024x768 display.
22 ViewportMetrics DefaultViewportMetrics() {
23 ViewportMetrics metrics;
24
25 metrics.device_scale_factor = 1.0f;
26 if (Display::HasForceDeviceScaleFactor())
27 metrics.device_scale_factor = Display::GetForcedDeviceScaleFactor();
28
29 metrics.pixel_size = gfx::Size(1024, 768);
30 gfx::Size scaled_size = gfx::ScaleToRoundedSize(
31 metrics.pixel_size, 1.0f / metrics.device_scale_factor);
32
33 metrics.bounds = gfx::Rect(scaled_size);
34 metrics.work_area = gfx::Rect(scaled_size);
35
36 return metrics;
37 }
38
39 } // namespace
40
41 // static
42 std::unique_ptr<PlatformScreen> PlatformScreen::Create() {
43 return base::MakeUnique<PlatformScreenStub>();
44 }
45
46 PlatformScreenStub::PlatformScreenStub()
47 : weak_ptr_factory_(this) {}
48
49 PlatformScreenStub::~PlatformScreenStub() {}
50
51 void PlatformScreenStub::FixedSizeScreenConfiguration() {
52 delegate_->OnDisplayAdded(display_id_, display_metrics_);
53 }
54
55 void PlatformScreenStub::AddInterfaces(
56 service_manager::InterfaceRegistry* registry) {}
57
58 void PlatformScreenStub::Init(PlatformScreenDelegate* delegate) {
59 DCHECK(delegate);
60 delegate_ = delegate;
61 display_metrics_ = DefaultViewportMetrics();
62 base::ThreadTaskRunnerHandle::Get()->PostTask(
63 FROM_HERE, base::Bind(&PlatformScreenStub::FixedSizeScreenConfiguration,
64 weak_ptr_factory_.GetWeakPtr()));
65 }
66
67 void PlatformScreenStub::RequestCloseDisplay(int64_t display_id) {
68 if (display_id == display_id_) {
69 base::ThreadTaskRunnerHandle::Get()->PostTask(
70 FROM_HERE, base::Bind(&PlatformScreenDelegate::OnDisplayRemoved,
71 base::Unretained(delegate_), display_id));
72 }
73 }
74
75 int64_t PlatformScreenStub::GetPrimaryDisplayId() const {
76 return display_id_;
77 }
78
79 } // namespace display
OLDNEW
« no previous file with comments | « services/ui/display/platform_screen_stub.h ('k') | services/ui/display/screen_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698