OLD | NEW |
(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 #ifndef UI_DISPLAY_CHROMEOS_VIRTUAL_DISPLAY_DELEGATE_H_ |
| 6 #define UI_DISPLAY_CHROMEOS_VIRTUAL_DISPLAY_DELEGATE_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/observer_list.h" |
| 13 #include "ui/display/chromeos/display_snapshot_virtual.h" |
| 14 #include "ui/display/display_export.h" |
| 15 #include "ui/display/types/native_display_delegate.h" |
| 16 #include "ui/display/types/virtual_display_controller.h" |
| 17 |
| 18 namespace display { |
| 19 |
| 20 // A NativeDisplayDelegate implementation that manages virtual displays. Each |
| 21 // virtual display mimics a physical display that doesn't exist. Intended to be |
| 22 // used when running off device and for unit testing of display configuration |
| 23 // and display management code. |
| 24 // |
| 25 // The size and number of displays can controlled via --display-bounds=X |
| 26 // command line flag with the format: |
| 27 // HxW[,] |
| 28 // H: display height in pixels |
| 29 // W: display width in pixels |
| 30 // |
| 31 // For example --display=bounds=1920x1080,400x400 creates two displays, the |
| 32 // first display 1920x1080 and the second 400x400. The specifier for each |
| 33 // display is comma separated. |
| 34 class DISPLAY_EXPORT VirtualDisplayDelegate : public ui::NativeDisplayDelegate, |
| 35 public VirtualDisplayController { |
| 36 public: |
| 37 VirtualDisplayDelegate(); |
| 38 ~VirtualDisplayDelegate() override; |
| 39 |
| 40 // VirtualDisplayController: |
| 41 int64_t AddVirtualDisplay(const gfx::Size& display_size) override; |
| 42 bool RemoveVirtualDisplay(int64_t display_id) override; |
| 43 |
| 44 // NativeDisplayDelegate overrides: |
| 45 void Initialize() override; |
| 46 void GrabServer() override; |
| 47 void UngrabServer() override; |
| 48 void TakeDisplayControl(const ui::DisplayControlCallback& callback) override; |
| 49 void RelinquishDisplayControl( |
| 50 const ui::DisplayControlCallback& callback) override; |
| 51 void SyncWithServer() override; |
| 52 void SetBackgroundColor(uint32_t color_argb) override; |
| 53 void ForceDPMSOn() override; |
| 54 void GetDisplays(const ui::GetDisplaysCallback& callback) override; |
| 55 void AddMode(const ui::DisplaySnapshot& output, |
| 56 const ui::DisplayMode* mode) override; |
| 57 void Configure(const ui::DisplaySnapshot& output, |
| 58 const ui::DisplayMode* mode, |
| 59 const gfx::Point& origin, |
| 60 const ui::ConfigureCallback& callback) override; |
| 61 void CreateFrameBuffer(const gfx::Size& size) override; |
| 62 void GetHDCPState(const ui::DisplaySnapshot& output, |
| 63 const ui::GetHDCPStateCallback& callback) override; |
| 64 void SetHDCPState(const ui::DisplaySnapshot& output, |
| 65 ui::HDCPState state, |
| 66 const ui::SetHDCPStateCallback& callback) override; |
| 67 std::vector<ui::ColorCalibrationProfile> GetAvailableColorCalibrationProfiles( |
| 68 const ui::DisplaySnapshot& output) override; |
| 69 bool SetColorCalibrationProfile( |
| 70 const ui::DisplaySnapshot& output, |
| 71 ui::ColorCalibrationProfile new_profile) override; |
| 72 bool SetColorCorrection(const ui::DisplaySnapshot& output, |
| 73 const std::vector<ui::GammaRampRGBEntry>& degamma_lut, |
| 74 const std::vector<ui::GammaRampRGBEntry>& gamma_lut, |
| 75 const std::vector<float>& correction_matrix) override; |
| 76 void AddObserver(ui::NativeDisplayObserver* observer) override; |
| 77 void RemoveObserver(ui::NativeDisplayObserver* observer) override; |
| 78 VirtualDisplayController* GetVirtualDisplayController() override; |
| 79 |
| 80 protected: |
| 81 // Initializes display snapshots from command line flags if provided. |
| 82 void InitFromCommandLine(); |
| 83 |
| 84 // Updates observers when display configuration has changed. Will not update |
| 85 // until after |Initialize()| has been called. |
| 86 void OnConfigurationChanged(); |
| 87 |
| 88 private: |
| 89 base::ObserverList<ui::NativeDisplayObserver> observers_; |
| 90 std::vector<std::unique_ptr<ui::DisplaySnapshotVirtual>> displays_; |
| 91 |
| 92 // Initialize() has been called. |
| 93 bool initialized_ = false; |
| 94 |
| 95 // The next available virtual display id. |
| 96 uint8_t next_virtual_display_id_ = 0; |
| 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(VirtualDisplayDelegate); |
| 99 }; |
| 100 |
| 101 } // namespace display |
| 102 #endif // UI_DISPLAY_CHROMEOS_VIRTUAL_DISPLAY_DELEGATE_H_ |
OLD | NEW |