blob: 23471f5d8e9c18064695805f2db7af7453ad2cd3 [file] [log] [blame]
Dominik Laskowskib363c4c2022-08-02 14:03:41 -07001/*
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 Laskowskib363c4c2022-08-02 14:03:41 -070020
Dominik Laskowski788945b2022-08-30 12:10:56 -070021#include <ui/ColorMode.h>
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070022#include <ui/DisplayId.h>
23#include <ui/StaticDisplayInfo.h>
24
Dominik Laskowskie70461a2022-08-30 14:42:01 -070025#include "DisplayHardware/DisplayMode.h"
26#include "Utils/Dumper.h"
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070027
28namespace android::display {
29
30// Immutable state of a physical display, captured on hotplug.
31class DisplaySnapshot {
32public:
Dominik Laskowski788945b2022-08-30 12:10:56 -070033 DisplaySnapshot(PhysicalDisplayId, ui::DisplayConnectionType, DisplayModes&&, ui::ColorModes&&,
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070034 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 Laskowski788945b2022-08-30 12:10:56 -070045 const auto& colorModes() const { return mColorModes; }
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070046 const auto& deviceProductInfo() const { return mDeviceProductInfo; }
47
Dominik Laskowski788945b2022-08-30 12:10:56 -070048 ui::ColorModes filterColorModes(bool supportsWideColor) const;
49
Dominik Laskowskie70461a2022-08-30 14:42:01 -070050 void dump(utils::Dumper&) const;
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070051
52private:
53 const PhysicalDisplayId mDisplayId;
54 const ui::DisplayConnectionType mConnectionType;
55
56 // Effectively const except in move constructor.
57 DisplayModes mDisplayModes;
Dominik Laskowski788945b2022-08-30 12:10:56 -070058 ui::ColorModes mColorModes;
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070059 std::optional<DeviceProductInfo> mDeviceProductInfo;
60};
61
62} // namespace android::display