1 /*
2  * Copyright 2019 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 <memory>
20 #include <vector>
21 
22 #include <android/hardware/graphics/composer/2.4/IComposer.h>
23 #include <android/hardware/graphics/composer/2.4/IComposerClient.h>
24 #include <composer-vts/2.3/ComposerVts.h>
25 #include <composer-vts/2.4/TestCommandReader.h>
26 #include <utils/StrongPointer.h>
27 
28 namespace android {
29 namespace hardware {
30 namespace graphics {
31 namespace composer {
32 namespace V2_4 {
33 namespace vts {
34 
35 using common::V1_1::RenderIntent;
36 using common::V1_2::ColorMode;
37 using common::V1_2::Dataspace;
38 using common::V1_2::Hdr;
39 using common::V1_2::PixelFormat;
40 using V2_1::Config;
41 using V2_1::Display;
42 using V2_4::Error;
43 using V2_4::IComposer;
44 using V2_4::IComposerClient;
45 using V2_4::VsyncPeriodNanos;
46 
47 class ComposerClient;
48 
49 // A wrapper to IComposer.
50 class Composer : public V2_3::vts::Composer {
51   public:
52     Composer();
53     explicit Composer(const std::string& name);
54     explicit Composer(const sp<IComposer>& composer);
55 
56     std::unique_ptr<ComposerClient> createClient();
57 
58   private:
59     const sp<IComposer> mComposer;
60 };
61 
62 // A wrapper to IComposerClient.
63 class ComposerClient : public V2_3::vts::ComposerClient {
64   public:
ComposerClient(const sp<IComposerClient> & client)65     explicit ComposerClient(const sp<IComposerClient>& client)
66         : V2_3::vts::ComposerClient(client), mClient(client) {}
67 
68     sp<IComposerClient> getRaw() const;
69 
70     Error getDisplayCapabilities(
71             Display display,
72             std::vector<IComposerClient::DisplayCapability>* outDisplayCapabilities);
73 
74     Error getDisplayConnectionType(Display display,
75                                    IComposerClient::DisplayConnectionType* outType);
76 
77     int32_t getDisplayAttribute_2_4(Display display, Config config,
78                                     IComposerClient::Attribute attribute);
79 
80     void registerCallback_2_4(const sp<IComposerCallback>& callback);
81 
82     Error getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriods);
83 
84     Error setActiveConfigWithConstraints(
85             Display display, Config config,
86             const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
87             VsyncPeriodChangeTimeline* timeline);
88 
89     Error setAutoLowLatencyMode(Display display, bool on);
90 
91     Error getSupportedContentTypes(
92             Display display, std::vector<IComposerClient::ContentType>* outSupportedContentTypes);
93 
94     Error setContentType(Display display, IComposerClient::ContentType contentType);
95 
96     void execute(TestCommandReader* reader, CommandWriterBase* writer);
97 
98     Error getLayerGenericMetadataKeys(
99             std::vector<IComposerClient::LayerGenericMetadataKey>* outKeys);
100 
101   private:
102     const sp<IComposerClient> mClient;
103 };
104 
105 }  // namespace vts
106 }  // namespace V2_4
107 }  // namespace composer
108 }  // namespace graphics
109 }  // namespace hardware
110 }  // namespace android
111