xref: /aosp_15_r20/frameworks/native/services/surfaceflinger/Display/VirtualDisplaySnapshot.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1 /*
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 
26 namespace android::display {
27 
28 // Immutable state of a virtual display, captured on creation.
29 class VirtualDisplaySnapshot {
30 public:
VirtualDisplaySnapshot(GpuVirtualDisplayId gpuId,std::string uniqueId)31     VirtualDisplaySnapshot(GpuVirtualDisplayId gpuId, std::string uniqueId)
32           : mIsGpu(true), mUniqueId(std::move(uniqueId)), mVirtualId(gpuId) {}
VirtualDisplaySnapshot(HalVirtualDisplayId halId,std::string uniqueId)33     VirtualDisplaySnapshot(HalVirtualDisplayId halId, std::string uniqueId)
34           : mIsGpu(false), mUniqueId(std::move(uniqueId)), mVirtualId(halId) {}
35 
displayId()36     VirtualDisplayId displayId() const { return mVirtualId; }
isGpu()37     bool isGpu() const { return mIsGpu; }
38 
dump(utils::Dumper & dumper)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 
46 private:
47     const bool mIsGpu;
48     const std::string mUniqueId;
49     const VirtualDisplayId mVirtualId;
50 };
51 
52 } // namespace android::display
53