blob: 656c8c44949ed72928147e16433b61f7d377320d [file] [log] [blame]
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -07001/*
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#include <VtsHalHidlTargetTestBase.h>
20
21namespace android {
22namespace hardware {
23namespace graphics {
24namespace composer {
25namespace V2_3 {
26namespace vts {
27
28using V2_1::Error;
29
30Composer::Composer() : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>()) {}
31
32Composer::Composer(const std::string& name)
33 : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name)) {}
34
35Composer::Composer(const sp<IComposer>& composer)
36 : V2_2::vts::Composer(composer), mComposer(composer) {}
37
38std::unique_ptr<ComposerClient> Composer::createClient() {
39 std::unique_ptr<ComposerClient> client;
40 mComposer->createClient_2_3([&client](const auto& tmpError, const auto& tmpClient) {
41 ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
42 client = std::make_unique<ComposerClient>(tmpClient);
43 });
44
45 return client;
46}
47
Valerie Hauec983062018-10-09 16:09:12 -070048sp<IComposerClient> ComposerClient::getRaw() const {
49 return mClient;
50}
51
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -070052bool ComposerClient::getDisplayIdentificationData(Display display, uint8_t* outPort,
53 std::vector<uint8_t>* outData) {
54 bool supported = true;
55 mClient->getDisplayIdentificationData(
56 display, [&](const auto& tmpError, const auto& tmpPort, const auto& tmpData) {
57 if (tmpError == Error::UNSUPPORTED) {
58 supported = false;
59 return;
60 }
61 ASSERT_EQ(Error::NONE, tmpError) << "failed to get display identification data";
62
63 *outPort = tmpPort;
64 *outData = tmpData;
65 ASSERT_FALSE(outData->empty()) << "data is empty";
66 });
67
68 return supported;
69}
70
Valerie Hauec983062018-10-09 16:09:12 -070071std::vector<ColorMode> ComposerClient::getColorModes_2_3(Display display) {
72 std::vector<ColorMode> modes;
73 mClient->getColorModes_2_3(display, [&](const auto& tmpError, const auto& tmpModes) {
74 ASSERT_EQ(Error::NONE, tmpError) << "failed to get color modes";
75 modes = tmpModes;
76 });
77 return modes;
78}
79
80void ComposerClient::setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent) {
81 Error error = mClient->setColorMode_2_3(display, mode, intent);
82 ASSERT_TRUE(error == Error::NONE || error == Error::UNSUPPORTED) << "failed to set color mode";
83}
84
85std::vector<RenderIntent> ComposerClient::getRenderIntents_2_3(Display display, ColorMode mode) {
86 std::vector<RenderIntent> intents;
87 mClient->getRenderIntents_2_3(display, mode, [&](const auto& tmpError, const auto& tmpIntents) {
88 ASSERT_EQ(Error::NONE, tmpError) << "failed to get render intents";
89 intents = tmpIntents;
90 });
91 return intents;
92}
93
94void ComposerClient::getReadbackBufferAttributes_2_3(Display display, PixelFormat* outPixelFormat,
95 Dataspace* outDataspace) {
96 mClient->getReadbackBufferAttributes_2_3(
97 display,
98 [&](const auto& tmpError, const auto& tmpOutPixelFormat, const auto& tmpOutDataspace) {
99 ASSERT_EQ(Error::NONE, tmpError) << "failed to get readback buffer attributes";
100 *outPixelFormat = tmpOutPixelFormat;
101 *outDataspace = tmpOutDataspace;
102 });
103}
104
105bool ComposerClient::getClientTargetSupport_2_3(Display display, uint32_t width, uint32_t height,
106 PixelFormat format, Dataspace dataspace) {
107 Error error = mClient->getClientTargetSupport_2_3(display, width, height, format, dataspace);
108 return error == Error::NONE;
109}
110
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -0700111} // namespace vts
112} // namespace V2_3
113} // namespace composer
114} // namespace graphics
115} // namespace hardware
116} // namespace android