blob: fca3a3de089e86376d74e6ea1238d6897b4ea222 [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#include <functional>
18#include <utility>
19
20#include <ftl/algorithm.h>
21#include <ftl/enum.h>
22
23#include "DisplaySnapshot.h"
24
25namespace android::display {
26
27DisplaySnapshot::DisplaySnapshot(PhysicalDisplayId displayId,
28 ui::DisplayConnectionType connectionType,
29 DisplayModes&& displayModes,
30 std::optional<DeviceProductInfo>&& deviceProductInfo)
31 : mDisplayId(displayId),
32 mConnectionType(connectionType),
33 mDisplayModes(std::move(displayModes)),
34 mDeviceProductInfo(std::move(deviceProductInfo)) {}
35
36std::optional<DisplayModeId> DisplaySnapshot::translateModeId(hal::HWConfigId hwcId) const {
37 return ftl::find_if(mDisplayModes,
38 [hwcId](const DisplayModes::value_type& pair) {
39 return pair.second->getHwcId() == hwcId;
40 })
41 .transform(&ftl::to_key<DisplayModes>);
42}
43
Dominik Laskowskie70461a2022-08-30 14:42:01 -070044void DisplaySnapshot::dump(utils::Dumper& dumper) const {
45 using namespace std::string_view_literals;
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070046
Dominik Laskowskie70461a2022-08-30 14:42:01 -070047 dumper.dump("connectionType"sv, ftl::enum_string(mConnectionType));
48 dumper.dump("deviceProductInfo"sv, mDeviceProductInfo);
Dominik Laskowskib363c4c2022-08-02 14:03:41 -070049}
50
51} // namespace android::display