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

Side by Side Diff: ui/display/manager/forwarding_display_delegate.cc

Issue 2805633004: Add Mojo NativeDisplayDelegate / NativeDisplayObserver. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2017 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 "ui/display/manager/forwarding_display_delegate.h"
6
7 #include <utility>
8
9 #include "base/bind.h"
10 #include "ui/display/types/display_snapshot_mojo.h"
11
12 namespace display {
13
14 ForwardingDisplayDelegate::ForwardingDisplayDelegate()
15 : binding_(this), weak_ptr_factory_(this) {}
16
17 ForwardingDisplayDelegate::~ForwardingDisplayDelegate() {}
18
19 void ForwardingDisplayDelegate::Connect(
20 mojom::NativeDisplayDelegatePtr delegate) {
21 delegate_ = std::move(delegate);
22 delegate_->RegisterObserver(binding_.CreateInterfacePtrAndBind());
23 }
24
25 void ForwardingDisplayDelegate::Initialize() {
26 delegate_->Initialize();
27 }
28
29 void ForwardingDisplayDelegate::GrabServer() {}
30
31 void ForwardingDisplayDelegate::UngrabServer() {}
32
33 void ForwardingDisplayDelegate::TakeDisplayControl(
34 const DisplayControlCallback& callback) {
35 delegate_->TakeDisplayControl(callback);
36 }
37
38 void ForwardingDisplayDelegate::RelinquishDisplayControl(
39 const DisplayControlCallback& callback) {
40 delegate_->TakeDisplayControl(callback);
41 }
42
43 void ForwardingDisplayDelegate::SyncWithServer() {}
44
45 void ForwardingDisplayDelegate::SetBackgroundColor(uint32_t color_argb) {}
46
47 void ForwardingDisplayDelegate::ForceDPMSOn() {}
48
49 void ForwardingDisplayDelegate::GetDisplays(
50 const GetDisplaysCallback& callback) {
51 delegate_->GetDisplays(
52 base::Bind(&ForwardingDisplayDelegate::StoreAndForwardDisplays,
53 weak_ptr_factory_.GetWeakPtr(), callback));
sky 2017/04/06 20:30:20 As delegate_ is owned by this class you shouldn't
kylechar 2017/04/07 13:52:16 Done.
54 }
55
56 void ForwardingDisplayDelegate::AddMode(const DisplaySnapshot& snapshot,
57 const DisplayMode* mode) {}
58
59 void ForwardingDisplayDelegate::Configure(const DisplaySnapshot& snapshot,
60 const DisplayMode* mode,
61 const gfx::Point& origin,
62 const ConfigureCallback& callback) {
63 delegate_->Configure(snapshot.display_id(), mode->Clone(), origin, callback);
64 }
65
66 void ForwardingDisplayDelegate::CreateFrameBuffer(const gfx::Size& size) {}
67
68 void ForwardingDisplayDelegate::GetHDCPState(
69 const DisplaySnapshot& snapshot,
70 const GetHDCPStateCallback& callback) {
71 delegate_->GetHDCPState(snapshot.display_id(), callback);
72 }
73
74 void ForwardingDisplayDelegate::SetHDCPState(
75 const DisplaySnapshot& snapshot,
76 HDCPState state,
77 const SetHDCPStateCallback& callback) {
78 delegate_->SetHDCPState(snapshot.display_id(), state, callback);
79 }
80
81 std::vector<ColorCalibrationProfile>
82 ForwardingDisplayDelegate::GetAvailableColorCalibrationProfiles(
83 const DisplaySnapshot& output) {
84 return std::vector<ColorCalibrationProfile>();
85 }
86
87 bool ForwardingDisplayDelegate::SetColorCalibrationProfile(
88 const DisplaySnapshot& output,
89 ColorCalibrationProfile new_profile) {
90 return false;
91 }
92
93 bool ForwardingDisplayDelegate::SetColorCorrection(
94 const DisplaySnapshot& output,
95 const std::vector<GammaRampRGBEntry>& degamma_lut,
96 const std::vector<GammaRampRGBEntry>& gamma_lut,
97 const std::vector<float>& correction_matrix) {
98 delegate_->SetColorCorrection(output.display_id(), degamma_lut, gamma_lut,
99 correction_matrix);
100 // DrmNativeDisplayDelegate always returns true so this will too.
101 return true;
102 }
103
104 void ForwardingDisplayDelegate::AddObserver(
105 display::NativeDisplayObserver* observer) {
106 observers_.AddObserver(observer);
107 }
108
109 void ForwardingDisplayDelegate::RemoveObserver(
110 display::NativeDisplayObserver* observer) {
111 observers_.RemoveObserver(observer);
112 }
113
114 FakeDisplayController* ForwardingDisplayDelegate::GetFakeDisplayController() {
115 return nullptr;
116 }
117
118 void ForwardingDisplayDelegate::OnConfigurationChanged() {
119 // Forward OnConfigurationChanged received over Mojo to local observers.
120 for (auto& observer : observers_)
121 observer.OnConfigurationChanged();
122 }
123
124 void ForwardingDisplayDelegate::StoreAndForwardDisplays(
125 const GetDisplaysCallback& callback,
126 std::vector<std::unique_ptr<DisplaySnapshotMojo>> snapshots) {
127 for (auto& observer : observers_)
128 observer.OnDisplaySnapshotsInvalidated();
129 snapshots_ = std::move(snapshots);
sky 2017/04/06 20:30:21 AFACIT you never use these. Is it worth caching th
kylechar 2017/04/07 13:52:16 Since this is the NDD implementation it needs to o
130
131 std::vector<DisplaySnapshot*> snapshot_ptrs;
132 for (auto& snapshot : snapshots_)
133 snapshot_ptrs.push_back(snapshot.get());
134 callback.Run(snapshot_ptrs);
135 }
136
137 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698