blob: 3f34e39d92be9b6603013d23df8b84c8b297e4a8 [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
21#include <ui/DisplayId.h>
22#include <ui/StaticDisplayInfo.h>
23
Dominik Laskowskie70461a2022-08-30 14:42:01 -070024#include "DisplayHardware/DisplayMode.h"
25#include "Utils/Dumper.h"
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070026
27namespace android::display {
28
29// Immutable state of a physical display, captured on hotplug.
30class DisplaySnapshot {
31public:
32 DisplaySnapshot(PhysicalDisplayId, ui::DisplayConnectionType, DisplayModes&&,
33 std::optional<DeviceProductInfo>&&);
34
35 DisplaySnapshot(const DisplaySnapshot&) = delete;
36 DisplaySnapshot(DisplaySnapshot&&) = default;
37
38 PhysicalDisplayId displayId() const { return mDisplayId; }
39 ui::DisplayConnectionType connectionType() const { return mConnectionType; }
40
41 std::optional<DisplayModeId> translateModeId(hal::HWConfigId) const;
42
43 const auto& displayModes() const { return mDisplayModes; }
44 const auto& deviceProductInfo() const { return mDeviceProductInfo; }
45
Dominik Laskowskie70461a2022-08-30 14:42:01 -070046 void dump(utils::Dumper&) const;
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070047
48private:
49 const PhysicalDisplayId mDisplayId;
50 const ui::DisplayConnectionType mConnectionType;
51
52 // Effectively const except in move constructor.
53 DisplayModes mDisplayModes;
54 std::optional<DeviceProductInfo> mDeviceProductInfo;
55};
56
57} // namespace android::display