blob: c68020ce510f566af52c586df60f0ddd257f5651 [file] [log] [blame]
Gil Dekel5d660422024-10-25 16:20:13 -04001/*
2 * Copyright 2024 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#include <string>
21
22#include <ui/DisplayId.h>
23
24#include "Utils/Dumper.h"
25
26namespace android::display {
27
28// Immutable state of a virtual display, captured on creation.
29class VirtualDisplaySnapshot {
30public:
31 VirtualDisplaySnapshot(GpuVirtualDisplayId gpuId, std::string uniqueId)
32 : mIsGpu(true), mUniqueId(std::move(uniqueId)), mVirtualId(gpuId) {}
33 VirtualDisplaySnapshot(HalVirtualDisplayId halId, std::string uniqueId)
34 : mIsGpu(false), mUniqueId(std::move(uniqueId)), mVirtualId(halId) {}
35
36 VirtualDisplayId displayId() const { return mVirtualId; }
37 bool isGpu() const { return mIsGpu; }
38
39 void dump(utils::Dumper& dumper) const {
40 using namespace std::string_view_literals;
41
42 dumper.dump("isGpu"sv, mIsGpu ? "true"sv : "false"sv);
43 dumper.dump("uniqueId"sv, mUniqueId);
44 }
45
46private:
47 const bool mIsGpu;
48 const std::string mUniqueId;
49 const VirtualDisplayId mVirtualId;
50};
51
52} // namespace android::display