Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 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 | |
Chia-I Wu | 96a098a | 2018-01-25 10:38:06 -0800 | [diff] [blame] | 17 | #include <composer-vts/2.1/ComposerVts.h> |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 18 | |
Chia-I Wu | 96a098a | 2018-01-25 10:38:06 -0800 | [diff] [blame] | 19 | #include <VtsHalHidlTargetTestBase.h> |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 20 | |
| 21 | namespace android { |
| 22 | namespace hardware { |
| 23 | namespace graphics { |
| 24 | namespace composer { |
| 25 | namespace V2_1 { |
Chia-I Wu | 96a098a | 2018-01-25 10:38:06 -0800 | [diff] [blame] | 26 | namespace vts { |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 27 | |
Dominik Laskowski | 0c41558 | 2018-04-02 15:35:00 -0700 | [diff] [blame^] | 28 | Composer::Composer() : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>()) {} |
Daniel Nicoara | d47f4a9 | 2017-05-30 15:38:30 -0400 | [diff] [blame] | 29 | |
Dominik Laskowski | 0c41558 | 2018-04-02 15:35:00 -0700 | [diff] [blame^] | 30 | Composer::Composer(const std::string& name) |
| 31 | : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name)) {} |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 32 | |
Dominik Laskowski | 0c41558 | 2018-04-02 15:35:00 -0700 | [diff] [blame^] | 33 | Composer::Composer(const sp<IComposer>& composer) : mComposer(composer) { |
| 34 | // ASSERT_* can only be used in functions returning void. |
| 35 | [this] { |
| 36 | ASSERT_NE(nullptr, mComposer.get()) << "failed to get composer service"; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 37 | |
Dominik Laskowski | 0c41558 | 2018-04-02 15:35:00 -0700 | [diff] [blame^] | 38 | std::vector<IComposer::Capability> capabilities = getCapabilities(); |
| 39 | mCapabilities.insert(capabilities.begin(), capabilities.end()); |
| 40 | }(); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 41 | } |
| 42 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 43 | sp<IComposer> Composer::getRaw() const { |
| 44 | return mComposer; |
| 45 | } |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 46 | |
| 47 | bool Composer::hasCapability(IComposer::Capability capability) const { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 48 | return mCapabilities.count(capability) > 0; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | std::vector<IComposer::Capability> Composer::getCapabilities() { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 52 | std::vector<IComposer::Capability> capabilities; |
| 53 | mComposer->getCapabilities( |
| 54 | [&](const auto& tmpCapabilities) { capabilities = tmpCapabilities; }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 55 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 56 | return capabilities; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | std::string Composer::dumpDebugInfo() { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 60 | std::string debugInfo; |
| 61 | mComposer->dumpDebugInfo([&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 62 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 63 | return debugInfo; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | std::unique_ptr<ComposerClient> Composer::createClient() { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 67 | std::unique_ptr<ComposerClient> client; |
| 68 | mComposer->createClient([&](const auto& tmpError, const auto& tmpClient) { |
| 69 | ASSERT_EQ(Error::NONE, tmpError) << "failed to create client"; |
| 70 | client = std::make_unique<ComposerClient>(tmpClient); |
| 71 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 72 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 73 | return client; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 74 | } |
| 75 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 76 | ComposerClient::ComposerClient(const sp<IComposerClient>& client) : mClient(client) {} |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 77 | |
| 78 | ComposerClient::~ComposerClient() { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 79 | for (auto it : mDisplayResources) { |
| 80 | Display display = it.first; |
| 81 | DisplayResource& resource = it.second; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 82 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 83 | for (auto layer : resource.layers) { |
| 84 | EXPECT_EQ(Error::NONE, mClient->destroyLayer(display, layer)) |
| 85 | << "failed to destroy layer " << layer; |
| 86 | } |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 87 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 88 | if (resource.isVirtual) { |
| 89 | EXPECT_EQ(Error::NONE, mClient->destroyVirtualDisplay(display)) |
| 90 | << "failed to destroy virtual display " << display; |
| 91 | } |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 92 | } |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 93 | mDisplayResources.clear(); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 94 | } |
| 95 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 96 | sp<IComposerClient> ComposerClient::getRaw() const { |
| 97 | return mClient; |
| 98 | } |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 99 | |
| 100 | void ComposerClient::registerCallback(const sp<IComposerCallback>& callback) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 101 | mClient->registerCallback(callback); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | uint32_t ComposerClient::getMaxVirtualDisplayCount() { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 105 | return mClient->getMaxVirtualDisplayCount(); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | Display ComposerClient::createVirtualDisplay(uint32_t width, uint32_t height, |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 109 | PixelFormat formatHint, uint32_t outputBufferSlotCount, |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 110 | PixelFormat* outFormat) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 111 | Display display = 0; |
| 112 | mClient->createVirtualDisplay( |
| 113 | width, height, formatHint, outputBufferSlotCount, |
| 114 | [&](const auto& tmpError, const auto& tmpDisplay, const auto& tmpFormat) { |
| 115 | ASSERT_EQ(Error::NONE, tmpError) << "failed to create virtual display"; |
| 116 | display = tmpDisplay; |
| 117 | *outFormat = tmpFormat; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 118 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 119 | ASSERT_TRUE(mDisplayResources.insert({display, DisplayResource(true)}).second) |
| 120 | << "duplicated virtual display id " << display; |
| 121 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 122 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 123 | return display; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | void ComposerClient::destroyVirtualDisplay(Display display) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 127 | Error error = mClient->destroyVirtualDisplay(display); |
| 128 | ASSERT_EQ(Error::NONE, error) << "failed to destroy virtual display " << display; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 129 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 130 | mDisplayResources.erase(display); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | Layer ComposerClient::createLayer(Display display, uint32_t bufferSlotCount) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 134 | Layer layer = 0; |
| 135 | mClient->createLayer(display, bufferSlotCount, [&](const auto& tmpError, const auto& tmpLayer) { |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 136 | ASSERT_EQ(Error::NONE, tmpError) << "failed to create layer"; |
| 137 | layer = tmpLayer; |
| 138 | |
| 139 | auto resourceIt = mDisplayResources.find(display); |
| 140 | if (resourceIt == mDisplayResources.end()) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 141 | resourceIt = mDisplayResources.insert({display, DisplayResource(false)}).first; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | ASSERT_TRUE(resourceIt->second.layers.insert(layer).second) |
| 145 | << "duplicated layer id " << layer; |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 146 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 147 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 148 | return layer; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | void ComposerClient::destroyLayer(Display display, Layer layer) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 152 | Error error = mClient->destroyLayer(display, layer); |
| 153 | ASSERT_EQ(Error::NONE, error) << "failed to destroy layer " << layer; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 154 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 155 | auto resourceIt = mDisplayResources.find(display); |
| 156 | ASSERT_NE(mDisplayResources.end(), resourceIt); |
| 157 | resourceIt->second.layers.erase(layer); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | Config ComposerClient::getActiveConfig(Display display) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 161 | Config config = 0; |
| 162 | mClient->getActiveConfig(display, [&](const auto& tmpError, const auto& tmpConfig) { |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 163 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get active config"; |
| 164 | config = tmpConfig; |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 165 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 166 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 167 | return config; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 168 | } |
| 169 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 170 | bool ComposerClient::getClientTargetSupport(Display display, uint32_t width, uint32_t height, |
| 171 | PixelFormat format, Dataspace dataspace) { |
| 172 | Error error = mClient->getClientTargetSupport(display, width, height, format, dataspace); |
| 173 | return error == Error::NONE; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | std::vector<ColorMode> ComposerClient::getColorModes(Display display) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 177 | std::vector<ColorMode> modes; |
| 178 | mClient->getColorModes(display, [&](const auto& tmpError, const auto& tmpMode) { |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 179 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get color mode"; |
| 180 | modes = tmpMode; |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 181 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 182 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 183 | return modes; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 184 | } |
| 185 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 186 | int32_t ComposerClient::getDisplayAttribute(Display display, Config config, |
| 187 | IComposerClient::Attribute attribute) { |
| 188 | int32_t value = 0; |
| 189 | mClient->getDisplayAttribute( |
| 190 | display, config, attribute, [&](const auto& tmpError, const auto& tmpValue) { |
| 191 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get display attribute"; |
| 192 | value = tmpValue; |
| 193 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 194 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 195 | return value; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | std::vector<Config> ComposerClient::getDisplayConfigs(Display display) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 199 | std::vector<Config> configs; |
| 200 | mClient->getDisplayConfigs(display, [&](const auto& tmpError, const auto& tmpConfigs) { |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 201 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get display configs"; |
| 202 | configs = tmpConfigs; |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 203 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 204 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 205 | return configs; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | std::string ComposerClient::getDisplayName(Display display) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 209 | std::string name; |
| 210 | mClient->getDisplayName(display, [&](const auto& tmpError, const auto& tmpName) { |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 211 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get display name"; |
| 212 | name = tmpName.c_str(); |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 213 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 214 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 215 | return name; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | IComposerClient::DisplayType ComposerClient::getDisplayType(Display display) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 219 | IComposerClient::DisplayType type = IComposerClient::DisplayType::INVALID; |
| 220 | mClient->getDisplayType(display, [&](const auto& tmpError, const auto& tmpType) { |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 221 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get display type"; |
| 222 | type = tmpType; |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 223 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 224 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 225 | return type; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | bool ComposerClient::getDozeSupport(Display display) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 229 | bool support = false; |
| 230 | mClient->getDozeSupport(display, [&](const auto& tmpError, const auto& tmpSupport) { |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 231 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get doze support"; |
| 232 | support = tmpSupport; |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 233 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 234 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 235 | return support; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 236 | } |
| 237 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 238 | std::vector<Hdr> ComposerClient::getHdrCapabilities(Display display, float* outMaxLuminance, |
| 239 | float* outMaxAverageLuminance, |
| 240 | float* outMinLuminance) { |
| 241 | std::vector<Hdr> types; |
| 242 | mClient->getHdrCapabilities( |
| 243 | display, [&](const auto& tmpError, const auto& tmpTypes, const auto& tmpMaxLuminance, |
| 244 | const auto& tmpMaxAverageLuminance, const auto& tmpMinLuminance) { |
| 245 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get HDR capabilities"; |
| 246 | types = tmpTypes; |
| 247 | *outMaxLuminance = tmpMaxLuminance; |
| 248 | *outMaxAverageLuminance = tmpMaxAverageLuminance; |
| 249 | *outMinLuminance = tmpMinLuminance; |
| 250 | }); |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 251 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 252 | return types; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 253 | } |
| 254 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 255 | void ComposerClient::setClientTargetSlotCount(Display display, uint32_t clientTargetSlotCount) { |
| 256 | Error error = mClient->setClientTargetSlotCount(display, clientTargetSlotCount); |
| 257 | ASSERT_EQ(Error::NONE, error) << "failed to set client target slot count"; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | void ComposerClient::setActiveConfig(Display display, Config config) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 261 | Error error = mClient->setActiveConfig(display, config); |
| 262 | ASSERT_EQ(Error::NONE, error) << "failed to set active config"; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | void ComposerClient::setColorMode(Display display, ColorMode mode) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 266 | Error error = mClient->setColorMode(display, mode); |
| 267 | ASSERT_EQ(Error::NONE, error) << "failed to set color mode"; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 268 | } |
| 269 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 270 | void ComposerClient::setPowerMode(Display display, IComposerClient::PowerMode mode) { |
| 271 | Error error = mClient->setPowerMode(display, mode); |
| 272 | ASSERT_EQ(Error::NONE, error) << "failed to set power mode"; |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | void ComposerClient::setVsyncEnabled(Display display, bool enabled) { |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 276 | IComposerClient::Vsync vsync = |
| 277 | (enabled) ? IComposerClient::Vsync::ENABLE : IComposerClient::Vsync::DISABLE; |
| 278 | Error error = mClient->setVsyncEnabled(display, vsync); |
| 279 | ASSERT_EQ(Error::NONE, error) << "failed to set vsync mode"; |
Chia-I Wu | 4f49038 | 2017-07-24 11:11:01 -0700 | [diff] [blame] | 280 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 281 | // give the hwbinder thread some time to handle any pending vsync callback |
| 282 | if (!enabled) { |
| 283 | usleep(5 * 1000); |
| 284 | } |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 285 | } |
| 286 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 287 | void ComposerClient::execute(TestCommandReader* reader, CommandWriterBase* writer) { |
| 288 | bool queueChanged = false; |
| 289 | uint32_t commandLength = 0; |
| 290 | hidl_vec<hidl_handle> commandHandles; |
| 291 | ASSERT_TRUE(writer->writeQueue(&queueChanged, &commandLength, &commandHandles)); |
Daniel Nicoara | d47f4a9 | 2017-05-30 15:38:30 -0400 | [diff] [blame] | 292 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 293 | if (queueChanged) { |
| 294 | auto ret = mClient->setInputCommandQueue(*writer->getMQDescriptor()); |
| 295 | ASSERT_EQ(Error::NONE, static_cast<Error>(ret)); |
| 296 | return; |
| 297 | } |
Daniel Nicoara | d47f4a9 | 2017-05-30 15:38:30 -0400 | [diff] [blame] | 298 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 299 | mClient->executeCommands(commandLength, commandHandles, |
| 300 | [&](const auto& tmpError, const auto& tmpOutQueueChanged, |
| 301 | const auto& tmpOutLength, const auto& tmpOutHandles) { |
| 302 | ASSERT_EQ(Error::NONE, tmpError); |
Daniel Nicoara | d47f4a9 | 2017-05-30 15:38:30 -0400 | [diff] [blame] | 303 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 304 | if (tmpOutQueueChanged) { |
| 305 | mClient->getOutputCommandQueue( |
| 306 | [&](const auto& tmpError, const auto& tmpDescriptor) { |
| 307 | ASSERT_EQ(Error::NONE, tmpError); |
| 308 | reader->setMQDescriptor(tmpDescriptor); |
| 309 | }); |
| 310 | } |
Daniel Nicoara | d47f4a9 | 2017-05-30 15:38:30 -0400 | [diff] [blame] | 311 | |
Chia-I Wu | 8b20c5c | 2018-01-25 11:18:10 -0800 | [diff] [blame] | 312 | ASSERT_TRUE(reader->readQueue(tmpOutLength, tmpOutHandles)); |
| 313 | reader->parse(); |
| 314 | }); |
Daniel Nicoara | d47f4a9 | 2017-05-30 15:38:30 -0400 | [diff] [blame] | 315 | } |
| 316 | |
Chia-I Wu | 96a098a | 2018-01-25 10:38:06 -0800 | [diff] [blame] | 317 | } // namespace vts |
Chia-I Wu | 8cc5a15 | 2017-02-24 14:34:02 -0800 | [diff] [blame] | 318 | } // namespace V2_1 |
| 319 | } // namespace composer |
| 320 | } // namespace graphics |
| 321 | } // namespace hardware |
| 322 | } // namespace android |