Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 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> { |
Kaiyi Li | 32fc2c7 | 2024-01-24 09:17:13 -0800 | [diff] [blame] | 34 | public: |
| 35 | virtual ~Device() = default; |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 36 | |
Kaiyi Li | 32fc2c7 | 2024-01-24 09:17:13 -0800 | [diff] [blame] | 37 | HWC3::Error getComposer(FrameComposer** outComposer); |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 38 | |
Kaiyi Li | 7d3a660 | 2024-01-23 16:24:23 -0800 | [diff] [blame] | 39 | bool persistentKeyValueEnabled() const; |
| 40 | |
Kaiyi Li | 32fc2c7 | 2024-01-24 09:17:13 -0800 | [diff] [blame] | 41 | HWC3::Error getPersistentKeyValue(const std::string& key, const std::string& defaultVal, |
| 42 | std::string* outValue); |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 43 | |
Kaiyi Li | 32fc2c7 | 2024-01-24 09:17:13 -0800 | [diff] [blame] | 44 | HWC3::Error setPersistentKeyValue(const std::string& key, const std::string& outValue); |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 45 | |
Kaiyi Li | 32fc2c7 | 2024-01-24 09:17:13 -0800 | [diff] [blame] | 46 | private: |
| 47 | friend class Singleton<Device>; |
| 48 | Device() = default; |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 49 | |
Kaiyi Li | 32fc2c7 | 2024-01-24 09:17:13 -0800 | [diff] [blame] | 50 | std::mutex mMutex; |
| 51 | std::unique_ptr<FrameComposer> mComposer; |
Jason Macnak | b53b790 | 2022-01-12 15:59:56 -0800 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | } // namespace aidl::android::hardware::graphics::composer3::impl |
| 55 | |
| 56 | #endif |