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 <cstdint> 20 #include <optional> 21 22 #include <ui/ColorMode.h> 23 #include <ui/DisplayId.h> 24 #include <ui/StaticDisplayInfo.h> 25 26 #include "DisplayHardware/DisplayMode.h" 27 #include "Utils/Dumper.h" 28 29 namespace android::display { 30 31 // Immutable state of a physical display, captured on hotplug. 32 class DisplaySnapshot { 33 public: 34 DisplaySnapshot(PhysicalDisplayId, uint8_t, ui::DisplayConnectionType, DisplayModes&&, 35 ui::ColorModes&&, std::optional<DeviceProductInfo>&&); 36 37 DisplaySnapshot(const DisplaySnapshot&) = delete; 38 DisplaySnapshot(DisplaySnapshot&&) = default; 39 displayId()40 PhysicalDisplayId displayId() const { return mDisplayId; } port()41 uint8_t port() const { return mPort; } connectionType()42 ui::DisplayConnectionType connectionType() const { return mConnectionType; } 43 44 std::optional<DisplayModeId> translateModeId(hal::HWConfigId) const; 45 displayModes()46 const auto& displayModes() const { return mDisplayModes; } colorModes()47 const auto& colorModes() const { return mColorModes; } deviceProductInfo()48 const auto& deviceProductInfo() const { return mDeviceProductInfo; } 49 50 ui::ColorModes filterColorModes(bool supportsWideColor) const; 51 52 void dump(utils::Dumper&) const; 53 54 private: 55 const PhysicalDisplayId mDisplayId; 56 const uint8_t mPort; 57 const ui::DisplayConnectionType mConnectionType; 58 59 // Effectively const except in move constructor. 60 DisplayModes mDisplayModes; 61 ui::ColorModes mColorModes; 62 std::optional<DeviceProductInfo> mDeviceProductInfo; 63 }; 64 65 } // namespace android::display 66