• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 #ifndef ANDROID_HWC_DEVICE_H
18 #define ANDROID_HWC_DEVICE_H
19 
20 #include <utils/Singleton.h>
21 
22 #include <memory>
23 #include <thread>
24 
25 #include "Common.h"
26 
27 namespace aidl::android::hardware::graphics::composer3::impl {
28 
29 class FrameComposer;
30 
31 // Provides resources that are stable for the duration of the virtual
32 // device.
33 class Device : public ::android::Singleton<Device> {
34  public:
35   virtual ~Device() = default;
36 
37   HWC3::Error getComposer(FrameComposer** outComposer);
38 
39   HWC3::Error getPersistentKeyValue(const std::string& key,
40                                     const std::string& defaultVal,
41                                     std::string* outValue);
42 
43   HWC3::Error setPersistentKeyValue(const std::string& key,
44                                     const std::string& outValue);
45 
46  private:
47   friend class Singleton<Device>;
48   Device() = default;
49 
50   std::mutex mMutex;
51   std::unique_ptr<FrameComposer> mComposer;
52 };
53 
54 }  // namespace aidl::android::hardware::graphics::composer3::impl
55 
56 #endif