1 /*
2  * Copyright 2017 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_DVR_HARDWARE_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H
18 #define ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H
19 
20 #include <android/frameworks/vr/composer/1.0/IVrComposerClient.h>
21 #include <composer-command-buffer/2.1/ComposerCommandBuffer.h>
22 #include <composer-hal/2.1/ComposerClient.h>
23 #include <composer-hal/2.1/ComposerCommandEngine.h>
24 
25 namespace android {
26 namespace dvr {
27 
28 class VrHwc;
29 
30 using hardware::graphics::composer::V2_1::hal::ComposerCommandEngine;
31 using hardware::graphics::composer::V2_1::hal::ComposerHal;
32 using hardware::graphics::composer::V2_1::hal::detail::ComposerClientImpl;
33 
34 using ComposerClient = ComposerClientImpl<IVrComposerClient, ComposerHal>;
35 
36 class VrComposerClient : public ComposerClient {
37  public:
38   VrComposerClient(android::dvr::VrHwc& hal);
39   virtual ~VrComposerClient();
40 
41  private:
42   class VrCommandEngine : public ComposerCommandEngine {
43    public:
44     VrCommandEngine(VrComposerClient& client);
45     ~VrCommandEngine() override;
46 
47     bool executeCommand(IComposerClient::Command command,
48                         uint16_t length) override;
49 
50    private:
51     bool executeSetLayerInfo(uint16_t length);
52     bool executeSetClientTargetMetadata(uint16_t length);
53     bool executeSetLayerBufferMetadata(uint16_t length);
54 
55     IVrComposerClient::BufferMetadata readBufferMetadata();
56 
57     VrComposerClient& mVrClient;
58     android::dvr::VrHwc& mVrHal;
59 
60     VrCommandEngine(const VrCommandEngine&) = delete;
61     void operator=(const VrCommandEngine&) = delete;
62   };
63 
64   VrComposerClient(const VrComposerClient&) = delete;
65   void operator=(const VrComposerClient&) = delete;
66 
67   std::unique_ptr<ComposerCommandEngine> createCommandEngine() override;
68   dvr::VrHwc& mVrHal;
69 };
70 
71 } // namespace dvr
72 } // namespace android
73 
74 #endif  // ANDROID_DVR_HARDWARE_COMPOSER_IMPL_VR_COMPOSER_CLIENT_H
75