Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <optional> |
Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 20 | |
Dominik Laskowski | 788945b | 2022-08-30 12:10:56 -0700 | [diff] [blame] | 21 | #include <ui/ColorMode.h> |
Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 22 | #include <ui/DisplayId.h> |
| 23 | #include <ui/StaticDisplayInfo.h> |
| 24 | |
Dominik Laskowski | e70461a | 2022-08-30 14:42:01 -0700 | [diff] [blame] | 25 | #include "DisplayHardware/DisplayMode.h" |
| 26 | #include "Utils/Dumper.h" |
Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 27 | |
| 28 | namespace android::display { |
| 29 | |
| 30 | // Immutable state of a physical display, captured on hotplug. |
| 31 | class DisplaySnapshot { |
| 32 | public: |
Dominik Laskowski | 788945b | 2022-08-30 12:10:56 -0700 | [diff] [blame] | 33 | DisplaySnapshot(PhysicalDisplayId, ui::DisplayConnectionType, DisplayModes&&, ui::ColorModes&&, |
Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 34 | std::optional<DeviceProductInfo>&&); |
| 35 | |
| 36 | DisplaySnapshot(const DisplaySnapshot&) = delete; |
| 37 | DisplaySnapshot(DisplaySnapshot&&) = default; |
| 38 | |
| 39 | PhysicalDisplayId displayId() const { return mDisplayId; } |
| 40 | ui::DisplayConnectionType connectionType() const { return mConnectionType; } |
| 41 | |
| 42 | std::optional<DisplayModeId> translateModeId(hal::HWConfigId) const; |
| 43 | |
| 44 | const auto& displayModes() const { return mDisplayModes; } |
Dominik Laskowski | 788945b | 2022-08-30 12:10:56 -0700 | [diff] [blame] | 45 | const auto& colorModes() const { return mColorModes; } |
Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 46 | const auto& deviceProductInfo() const { return mDeviceProductInfo; } |
| 47 | |
Dominik Laskowski | 788945b | 2022-08-30 12:10:56 -0700 | [diff] [blame] | 48 | ui::ColorModes filterColorModes(bool supportsWideColor) const; |
| 49 | |
Dominik Laskowski | e70461a | 2022-08-30 14:42:01 -0700 | [diff] [blame] | 50 | void dump(utils::Dumper&) const; |
Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 51 | |
| 52 | private: |
| 53 | const PhysicalDisplayId mDisplayId; |
| 54 | const ui::DisplayConnectionType mConnectionType; |
| 55 | |
| 56 | // Effectively const except in move constructor. |
| 57 | DisplayModes mDisplayModes; |
Dominik Laskowski | 788945b | 2022-08-30 12:10:56 -0700 | [diff] [blame] | 58 | ui::ColorModes mColorModes; |
Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 59 | std::optional<DeviceProductInfo> mDeviceProductInfo; |
| 60 | }; |
| 61 | |
| 62 | } // namespace android::display |