Index: ui/display/manager/forwarding_display_delegate.cc |
diff --git a/ui/display/manager/forwarding_display_delegate.cc b/ui/display/manager/forwarding_display_delegate.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e93f07d6d63e1fece45e5e378451498565c15d44 |
--- /dev/null |
+++ b/ui/display/manager/forwarding_display_delegate.cc |
@@ -0,0 +1,137 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/display/manager/forwarding_display_delegate.h" |
+ |
+#include <utility> |
+ |
+#include "base/bind.h" |
+#include "ui/display/types/display_snapshot_mojo.h" |
+ |
+namespace display { |
+ |
+ForwardingDisplayDelegate::ForwardingDisplayDelegate() |
+ : binding_(this), weak_ptr_factory_(this) {} |
+ |
+ForwardingDisplayDelegate::~ForwardingDisplayDelegate() {} |
+ |
+void ForwardingDisplayDelegate::Connect( |
+ mojom::NativeDisplayDelegatePtr delegate) { |
+ delegate_ = std::move(delegate); |
+ delegate_->RegisterObserver(binding_.CreateInterfacePtrAndBind()); |
+} |
+ |
+void ForwardingDisplayDelegate::Initialize() { |
+ delegate_->Initialize(); |
+} |
+ |
+void ForwardingDisplayDelegate::GrabServer() {} |
+ |
+void ForwardingDisplayDelegate::UngrabServer() {} |
+ |
+void ForwardingDisplayDelegate::TakeDisplayControl( |
+ const DisplayControlCallback& callback) { |
+ delegate_->TakeDisplayControl(callback); |
+} |
+ |
+void ForwardingDisplayDelegate::RelinquishDisplayControl( |
+ const DisplayControlCallback& callback) { |
+ delegate_->TakeDisplayControl(callback); |
+} |
+ |
+void ForwardingDisplayDelegate::SyncWithServer() {} |
+ |
+void ForwardingDisplayDelegate::SetBackgroundColor(uint32_t color_argb) {} |
+ |
+void ForwardingDisplayDelegate::ForceDPMSOn() {} |
+ |
+void ForwardingDisplayDelegate::GetDisplays( |
+ const GetDisplaysCallback& callback) { |
+ delegate_->GetDisplays( |
+ base::Bind(&ForwardingDisplayDelegate::StoreAndForwardDisplays, |
+ 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.
|
+} |
+ |
+void ForwardingDisplayDelegate::AddMode(const DisplaySnapshot& snapshot, |
+ const DisplayMode* mode) {} |
+ |
+void ForwardingDisplayDelegate::Configure(const DisplaySnapshot& snapshot, |
+ const DisplayMode* mode, |
+ const gfx::Point& origin, |
+ const ConfigureCallback& callback) { |
+ delegate_->Configure(snapshot.display_id(), mode->Clone(), origin, callback); |
+} |
+ |
+void ForwardingDisplayDelegate::CreateFrameBuffer(const gfx::Size& size) {} |
+ |
+void ForwardingDisplayDelegate::GetHDCPState( |
+ const DisplaySnapshot& snapshot, |
+ const GetHDCPStateCallback& callback) { |
+ delegate_->GetHDCPState(snapshot.display_id(), callback); |
+} |
+ |
+void ForwardingDisplayDelegate::SetHDCPState( |
+ const DisplaySnapshot& snapshot, |
+ HDCPState state, |
+ const SetHDCPStateCallback& callback) { |
+ delegate_->SetHDCPState(snapshot.display_id(), state, callback); |
+} |
+ |
+std::vector<ColorCalibrationProfile> |
+ForwardingDisplayDelegate::GetAvailableColorCalibrationProfiles( |
+ const DisplaySnapshot& output) { |
+ return std::vector<ColorCalibrationProfile>(); |
+} |
+ |
+bool ForwardingDisplayDelegate::SetColorCalibrationProfile( |
+ const DisplaySnapshot& output, |
+ ColorCalibrationProfile new_profile) { |
+ return false; |
+} |
+ |
+bool ForwardingDisplayDelegate::SetColorCorrection( |
+ const DisplaySnapshot& output, |
+ const std::vector<GammaRampRGBEntry>& degamma_lut, |
+ const std::vector<GammaRampRGBEntry>& gamma_lut, |
+ const std::vector<float>& correction_matrix) { |
+ delegate_->SetColorCorrection(output.display_id(), degamma_lut, gamma_lut, |
+ correction_matrix); |
+ // DrmNativeDisplayDelegate always returns true so this will too. |
+ return true; |
+} |
+ |
+void ForwardingDisplayDelegate::AddObserver( |
+ display::NativeDisplayObserver* observer) { |
+ observers_.AddObserver(observer); |
+} |
+ |
+void ForwardingDisplayDelegate::RemoveObserver( |
+ display::NativeDisplayObserver* observer) { |
+ observers_.RemoveObserver(observer); |
+} |
+ |
+FakeDisplayController* ForwardingDisplayDelegate::GetFakeDisplayController() { |
+ return nullptr; |
+} |
+ |
+void ForwardingDisplayDelegate::OnConfigurationChanged() { |
+ // Forward OnConfigurationChanged received over Mojo to local observers. |
+ for (auto& observer : observers_) |
+ observer.OnConfigurationChanged(); |
+} |
+ |
+void ForwardingDisplayDelegate::StoreAndForwardDisplays( |
+ const GetDisplaysCallback& callback, |
+ std::vector<std::unique_ptr<DisplaySnapshotMojo>> snapshots) { |
+ for (auto& observer : observers_) |
+ observer.OnDisplaySnapshotsInvalidated(); |
+ 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
|
+ |
+ std::vector<DisplaySnapshot*> snapshot_ptrs; |
+ for (auto& snapshot : snapshots_) |
+ snapshot_ptrs.push_back(snapshot.get()); |
+ callback.Run(snapshot_ptrs); |
+} |
+ |
+} // namespace display |