OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 "ui/display/manager/forwarding_display_delegate.h" | 5 #include "ui/display/manager/forwarding_display_delegate.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "ui/display/types/display_snapshot_mojo.h" | 10 #include "ui/display/types/display_snapshot_mojo.h" |
11 | 11 |
12 namespace display { | 12 namespace display { |
13 | 13 |
14 ForwardingDisplayDelegate::ForwardingDisplayDelegate( | 14 ForwardingDisplayDelegate::ForwardingDisplayDelegate( |
15 mojom::NativeDisplayDelegatePtr delegate) | 15 mojom::NativeDisplayDelegatePtr delegate) |
16 : delegate_(std::move(delegate)), binding_(this) {} | 16 : delegate_(std::move(delegate)), binding_(this) {} |
17 | 17 |
18 ForwardingDisplayDelegate::~ForwardingDisplayDelegate() {} | 18 ForwardingDisplayDelegate::~ForwardingDisplayDelegate() {} |
19 | 19 |
20 void ForwardingDisplayDelegate::Initialize() { | 20 void ForwardingDisplayDelegate::Initialize() { |
21 delegate_->Initialize(binding_.CreateInterfacePtrAndBind()); | 21 if (delegate_) |
| 22 delegate_->Initialize(binding_.CreateInterfacePtrAndBind()); |
22 } | 23 } |
23 | 24 |
24 void ForwardingDisplayDelegate::GrabServer() {} | 25 void ForwardingDisplayDelegate::GrabServer() {} |
25 | 26 |
26 void ForwardingDisplayDelegate::UngrabServer() {} | 27 void ForwardingDisplayDelegate::UngrabServer() {} |
27 | 28 |
28 void ForwardingDisplayDelegate::TakeDisplayControl( | 29 void ForwardingDisplayDelegate::TakeDisplayControl( |
29 const DisplayControlCallback& callback) { | 30 const DisplayControlCallback& callback) { |
30 delegate_->TakeDisplayControl(callback); | 31 if (delegate_) |
| 32 delegate_->TakeDisplayControl(callback); |
31 } | 33 } |
32 | 34 |
33 void ForwardingDisplayDelegate::RelinquishDisplayControl( | 35 void ForwardingDisplayDelegate::RelinquishDisplayControl( |
34 const DisplayControlCallback& callback) { | 36 const DisplayControlCallback& callback) { |
35 delegate_->TakeDisplayControl(callback); | 37 if (delegate_) |
| 38 delegate_->TakeDisplayControl(callback); |
36 } | 39 } |
37 | 40 |
38 void ForwardingDisplayDelegate::SyncWithServer() {} | 41 void ForwardingDisplayDelegate::SyncWithServer() {} |
39 | 42 |
40 void ForwardingDisplayDelegate::SetBackgroundColor(uint32_t color_argb) {} | 43 void ForwardingDisplayDelegate::SetBackgroundColor(uint32_t color_argb) {} |
41 | 44 |
42 void ForwardingDisplayDelegate::ForceDPMSOn() {} | 45 void ForwardingDisplayDelegate::ForceDPMSOn() {} |
43 | 46 |
44 void ForwardingDisplayDelegate::GetDisplays( | 47 void ForwardingDisplayDelegate::GetDisplays( |
45 const GetDisplaysCallback& callback) { | 48 const GetDisplaysCallback& callback) { |
46 delegate_->GetDisplays( | 49 if (delegate_) { |
47 base::Bind(&ForwardingDisplayDelegate::StoreAndForwardDisplays, | 50 delegate_->GetDisplays( |
48 base::Unretained(this), callback)); | 51 base::Bind(&ForwardingDisplayDelegate::StoreAndForwardDisplays, |
| 52 base::Unretained(this), callback)); |
| 53 } |
49 } | 54 } |
50 | 55 |
51 void ForwardingDisplayDelegate::AddMode(const DisplaySnapshot& snapshot, | 56 void ForwardingDisplayDelegate::AddMode(const DisplaySnapshot& snapshot, |
52 const DisplayMode* mode) {} | 57 const DisplayMode* mode) {} |
53 | 58 |
54 void ForwardingDisplayDelegate::Configure(const DisplaySnapshot& snapshot, | 59 void ForwardingDisplayDelegate::Configure(const DisplaySnapshot& snapshot, |
55 const DisplayMode* mode, | 60 const DisplayMode* mode, |
56 const gfx::Point& origin, | 61 const gfx::Point& origin, |
57 const ConfigureCallback& callback) { | 62 const ConfigureCallback& callback) { |
58 delegate_->Configure(snapshot.display_id(), mode->Clone(), origin, callback); | 63 if (delegate_) |
| 64 delegate_->Configure(snapshot.display_id(), mode->Clone(), origin, |
| 65 callback); |
59 } | 66 } |
60 | 67 |
61 void ForwardingDisplayDelegate::CreateFrameBuffer(const gfx::Size& size) {} | 68 void ForwardingDisplayDelegate::CreateFrameBuffer(const gfx::Size& size) {} |
62 | 69 |
63 void ForwardingDisplayDelegate::GetHDCPState( | 70 void ForwardingDisplayDelegate::GetHDCPState( |
64 const DisplaySnapshot& snapshot, | 71 const DisplaySnapshot& snapshot, |
65 const GetHDCPStateCallback& callback) { | 72 const GetHDCPStateCallback& callback) { |
66 delegate_->GetHDCPState(snapshot.display_id(), callback); | 73 if (delegate_) |
| 74 delegate_->GetHDCPState(snapshot.display_id(), callback); |
67 } | 75 } |
68 | 76 |
69 void ForwardingDisplayDelegate::SetHDCPState( | 77 void ForwardingDisplayDelegate::SetHDCPState( |
70 const DisplaySnapshot& snapshot, | 78 const DisplaySnapshot& snapshot, |
71 HDCPState state, | 79 HDCPState state, |
72 const SetHDCPStateCallback& callback) { | 80 const SetHDCPStateCallback& callback) { |
73 delegate_->SetHDCPState(snapshot.display_id(), state, callback); | 81 if (delegate_) |
| 82 delegate_->SetHDCPState(snapshot.display_id(), state, callback); |
74 } | 83 } |
75 | 84 |
76 std::vector<ColorCalibrationProfile> | 85 std::vector<ColorCalibrationProfile> |
77 ForwardingDisplayDelegate::GetAvailableColorCalibrationProfiles( | 86 ForwardingDisplayDelegate::GetAvailableColorCalibrationProfiles( |
78 const DisplaySnapshot& output) { | 87 const DisplaySnapshot& output) { |
79 return std::vector<ColorCalibrationProfile>(); | 88 return std::vector<ColorCalibrationProfile>(); |
80 } | 89 } |
81 | 90 |
82 bool ForwardingDisplayDelegate::SetColorCalibrationProfile( | 91 bool ForwardingDisplayDelegate::SetColorCalibrationProfile( |
83 const DisplaySnapshot& output, | 92 const DisplaySnapshot& output, |
84 ColorCalibrationProfile new_profile) { | 93 ColorCalibrationProfile new_profile) { |
85 return false; | 94 return false; |
86 } | 95 } |
87 | 96 |
88 bool ForwardingDisplayDelegate::SetColorCorrection( | 97 bool ForwardingDisplayDelegate::SetColorCorrection( |
89 const DisplaySnapshot& output, | 98 const DisplaySnapshot& output, |
90 const std::vector<GammaRampRGBEntry>& degamma_lut, | 99 const std::vector<GammaRampRGBEntry>& degamma_lut, |
91 const std::vector<GammaRampRGBEntry>& gamma_lut, | 100 const std::vector<GammaRampRGBEntry>& gamma_lut, |
92 const std::vector<float>& correction_matrix) { | 101 const std::vector<float>& correction_matrix) { |
93 delegate_->SetColorCorrection(output.display_id(), degamma_lut, gamma_lut, | 102 if (delegate_) { |
94 correction_matrix); | 103 delegate_->SetColorCorrection(output.display_id(), degamma_lut, gamma_lut, |
| 104 correction_matrix); |
| 105 } |
95 // DrmNativeDisplayDelegate always returns true so this will too. | 106 // DrmNativeDisplayDelegate always returns true so this will too. |
96 return true; | 107 return true; |
97 } | 108 } |
98 | 109 |
99 void ForwardingDisplayDelegate::AddObserver( | 110 void ForwardingDisplayDelegate::AddObserver( |
100 display::NativeDisplayObserver* observer) { | 111 display::NativeDisplayObserver* observer) { |
101 observers_.AddObserver(observer); | 112 observers_.AddObserver(observer); |
102 } | 113 } |
103 | 114 |
104 void ForwardingDisplayDelegate::RemoveObserver( | 115 void ForwardingDisplayDelegate::RemoveObserver( |
(...skipping 18 matching lines...) Expand all Loading... |
123 observer.OnDisplaySnapshotsInvalidated(); | 134 observer.OnDisplaySnapshotsInvalidated(); |
124 snapshots_ = std::move(snapshots); | 135 snapshots_ = std::move(snapshots); |
125 | 136 |
126 std::vector<DisplaySnapshot*> snapshot_ptrs; | 137 std::vector<DisplaySnapshot*> snapshot_ptrs; |
127 for (auto& snapshot : snapshots_) | 138 for (auto& snapshot : snapshots_) |
128 snapshot_ptrs.push_back(snapshot.get()); | 139 snapshot_ptrs.push_back(snapshot.get()); |
129 callback.Run(snapshot_ptrs); | 140 callback.Run(snapshot_ptrs); |
130 } | 141 } |
131 | 142 |
132 } // namespace display | 143 } // namespace display |
OLD | NEW |