Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 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 | #include <VtsHalHidlTargetTestBase.h> |
| 20 | |
| 21 | namespace android { |
| 22 | namespace hardware { |
| 23 | namespace graphics { |
| 24 | namespace composer { |
| 25 | namespace V2_3 { |
| 26 | namespace vts { |
| 27 | |
| 28 | using V2_1::Error; |
| 29 | |
| 30 | Composer::Composer() : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>()) {} |
| 31 | |
| 32 | Composer::Composer(const std::string& name) |
| 33 | : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name)) {} |
| 34 | |
| 35 | Composer::Composer(const sp<IComposer>& composer) |
| 36 | : V2_2::vts::Composer(composer), mComposer(composer) {} |
| 37 | |
| 38 | std::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 Hau | ec98306 | 2018-10-09 16:09:12 -0700 | [diff] [blame^] | 48 | sp<IComposerClient> ComposerClient::getRaw() const { |
| 49 | return mClient; |
| 50 | } |
| 51 | |
Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 52 | bool 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 Hau | ec98306 | 2018-10-09 16:09:12 -0700 | [diff] [blame^] | 71 | std::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 | |
| 80 | void 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 | |
| 85 | std::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 | |
| 94 | void 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 | |
| 105 | bool 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 Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 111 | } // namespace vts |
| 112 | } // namespace V2_3 |
| 113 | } // namespace composer |
| 114 | } // namespace graphics |
| 115 | } // namespace hardware |
| 116 | } // namespace android |