• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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; }
uniqueId()38     const std::string& uniqueId() const { return mUniqueId; }
39 
dump(utils::Dumper & dumper)40     void dump(utils::Dumper& dumper) const {
41         using namespace std::string_view_literals;
42 
43         dumper.dump("isGpu"sv, mIsGpu ? "true"sv : "false"sv);
44         dumper.dump("uniqueId"sv, mUniqueId);
45     }
46 
47 private:
48     const bool mIsGpu;
49     const std::string mUniqueId;
50     const VirtualDisplayId mVirtualId;
51 };
52 
53 } // namespace android::display
54