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