• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 #include <composer-vts/2.3/ComposerVts.h>
18 
19 namespace android {
20 namespace hardware {
21 namespace graphics {
22 namespace composer {
23 namespace V2_3 {
24 namespace vts {
25 
26 using V2_1::Error;
27 
Composer(const sp<IComposer> & composer)28 Composer::Composer(const sp<IComposer>& composer)
29     : V2_2::vts::Composer(composer), mComposer(composer) {}
30 
createClient()31 std::unique_ptr<ComposerClient> Composer::createClient() {
32     std::unique_ptr<ComposerClient> client;
33     mComposer->createClient_2_3([&client](const auto& tmpError, const auto& tmpClient) {
34         ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
35         client = std::make_unique<ComposerClient>(tmpClient);
36     });
37 
38     return client;
39 }
40 
getRaw() const41 sp<IComposerClient> ComposerClient::getRaw() const {
42     return mClient;
43 }
44 
getDisplayIdentificationData(Display display,uint8_t * outPort,std::vector<uint8_t> * outData)45 bool ComposerClient::getDisplayIdentificationData(Display display, uint8_t* outPort,
46                                                   std::vector<uint8_t>* outData) {
47     bool supported = true;
48     mClient->getDisplayIdentificationData(
49         display, [&](const auto& tmpError, const auto& tmpPort, const auto& tmpData) {
50             if (tmpError == Error::UNSUPPORTED) {
51                 supported = false;
52                 return;
53             }
54             ASSERT_EQ(Error::NONE, tmpError) << "failed to get display identification data";
55 
56             *outPort = tmpPort;
57             *outData = tmpData;
58             ASSERT_FALSE(outData->empty()) << "data is empty";
59         });
60 
61     return supported;
62 }
63 
getColorModes_2_3(Display display)64 std::vector<ColorMode> ComposerClient::getColorModes_2_3(Display display) {
65     std::vector<ColorMode> modes;
66     mClient->getColorModes_2_3(display, [&](const auto& tmpError, const auto& tmpModes) {
67         ASSERT_EQ(Error::NONE, tmpError) << "failed to get color modes";
68         modes = tmpModes;
69     });
70     return modes;
71 }
72 
setColorMode_2_3(Display display,ColorMode mode,RenderIntent intent)73 void ComposerClient::setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent) {
74     Error error = mClient->setColorMode_2_3(display, mode, intent);
75     ASSERT_TRUE(error == Error::NONE || error == Error::UNSUPPORTED) << "failed to set color mode";
76 }
77 
getRenderIntents_2_3(Display display,ColorMode mode)78 std::vector<RenderIntent> ComposerClient::getRenderIntents_2_3(Display display, ColorMode mode) {
79     std::vector<RenderIntent> intents;
80     mClient->getRenderIntents_2_3(display, mode, [&](const auto& tmpError, const auto& tmpIntents) {
81         ASSERT_EQ(Error::NONE, tmpError) << "failed to get render intents";
82         intents = tmpIntents;
83     });
84     return intents;
85 }
86 
getReadbackBufferAttributes_2_3(Display display,PixelFormat * outPixelFormat,Dataspace * outDataspace)87 void ComposerClient::getReadbackBufferAttributes_2_3(Display display, PixelFormat* outPixelFormat,
88                                                      Dataspace* outDataspace) {
89     mClient->getReadbackBufferAttributes_2_3(
90         display,
91         [&](const auto& tmpError, const auto& tmpOutPixelFormat, const auto& tmpOutDataspace) {
92             ASSERT_EQ(Error::NONE, tmpError) << "failed to get readback buffer attributes";
93             *outPixelFormat = tmpOutPixelFormat;
94             *outDataspace = tmpOutDataspace;
95         });
96 }
97 
getClientTargetSupport_2_3(Display display,uint32_t width,uint32_t height,PixelFormat format,Dataspace dataspace)98 bool ComposerClient::getClientTargetSupport_2_3(Display display, uint32_t width, uint32_t height,
99                                                 PixelFormat format, Dataspace dataspace) {
100     Error error = mClient->getClientTargetSupport_2_3(display, width, height, format, dataspace);
101     return error == Error::NONE;
102 }
103 
getPerFrameMetadataKeys_2_3(Display display)104 std::vector<IComposerClient::PerFrameMetadataKey> ComposerClient::getPerFrameMetadataKeys_2_3(
105     Display display) {
106     std::vector<IComposerClient::PerFrameMetadataKey> keys;
107     mClient->getPerFrameMetadataKeys_2_3(display, [&](const auto& tmpError, const auto& tmpKeys) {
108         ASSERT_EQ(Error::NONE, tmpError) << "failed to get perFrameMetadataKeys";
109         keys = tmpKeys;
110     });
111     return keys;
112 }
113 
getHdrCapabilities_2_3(Display display,float * outMaxLuminance,float * outMaxAverageLuminance,float * outMinLuminance)114 std::vector<Hdr> ComposerClient::getHdrCapabilities_2_3(Display display, float* outMaxLuminance,
115                                                         float* outMaxAverageLuminance,
116                                                         float* outMinLuminance) {
117     std::vector<Hdr> types;
118     mClient->getHdrCapabilities_2_3(
119         display, [&](const auto& tmpError, const auto& tmpTypes, const auto& tmpMaxLuminance,
120                      const auto& tmpMaxAverageLuminance, const auto& tmpMinLuminance) {
121             ASSERT_EQ(Error::NONE, tmpError) << "failed to get HDR capabilities";
122             types = tmpTypes;
123             *outMaxLuminance = tmpMaxLuminance;
124             *outMaxAverageLuminance = tmpMaxAverageLuminance;
125             *outMinLuminance = tmpMinLuminance;
126         });
127 
128     return types;
129 }
130 
getDisplayedContentSamplingAttributes(uint64_t display,PixelFormat & format,Dataspace & dataspace,hidl_bitfield<IComposerClient::FormatColorComponent> & componentMask)131 Error ComposerClient::getDisplayedContentSamplingAttributes(
132     uint64_t display, PixelFormat& format, Dataspace& dataspace,
133     hidl_bitfield<IComposerClient::FormatColorComponent>& componentMask) {
134     auto error = Error::BAD_PARAMETER;
135     mClient->getDisplayedContentSamplingAttributes(
136         display, [&](const auto& tmpError, const auto& tmpFormat, const auto& tmpDataspace,
137                      const auto& tmpComponentMask) {
138             error = tmpError;
139             format = tmpFormat;
140             dataspace = tmpDataspace;
141             componentMask = tmpComponentMask;
142         });
143     return error;
144 }
145 
setDisplayedContentSamplingEnabled(uint64_t display,IComposerClient::DisplayedContentSampling enable,hidl_bitfield<IComposerClient::FormatColorComponent> componentMask,uint64_t maxFrames)146 Error ComposerClient::setDisplayedContentSamplingEnabled(
147     uint64_t display, IComposerClient::DisplayedContentSampling enable,
148     hidl_bitfield<IComposerClient::FormatColorComponent> componentMask, uint64_t maxFrames) {
149     return mClient->setDisplayedContentSamplingEnabled(display, enable, componentMask, maxFrames);
150 }
151 
getDisplayedContentSample(uint64_t display,uint64_t maxFrames,uint64_t timestamp,uint64_t & frameCount,hidl_vec<uint64_t> & sampleComponent0,hidl_vec<uint64_t> & sampleComponent1,hidl_vec<uint64_t> & sampleComponent2,hidl_vec<uint64_t> & sampleComponent3)152 Error ComposerClient::getDisplayedContentSample(uint64_t display, uint64_t maxFrames,
153                                                 uint64_t timestamp, uint64_t& frameCount,
154                                                 hidl_vec<uint64_t>& sampleComponent0,
155                                                 hidl_vec<uint64_t>& sampleComponent1,
156                                                 hidl_vec<uint64_t>& sampleComponent2,
157                                                 hidl_vec<uint64_t>& sampleComponent3) {
158     auto error = Error::BAD_PARAMETER;
159     mClient->getDisplayedContentSample(
160         display, maxFrames, timestamp,
161         [&](const auto& tmpError, const auto& tmpFrameCount, const auto& tmpSamples0,
162             const auto& tmpSamples1, const auto& tmpSamples2, const auto& tmpSamples3) {
163             error = tmpError;
164             frameCount = tmpFrameCount;
165             sampleComponent0 = tmpSamples0;
166             sampleComponent1 = tmpSamples1;
167             sampleComponent2 = tmpSamples2;
168             sampleComponent3 = tmpSamples3;
169         });
170     return error;
171 }
172 
getDisplayCapabilities(Display display,std::vector<IComposerClient::DisplayCapability> * outCapabilities)173 Error ComposerClient::getDisplayCapabilities(
174         Display display, std::vector<IComposerClient::DisplayCapability>* outCapabilities) {
175     std::vector<IComposerClient::DisplayCapability> capabilities;
176     Error error = Error::NONE;
177     mClient->getDisplayCapabilities(display,
178                                     [&](const auto& tmpError, const auto& tmpCapabilities) {
179                                         error = tmpError;
180                                         *outCapabilities = tmpCapabilities;
181                                     });
182 
183     return error;
184 }
185 
getDisplayBrightnessSupport(Display display)186 bool ComposerClient::getDisplayBrightnessSupport(Display display) {
187     bool support = false;
188     mClient->getDisplayBrightnessSupport(
189             display, [&](const auto& /*error*/, const auto& tmpSupport) { support = tmpSupport; });
190     return support;
191 }
192 
setDisplayBrightness(Display display,float brightness)193 Error ComposerClient::setDisplayBrightness(Display display, float brightness) {
194     return mClient->setDisplayBrightness(display, brightness);
195 }
196 
197 }  // namespace vts
198 }  // namespace V2_3
199 }  // namespace composer
200 }  // namespace graphics
201 }  // namespace hardware
202 }  // namespace android
203