2 * Copyright (C) 2020 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_BACKEND_MANAGER_H
18 #define ANDROID_BACKEND_MANAGER_H
27 #define REGISTER_BACKEND(name_str_, backend_) \
29 backend = BackendManager::GetInstance() \
30 .RegisterBackend(name_str_, \
31 []() -> std::unique_ptr<Backend> { \
32 return std::make_unique<backend_>(); \
37 class BackendManager {
39 using backend_constructor_t = std::function<std::unique_ptr<Backend>()>;
40 static BackendManager &GetInstance();
41 int RegisterBackend(const std::string &name,
42 backend_constructor_t backend_constructor);
43 int SetBackendForDisplay(DrmHwcTwo::HwcDisplay *display);
44 std::unique_ptr<Backend> GetBackendByName(std::string &name);
45 HWC2::Error ValidateDisplay(DrmHwcTwo::HwcDisplay *display,
46 uint32_t *num_types, uint32_t *num_requests);
49 BackendManager() = default;
51 static const std::vector<std::string> kClientDevices;
53 std::map<std::string, backend_constructor_t> available_backends_;
55 } // namespace android