• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 <aidl/android/hardware/graphics/composer3/BnComposer.h>
20 #include <utils/Mutex.h>
21 
22 #include "include/IComposerHal.h"
23 #include "ComposerClient.h"
24 
25 namespace aidl::android::hardware::graphics::composer3::impl {
26 
27 class Composer : public BnComposer {
28 public:
Composer(std::unique_ptr<IComposerHal> hal)29     Composer(std::unique_ptr<IComposerHal> hal) : mHal(std::move(hal)) {}
30 
31     binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
32 
33     // compser3 api
34     ndk::ScopedAStatus createClient(std::shared_ptr<IComposerClient>* client) override;
35     ndk::ScopedAStatus getCapabilities(std::vector<Capability>* caps) override;
36 
37 protected:
38     ::ndk::SpAIBinder createBinder() override;
39 
40 private:
41     bool waitForClientDestroyedLocked(std::unique_lock<std::mutex>& lock);
42     void onClientDestroyed();
43 
44     const std::unique_ptr<IComposerHal> mHal;
45     std::mutex mClientMutex;
46     bool mClientAlive = false; // GUARDED_BY(mClientMutex)
47     std::condition_variable mClientDestroyedCondition;
48 };
49 
50 }  // namespace aidl::android::hardware::graphics::composer3::impl
51