Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 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 | #undef LOG_TAG |
| 18 | #define LOG_TAG "HwcComposer" |
| 19 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 20 | |
Ady Abraham | 9fc2805 | 2021-10-14 17:21:38 -0700 | [diff] [blame] | 21 | #include "AidlComposerHal.h" |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 22 | |
Ady Abraham | c4acf51 | 2022-02-18 17:11:59 -0800 | [diff] [blame^] | 23 | #include <android-base/file.h> |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 24 | #include <android/binder_ibinder_platform.h> |
| 25 | #include <android/binder_manager.h> |
| 26 | #include <log/log.h> |
| 27 | #include <utils/Trace.h> |
| 28 | |
| 29 | #include <aidl/android/hardware/graphics/composer3/BnComposerCallback.h> |
| 30 | |
| 31 | #include <algorithm> |
| 32 | #include <cinttypes> |
| 33 | |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 34 | #include "HWC2.h" |
| 35 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 36 | namespace android { |
| 37 | |
| 38 | using hardware::hidl_handle; |
| 39 | using hardware::hidl_vec; |
| 40 | using hardware::Return; |
| 41 | |
| 42 | using aidl::android::hardware::graphics::composer3::BnComposerCallback; |
| 43 | using aidl::android::hardware::graphics::composer3::Capability; |
| 44 | using aidl::android::hardware::graphics::composer3::PowerMode; |
| 45 | using aidl::android::hardware::graphics::composer3::VirtualDisplay; |
| 46 | |
Ady Abraham | 4297736 | 2021-12-07 21:04:49 -0800 | [diff] [blame] | 47 | using aidl::android::hardware::graphics::composer3::CommandResultPayload; |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 48 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 49 | using AidlColorMode = aidl::android::hardware::graphics::composer3::ColorMode; |
| 50 | using AidlContentType = aidl::android::hardware::graphics::composer3::ContentType; |
| 51 | using AidlDisplayIdentification = |
| 52 | aidl::android::hardware::graphics::composer3::DisplayIdentification; |
| 53 | using AidlDisplayContentSample = aidl::android::hardware::graphics::composer3::DisplayContentSample; |
| 54 | using AidlDisplayAttribute = aidl::android::hardware::graphics::composer3::DisplayAttribute; |
| 55 | using AidlDisplayCapability = aidl::android::hardware::graphics::composer3::DisplayCapability; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 56 | using AidlHdrCapabilities = aidl::android::hardware::graphics::composer3::HdrCapabilities; |
| 57 | using AidlPerFrameMetadata = aidl::android::hardware::graphics::composer3::PerFrameMetadata; |
| 58 | using AidlPerFrameMetadataKey = aidl::android::hardware::graphics::composer3::PerFrameMetadataKey; |
| 59 | using AidlPerFrameMetadataBlob = aidl::android::hardware::graphics::composer3::PerFrameMetadataBlob; |
| 60 | using AidlRenderIntent = aidl::android::hardware::graphics::composer3::RenderIntent; |
| 61 | using AidlVsyncPeriodChangeConstraints = |
| 62 | aidl::android::hardware::graphics::composer3::VsyncPeriodChangeConstraints; |
| 63 | using AidlVsyncPeriodChangeTimeline = |
| 64 | aidl::android::hardware::graphics::composer3::VsyncPeriodChangeTimeline; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 65 | using AidlDisplayContentSamplingAttributes = |
| 66 | aidl::android::hardware::graphics::composer3::DisplayContentSamplingAttributes; |
| 67 | using AidlFormatColorComponent = aidl::android::hardware::graphics::composer3::FormatColorComponent; |
| 68 | using AidlDisplayConnectionType = |
| 69 | aidl::android::hardware::graphics::composer3::DisplayConnectionType; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 70 | |
| 71 | using AidlColorTransform = aidl::android::hardware::graphics::common::ColorTransform; |
| 72 | using AidlDataspace = aidl::android::hardware::graphics::common::Dataspace; |
| 73 | using AidlFRect = aidl::android::hardware::graphics::common::FRect; |
| 74 | using AidlRect = aidl::android::hardware::graphics::common::Rect; |
| 75 | using AidlTransform = aidl::android::hardware::graphics::common::Transform; |
| 76 | |
| 77 | namespace Hwc2 { |
| 78 | |
| 79 | namespace { |
| 80 | |
| 81 | template <typename To, typename From> |
| 82 | To translate(From x) { |
| 83 | return static_cast<To>(x); |
| 84 | } |
| 85 | |
| 86 | template <typename To, typename From> |
| 87 | std::vector<To> translate(const std::vector<From>& in) { |
| 88 | std::vector<To> out; |
| 89 | out.reserve(in.size()); |
| 90 | std::transform(in.begin(), in.end(), std::back_inserter(out), |
| 91 | [](From x) { return translate<To>(x); }); |
| 92 | return out; |
| 93 | } |
| 94 | |
| 95 | template <> |
| 96 | AidlRect translate(IComposerClient::Rect x) { |
| 97 | return AidlRect{ |
| 98 | .left = x.left, |
| 99 | .top = x.top, |
| 100 | .right = x.right, |
| 101 | .bottom = x.bottom, |
| 102 | }; |
| 103 | } |
| 104 | |
| 105 | template <> |
| 106 | AidlFRect translate(IComposerClient::FRect x) { |
| 107 | return AidlFRect{ |
| 108 | .left = x.left, |
| 109 | .top = x.top, |
| 110 | .right = x.right, |
| 111 | .bottom = x.bottom, |
| 112 | }; |
| 113 | } |
| 114 | |
| 115 | template <> |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 116 | AidlPerFrameMetadataBlob translate(IComposerClient::PerFrameMetadataBlob x) { |
| 117 | AidlPerFrameMetadataBlob blob; |
| 118 | blob.key = translate<AidlPerFrameMetadataKey>(x.key), |
| 119 | std::copy(blob.blob.begin(), blob.blob.end(), x.blob.begin()); |
| 120 | return blob; |
| 121 | } |
| 122 | |
| 123 | template <> |
| 124 | AidlPerFrameMetadata translate(IComposerClient::PerFrameMetadata x) { |
| 125 | return AidlPerFrameMetadata{ |
| 126 | .key = translate<AidlPerFrameMetadataKey>(x.key), |
| 127 | .value = x.value, |
| 128 | }; |
| 129 | } |
| 130 | |
| 131 | template <> |
| 132 | DisplayedFrameStats translate(AidlDisplayContentSample x) { |
| 133 | return DisplayedFrameStats{ |
| 134 | .numFrames = static_cast<uint64_t>(x.frameCount), |
| 135 | .component_0_sample = translate<uint64_t>(x.sampleComponent0), |
| 136 | .component_1_sample = translate<uint64_t>(x.sampleComponent1), |
| 137 | .component_2_sample = translate<uint64_t>(x.sampleComponent2), |
| 138 | .component_3_sample = translate<uint64_t>(x.sampleComponent3), |
| 139 | }; |
| 140 | } |
| 141 | |
| 142 | template <> |
| 143 | AidlVsyncPeriodChangeConstraints translate(IComposerClient::VsyncPeriodChangeConstraints x) { |
| 144 | return AidlVsyncPeriodChangeConstraints{ |
| 145 | .desiredTimeNanos = x.desiredTimeNanos, |
| 146 | .seamlessRequired = x.seamlessRequired, |
| 147 | }; |
| 148 | } |
| 149 | |
| 150 | template <> |
| 151 | VsyncPeriodChangeTimeline translate(AidlVsyncPeriodChangeTimeline x) { |
| 152 | return VsyncPeriodChangeTimeline{ |
| 153 | .newVsyncAppliedTimeNanos = x.newVsyncAppliedTimeNanos, |
| 154 | .refreshRequired = x.refreshRequired, |
| 155 | .refreshTimeNanos = x.refreshTimeNanos, |
| 156 | }; |
| 157 | } |
| 158 | |
| 159 | template <> |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 160 | IComposerClient::ClientTargetProperty translate(ClientTargetProperty x) { |
| 161 | return IComposerClient::ClientTargetProperty{ |
| 162 | .pixelFormat = translate<PixelFormat>(x.pixelFormat), |
| 163 | .dataspace = translate<Dataspace>(x.dataspace), |
| 164 | }; |
| 165 | } |
| 166 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 167 | mat4 makeMat4(std::vector<float> in) { |
| 168 | return mat4(static_cast<const float*>(in.data())); |
| 169 | } |
| 170 | |
| 171 | } // namespace |
| 172 | |
| 173 | class AidlIComposerCallbackWrapper : public BnComposerCallback { |
| 174 | public: |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 175 | AidlIComposerCallbackWrapper(HWC2::ComposerCallback& callback) : mCallback(callback) {} |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 176 | |
| 177 | ::ndk::ScopedAStatus onHotplug(int64_t in_display, bool in_connected) override { |
| 178 | const auto connection = in_connected ? V2_4::IComposerCallback::Connection::CONNECTED |
| 179 | : V2_4::IComposerCallback::Connection::DISCONNECTED; |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 180 | mCallback.onComposerHalHotplug(translate<Display>(in_display), connection); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 181 | return ::ndk::ScopedAStatus::ok(); |
| 182 | } |
| 183 | |
| 184 | ::ndk::ScopedAStatus onRefresh(int64_t in_display) override { |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 185 | mCallback.onComposerHalRefresh(translate<Display>(in_display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 186 | return ::ndk::ScopedAStatus::ok(); |
| 187 | } |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 188 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 189 | ::ndk::ScopedAStatus onSeamlessPossible(int64_t in_display) override { |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 190 | mCallback.onComposerHalSeamlessPossible(translate<Display>(in_display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 191 | return ::ndk::ScopedAStatus::ok(); |
| 192 | } |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 193 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 194 | ::ndk::ScopedAStatus onVsync(int64_t in_display, int64_t in_timestamp, |
| 195 | int32_t in_vsyncPeriodNanos) override { |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 196 | mCallback.onComposerHalVsync(translate<Display>(in_display), in_timestamp, |
| 197 | static_cast<uint32_t>(in_vsyncPeriodNanos)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 198 | return ::ndk::ScopedAStatus::ok(); |
| 199 | } |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 200 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 201 | ::ndk::ScopedAStatus onVsyncPeriodTimingChanged( |
| 202 | int64_t in_display, const AidlVsyncPeriodChangeTimeline& in_updatedTimeline) override { |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 203 | mCallback.onComposerHalVsyncPeriodTimingChanged(translate<Display>(in_display), |
| 204 | translate<V2_4::VsyncPeriodChangeTimeline>( |
| 205 | in_updatedTimeline)); |
| 206 | return ::ndk::ScopedAStatus::ok(); |
| 207 | } |
| 208 | |
| 209 | ::ndk::ScopedAStatus onVsyncIdle(int64_t in_display) override { |
| 210 | mCallback.onComposerHalVsyncIdle(translate<Display>(in_display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 211 | return ::ndk::ScopedAStatus::ok(); |
| 212 | } |
| 213 | |
| 214 | private: |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 215 | HWC2::ComposerCallback& mCallback; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 216 | }; |
| 217 | |
Ady Abraham | 9fc2805 | 2021-10-14 17:21:38 -0700 | [diff] [blame] | 218 | std::string AidlComposer::instance(const std::string& serviceName) { |
| 219 | return std::string(AidlIComposer::descriptor) + "/" + serviceName; |
| 220 | } |
| 221 | |
| 222 | bool AidlComposer::isDeclared(const std::string& serviceName) { |
| 223 | return AServiceManager_isDeclared(instance(serviceName).c_str()); |
| 224 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 225 | |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 226 | AidlComposer::AidlComposer(const std::string& serviceName) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 227 | // This only waits if the service is actually declared |
Ady Abraham | 9fc2805 | 2021-10-14 17:21:38 -0700 | [diff] [blame] | 228 | mAidlComposer = AidlIComposer::fromBinder( |
| 229 | ndk::SpAIBinder(AServiceManager_waitForService(instance(serviceName).c_str()))); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 230 | if (!mAidlComposer) { |
| 231 | LOG_ALWAYS_FATAL("Failed to get AIDL composer service"); |
| 232 | return; |
| 233 | } |
| 234 | |
| 235 | if (!mAidlComposer->createClient(&mAidlComposerClient).isOk()) { |
| 236 | LOG_ALWAYS_FATAL("Can't create AidlComposerClient, fallback to HIDL"); |
| 237 | return; |
| 238 | } |
| 239 | |
| 240 | ALOGI("Loaded AIDL composer3 HAL service"); |
| 241 | } |
| 242 | |
| 243 | AidlComposer::~AidlComposer() = default; |
| 244 | |
Ady Abraham | 4d211cf | 2021-12-14 16:19:03 -0800 | [diff] [blame] | 245 | bool AidlComposer::isSupported(OptionalFeature feature) const { |
| 246 | switch (feature) { |
| 247 | case OptionalFeature::RefreshRateSwitching: |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 248 | case OptionalFeature::ExpectedPresentTime: |
Alec Mouri | cdf1679 | 2021-12-10 13:16:06 -0800 | [diff] [blame] | 249 | case OptionalFeature::DisplayBrightnessCommand: |
Kriti Dang | 7defaf3 | 2021-11-15 11:55:43 +0100 | [diff] [blame] | 250 | case OptionalFeature::BootDisplayConfig: |
Ady Abraham | 4d211cf | 2021-12-14 16:19:03 -0800 | [diff] [blame] | 251 | return true; |
| 252 | } |
| 253 | } |
| 254 | |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 255 | std::vector<Capability> AidlComposer::getCapabilities() { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 256 | std::vector<Capability> capabilities; |
| 257 | const auto status = mAidlComposer->getCapabilities(&capabilities); |
| 258 | if (!status.isOk()) { |
| 259 | ALOGE("getCapabilities failed %s", status.getDescription().c_str()); |
| 260 | return {}; |
| 261 | } |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 262 | return capabilities; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | std::string AidlComposer::dumpDebugInfo() { |
Ady Abraham | c4acf51 | 2022-02-18 17:11:59 -0800 | [diff] [blame^] | 266 | int pipefds[2]; |
| 267 | int result = pipe(pipefds); |
| 268 | if (result < 0) { |
| 269 | ALOGE("dumpDebugInfo: pipe failed: %s", strerror(errno)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 270 | return {}; |
| 271 | } |
Ady Abraham | c4acf51 | 2022-02-18 17:11:59 -0800 | [diff] [blame^] | 272 | |
| 273 | std::string str; |
| 274 | const auto status = mAidlComposer->dump(pipefds[1], /*args*/ nullptr, /*numArgs*/ 0); |
| 275 | // Close the write-end of the pipe to make sure that when reading from the |
| 276 | // read-end we will get eof instead of blocking forever |
| 277 | close(pipefds[1]); |
| 278 | |
| 279 | if (status == STATUS_OK) { |
| 280 | base::ReadFdToString(pipefds[0], &str); |
| 281 | } else { |
| 282 | ALOGE("dumpDebugInfo: dump failed: %d", status); |
| 283 | } |
| 284 | |
| 285 | close(pipefds[0]); |
| 286 | return str; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 287 | } |
| 288 | |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 289 | void AidlComposer::registerCallback(HWC2::ComposerCallback& callback) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 290 | if (mAidlComposerCallback) { |
| 291 | ALOGE("Callback already registered"); |
| 292 | } |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 293 | |
Ady Abraham | 9fc2805 | 2021-10-14 17:21:38 -0700 | [diff] [blame] | 294 | mAidlComposerCallback = ndk::SharedRefBase::make<AidlIComposerCallbackWrapper>(callback); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 295 | AIBinder_setMinSchedulerPolicy(mAidlComposerCallback->asBinder().get(), SCHED_FIFO, 2); |
| 296 | |
| 297 | const auto status = mAidlComposerClient->registerCallback(mAidlComposerCallback); |
| 298 | if (!status.isOk()) { |
| 299 | ALOGE("registerCallback failed %s", status.getDescription().c_str()); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | void AidlComposer::resetCommands() { |
| 304 | mWriter.reset(); |
| 305 | } |
| 306 | |
| 307 | Error AidlComposer::executeCommands() { |
| 308 | return execute(); |
| 309 | } |
| 310 | |
| 311 | uint32_t AidlComposer::getMaxVirtualDisplayCount() { |
| 312 | int32_t count = 0; |
| 313 | const auto status = mAidlComposerClient->getMaxVirtualDisplayCount(&count); |
| 314 | if (!status.isOk()) { |
| 315 | ALOGE("getMaxVirtualDisplayCount failed %s", status.getDescription().c_str()); |
| 316 | return 0; |
| 317 | } |
| 318 | return static_cast<uint32_t>(count); |
| 319 | } |
| 320 | |
| 321 | Error AidlComposer::createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat* format, |
| 322 | Display* outDisplay) { |
| 323 | using AidlPixelFormat = aidl::android::hardware::graphics::common::PixelFormat; |
| 324 | const int32_t bufferSlotCount = 1; |
| 325 | VirtualDisplay virtualDisplay; |
| 326 | const auto status = |
| 327 | mAidlComposerClient->createVirtualDisplay(static_cast<int32_t>(width), |
| 328 | static_cast<int32_t>(height), |
| 329 | static_cast<AidlPixelFormat>(*format), |
| 330 | bufferSlotCount, &virtualDisplay); |
| 331 | |
| 332 | if (!status.isOk()) { |
| 333 | ALOGE("createVirtualDisplay failed %s", status.getDescription().c_str()); |
| 334 | return static_cast<Error>(status.getServiceSpecificError()); |
| 335 | } |
| 336 | |
| 337 | *outDisplay = translate<Display>(virtualDisplay.display); |
| 338 | *format = static_cast<PixelFormat>(virtualDisplay.format); |
| 339 | return Error::NONE; |
| 340 | } |
| 341 | |
| 342 | Error AidlComposer::destroyVirtualDisplay(Display display) { |
| 343 | const auto status = mAidlComposerClient->destroyVirtualDisplay(translate<int64_t>(display)); |
| 344 | if (!status.isOk()) { |
| 345 | ALOGE("destroyVirtualDisplay failed %s", status.getDescription().c_str()); |
| 346 | return static_cast<Error>(status.getServiceSpecificError()); |
| 347 | } |
| 348 | return Error::NONE; |
| 349 | } |
| 350 | |
| 351 | Error AidlComposer::acceptDisplayChanges(Display display) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 352 | mWriter.acceptDisplayChanges(translate<int64_t>(display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 353 | return Error::NONE; |
| 354 | } |
| 355 | |
| 356 | Error AidlComposer::createLayer(Display display, Layer* outLayer) { |
| 357 | int64_t layer; |
| 358 | const auto status = mAidlComposerClient->createLayer(translate<int64_t>(display), |
| 359 | kMaxLayerBufferCount, &layer); |
| 360 | if (!status.isOk()) { |
| 361 | ALOGE("createLayer failed %s", status.getDescription().c_str()); |
| 362 | return static_cast<Error>(status.getServiceSpecificError()); |
| 363 | } |
| 364 | |
| 365 | *outLayer = translate<Layer>(layer); |
| 366 | return Error::NONE; |
| 367 | } |
| 368 | |
| 369 | Error AidlComposer::destroyLayer(Display display, Layer layer) { |
| 370 | const auto status = mAidlComposerClient->destroyLayer(translate<int64_t>(display), |
| 371 | translate<int64_t>(layer)); |
| 372 | if (!status.isOk()) { |
| 373 | ALOGE("destroyLayer failed %s", status.getDescription().c_str()); |
| 374 | return static_cast<Error>(status.getServiceSpecificError()); |
| 375 | } |
| 376 | return Error::NONE; |
| 377 | } |
| 378 | |
| 379 | Error AidlComposer::getActiveConfig(Display display, Config* outConfig) { |
| 380 | int32_t config; |
| 381 | const auto status = mAidlComposerClient->getActiveConfig(translate<int64_t>(display), &config); |
| 382 | if (!status.isOk()) { |
| 383 | ALOGE("getActiveConfig failed %s", status.getDescription().c_str()); |
| 384 | return static_cast<Error>(status.getServiceSpecificError()); |
| 385 | } |
| 386 | *outConfig = translate<Config>(config); |
| 387 | return Error::NONE; |
| 388 | } |
| 389 | |
| 390 | Error AidlComposer::getChangedCompositionTypes( |
| 391 | Display display, std::vector<Layer>* outLayers, |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 392 | std::vector<aidl::android::hardware::graphics::composer3::Composition>* outTypes) { |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 393 | const auto changedLayers = mReader.takeChangedCompositionTypes(translate<int64_t>(display)); |
| 394 | outLayers->reserve(changedLayers.size()); |
| 395 | outTypes->reserve(changedLayers.size()); |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 396 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 397 | for (const auto& layer : changedLayers) { |
| 398 | outLayers->emplace_back(translate<Layer>(layer.layer)); |
| 399 | outTypes->emplace_back(layer.composition); |
| 400 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 401 | return Error::NONE; |
| 402 | } |
| 403 | |
| 404 | Error AidlComposer::getColorModes(Display display, std::vector<ColorMode>* outModes) { |
| 405 | std::vector<AidlColorMode> modes; |
| 406 | const auto status = mAidlComposerClient->getColorModes(translate<int64_t>(display), &modes); |
| 407 | if (!status.isOk()) { |
| 408 | ALOGE("getColorModes failed %s", status.getDescription().c_str()); |
| 409 | return static_cast<Error>(status.getServiceSpecificError()); |
| 410 | } |
| 411 | *outModes = translate<ColorMode>(modes); |
| 412 | return Error::NONE; |
| 413 | } |
| 414 | |
| 415 | Error AidlComposer::getDisplayAttribute(Display display, Config config, |
| 416 | IComposerClient::Attribute attribute, int32_t* outValue) { |
| 417 | const auto status = |
| 418 | mAidlComposerClient->getDisplayAttribute(translate<int64_t>(display), |
| 419 | translate<int32_t>(config), |
| 420 | static_cast<AidlDisplayAttribute>(attribute), |
| 421 | outValue); |
| 422 | if (!status.isOk()) { |
| 423 | ALOGE("getDisplayAttribute failed %s", status.getDescription().c_str()); |
| 424 | return static_cast<Error>(status.getServiceSpecificError()); |
| 425 | } |
| 426 | return Error::NONE; |
| 427 | } |
| 428 | |
| 429 | Error AidlComposer::getDisplayConfigs(Display display, std::vector<Config>* outConfigs) { |
| 430 | std::vector<int32_t> configs; |
| 431 | const auto status = |
| 432 | mAidlComposerClient->getDisplayConfigs(translate<int64_t>(display), &configs); |
| 433 | if (!status.isOk()) { |
| 434 | ALOGE("getDisplayConfigs failed %s", status.getDescription().c_str()); |
| 435 | return static_cast<Error>(status.getServiceSpecificError()); |
| 436 | } |
| 437 | *outConfigs = translate<Config>(configs); |
| 438 | return Error::NONE; |
| 439 | } |
| 440 | |
| 441 | Error AidlComposer::getDisplayName(Display display, std::string* outName) { |
| 442 | const auto status = mAidlComposerClient->getDisplayName(translate<int64_t>(display), outName); |
| 443 | if (!status.isOk()) { |
| 444 | ALOGE("getDisplayName failed %s", status.getDescription().c_str()); |
| 445 | return static_cast<Error>(status.getServiceSpecificError()); |
| 446 | } |
| 447 | return Error::NONE; |
| 448 | } |
| 449 | |
| 450 | Error AidlComposer::getDisplayRequests(Display display, uint32_t* outDisplayRequestMask, |
| 451 | std::vector<Layer>* outLayers, |
| 452 | std::vector<uint32_t>* outLayerRequestMasks) { |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 453 | const auto displayRequests = mReader.takeDisplayRequests(translate<int64_t>(display)); |
| 454 | *outDisplayRequestMask = translate<uint32_t>(displayRequests.mask); |
| 455 | outLayers->reserve(displayRequests.layerRequests.size()); |
| 456 | outLayerRequestMasks->reserve(displayRequests.layerRequests.size()); |
| 457 | |
| 458 | for (const auto& layer : displayRequests.layerRequests) { |
| 459 | outLayers->emplace_back(translate<Layer>(layer.layer)); |
| 460 | outLayerRequestMasks->emplace_back(translate<uint32_t>(layer.mask)); |
| 461 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 462 | return Error::NONE; |
| 463 | } |
| 464 | |
| 465 | Error AidlComposer::getDozeSupport(Display display, bool* outSupport) { |
Ady Abraham | 33b92b9 | 2021-12-08 18:30:27 -0800 | [diff] [blame] | 466 | std::vector<AidlDisplayCapability> capabilities; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 467 | const auto status = |
Ady Abraham | 33b92b9 | 2021-12-08 18:30:27 -0800 | [diff] [blame] | 468 | mAidlComposerClient->getDisplayCapabilities(translate<int64_t>(display), &capabilities); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 469 | if (!status.isOk()) { |
Ady Abraham | 33b92b9 | 2021-12-08 18:30:27 -0800 | [diff] [blame] | 470 | ALOGE("getDisplayCapabilities failed %s", status.getDescription().c_str()); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 471 | return static_cast<Error>(status.getServiceSpecificError()); |
| 472 | } |
Ady Abraham | 33b92b9 | 2021-12-08 18:30:27 -0800 | [diff] [blame] | 473 | *outSupport = std::find(capabilities.begin(), capabilities.end(), |
| 474 | AidlDisplayCapability::DOZE) != capabilities.end(); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 475 | return Error::NONE; |
| 476 | } |
| 477 | |
| 478 | Error AidlComposer::getHdrCapabilities(Display display, std::vector<Hdr>* outTypes, |
| 479 | float* outMaxLuminance, float* outMaxAverageLuminance, |
| 480 | float* outMinLuminance) { |
| 481 | AidlHdrCapabilities capabilities; |
| 482 | const auto status = |
| 483 | mAidlComposerClient->getHdrCapabilities(translate<int64_t>(display), &capabilities); |
| 484 | if (!status.isOk()) { |
| 485 | ALOGE("getHdrCapabilities failed %s", status.getDescription().c_str()); |
| 486 | return static_cast<Error>(status.getServiceSpecificError()); |
| 487 | } |
| 488 | |
| 489 | *outTypes = translate<Hdr>(capabilities.types); |
| 490 | *outMaxLuminance = capabilities.maxLuminance; |
| 491 | *outMaxAverageLuminance = capabilities.maxAverageLuminance; |
| 492 | *outMinLuminance = capabilities.minLuminance; |
| 493 | return Error::NONE; |
| 494 | } |
| 495 | |
| 496 | Error AidlComposer::getReleaseFences(Display display, std::vector<Layer>* outLayers, |
| 497 | std::vector<int>* outReleaseFences) { |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 498 | auto fences = mReader.takeReleaseFences(translate<int64_t>(display)); |
| 499 | outLayers->reserve(fences.size()); |
| 500 | outReleaseFences->reserve(fences.size()); |
| 501 | |
| 502 | for (auto& fence : fences) { |
| 503 | outLayers->emplace_back(translate<Layer>(fence.layer)); |
| 504 | // take ownership |
| 505 | const int fenceOwner = fence.fence.get(); |
| 506 | *fence.fence.getR() = -1; |
| 507 | outReleaseFences->emplace_back(fenceOwner); |
| 508 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 509 | return Error::NONE; |
| 510 | } |
| 511 | |
| 512 | Error AidlComposer::presentDisplay(Display display, int* outPresentFence) { |
| 513 | ATRACE_NAME("HwcPresentDisplay"); |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 514 | mWriter.presentDisplay(translate<int64_t>(display)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 515 | |
| 516 | Error error = execute(); |
| 517 | if (error != Error::NONE) { |
| 518 | return error; |
| 519 | } |
| 520 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 521 | auto fence = mReader.takePresentFence(translate<int64_t>(display)); |
| 522 | // take ownership |
| 523 | *outPresentFence = fence.get(); |
| 524 | *fence.getR() = -1; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 525 | return Error::NONE; |
| 526 | } |
| 527 | |
| 528 | Error AidlComposer::setActiveConfig(Display display, Config config) { |
| 529 | const auto status = mAidlComposerClient->setActiveConfig(translate<int64_t>(display), |
| 530 | translate<int32_t>(config)); |
| 531 | if (!status.isOk()) { |
| 532 | ALOGE("setActiveConfig failed %s", status.getDescription().c_str()); |
| 533 | return static_cast<Error>(status.getServiceSpecificError()); |
| 534 | } |
| 535 | return Error::NONE; |
| 536 | } |
| 537 | |
| 538 | Error AidlComposer::setClientTarget(Display display, uint32_t slot, const sp<GraphicBuffer>& target, |
| 539 | int acquireFence, Dataspace dataspace, |
| 540 | const std::vector<IComposerClient::Rect>& damage) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 541 | const native_handle_t* handle = nullptr; |
| 542 | if (target.get()) { |
| 543 | handle = target->getNativeBuffer()->handle; |
| 544 | } |
| 545 | |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 546 | mWriter.setClientTarget(translate<int64_t>(display), slot, handle, acquireFence, |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 547 | translate<aidl::android::hardware::graphics::common::Dataspace>( |
| 548 | dataspace), |
| 549 | translate<AidlRect>(damage)); |
| 550 | return Error::NONE; |
| 551 | } |
| 552 | |
| 553 | Error AidlComposer::setColorMode(Display display, ColorMode mode, RenderIntent renderIntent) { |
| 554 | const auto status = |
| 555 | mAidlComposerClient->setColorMode(translate<int64_t>(display), |
| 556 | translate<AidlColorMode>(mode), |
| 557 | translate<AidlRenderIntent>(renderIntent)); |
| 558 | if (!status.isOk()) { |
| 559 | ALOGE("setColorMode failed %s", status.getDescription().c_str()); |
| 560 | return static_cast<Error>(status.getServiceSpecificError()); |
| 561 | } |
| 562 | return Error::NONE; |
| 563 | } |
| 564 | |
Ady Abraham | dc011a9 | 2021-12-21 14:06:44 -0800 | [diff] [blame] | 565 | Error AidlComposer::setColorTransform(Display display, const float* matrix) { |
| 566 | mWriter.setColorTransform(translate<int64_t>(display), matrix); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 567 | return Error::NONE; |
| 568 | } |
| 569 | |
| 570 | Error AidlComposer::setOutputBuffer(Display display, const native_handle_t* buffer, |
| 571 | int releaseFence) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 572 | mWriter.setOutputBuffer(translate<int64_t>(display), 0, buffer, dup(releaseFence)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 573 | return Error::NONE; |
| 574 | } |
| 575 | |
| 576 | Error AidlComposer::setPowerMode(Display display, IComposerClient::PowerMode mode) { |
| 577 | const auto status = mAidlComposerClient->setPowerMode(translate<int64_t>(display), |
| 578 | translate<PowerMode>(mode)); |
| 579 | if (!status.isOk()) { |
| 580 | ALOGE("setPowerMode failed %s", status.getDescription().c_str()); |
| 581 | return static_cast<Error>(status.getServiceSpecificError()); |
| 582 | } |
| 583 | return Error::NONE; |
| 584 | } |
| 585 | |
| 586 | Error AidlComposer::setVsyncEnabled(Display display, IComposerClient::Vsync enabled) { |
| 587 | const bool enableVsync = enabled == IComposerClient::Vsync::ENABLE; |
| 588 | const auto status = |
| 589 | mAidlComposerClient->setVsyncEnabled(translate<int64_t>(display), enableVsync); |
| 590 | if (!status.isOk()) { |
| 591 | ALOGE("setVsyncEnabled failed %s", status.getDescription().c_str()); |
| 592 | return static_cast<Error>(status.getServiceSpecificError()); |
| 593 | } |
| 594 | return Error::NONE; |
| 595 | } |
| 596 | |
| 597 | Error AidlComposer::setClientTargetSlotCount(Display display) { |
| 598 | const int32_t bufferSlotCount = BufferQueue::NUM_BUFFER_SLOTS; |
| 599 | const auto status = mAidlComposerClient->setClientTargetSlotCount(translate<int64_t>(display), |
| 600 | bufferSlotCount); |
| 601 | if (!status.isOk()) { |
| 602 | ALOGE("setClientTargetSlotCount failed %s", status.getDescription().c_str()); |
| 603 | return static_cast<Error>(status.getServiceSpecificError()); |
| 604 | } |
| 605 | return Error::NONE; |
| 606 | } |
| 607 | |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 608 | Error AidlComposer::validateDisplay(Display display, nsecs_t expectedPresentTime, |
| 609 | uint32_t* outNumTypes, uint32_t* outNumRequests) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 610 | ATRACE_NAME("HwcValidateDisplay"); |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 611 | mWriter.validateDisplay(translate<int64_t>(display), |
| 612 | ClockMonotonicTimestamp{expectedPresentTime}); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 613 | |
| 614 | Error error = execute(); |
| 615 | if (error != Error::NONE) { |
| 616 | return error; |
| 617 | } |
| 618 | |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 619 | mReader.hasChanges(translate<int64_t>(display), outNumTypes, outNumRequests); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 620 | |
| 621 | return Error::NONE; |
| 622 | } |
| 623 | |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 624 | Error AidlComposer::presentOrValidateDisplay(Display display, nsecs_t expectedPresentTime, |
| 625 | uint32_t* outNumTypes, uint32_t* outNumRequests, |
| 626 | int* outPresentFence, uint32_t* state) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 627 | ATRACE_NAME("HwcPresentOrValidateDisplay"); |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 628 | mWriter.presentOrvalidateDisplay(translate<int64_t>(display), |
| 629 | ClockMonotonicTimestamp{expectedPresentTime}); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 630 | |
| 631 | Error error = execute(); |
| 632 | if (error != Error::NONE) { |
| 633 | return error; |
| 634 | } |
| 635 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 636 | const auto result = mReader.takePresentOrValidateStage(translate<int64_t>(display)); |
| 637 | if (!result.has_value()) { |
| 638 | *state = translate<uint32_t>(-1); |
| 639 | return Error::NO_RESOURCES; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 640 | } |
| 641 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 642 | *state = translate<uint32_t>(*result); |
| 643 | |
| 644 | if (*result == PresentOrValidate::Result::Presented) { |
| 645 | auto fence = mReader.takePresentFence(translate<int64_t>(display)); |
| 646 | // take ownership |
| 647 | *outPresentFence = fence.get(); |
| 648 | *fence.getR() = -1; |
| 649 | } |
| 650 | |
| 651 | if (*result == PresentOrValidate::Result::Validated) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 652 | mReader.hasChanges(translate<int64_t>(display), outNumTypes, outNumRequests); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | return Error::NONE; |
| 656 | } |
| 657 | |
| 658 | Error AidlComposer::setCursorPosition(Display display, Layer layer, int32_t x, int32_t y) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 659 | mWriter.setLayerCursorPosition(translate<int64_t>(display), translate<int64_t>(layer), x, y); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 660 | return Error::NONE; |
| 661 | } |
| 662 | |
| 663 | Error AidlComposer::setLayerBuffer(Display display, Layer layer, uint32_t slot, |
| 664 | const sp<GraphicBuffer>& buffer, int acquireFence) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 665 | const native_handle_t* handle = nullptr; |
| 666 | if (buffer.get()) { |
| 667 | handle = buffer->getNativeBuffer()->handle; |
| 668 | } |
| 669 | |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 670 | mWriter.setLayerBuffer(translate<int64_t>(display), translate<int64_t>(layer), slot, handle, |
| 671 | acquireFence); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 672 | return Error::NONE; |
| 673 | } |
| 674 | |
| 675 | Error AidlComposer::setLayerSurfaceDamage(Display display, Layer layer, |
| 676 | const std::vector<IComposerClient::Rect>& damage) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 677 | mWriter.setLayerSurfaceDamage(translate<int64_t>(display), translate<int64_t>(layer), |
| 678 | translate<AidlRect>(damage)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 679 | return Error::NONE; |
| 680 | } |
| 681 | |
| 682 | Error AidlComposer::setLayerBlendMode(Display display, Layer layer, |
| 683 | IComposerClient::BlendMode mode) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 684 | mWriter.setLayerBlendMode(translate<int64_t>(display), translate<int64_t>(layer), |
| 685 | translate<BlendMode>(mode)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 686 | return Error::NONE; |
| 687 | } |
| 688 | |
Ady Abraham | 6e60b14 | 2022-01-06 18:10:35 -0800 | [diff] [blame] | 689 | Error AidlComposer::setLayerColor(Display display, Layer layer, const Color& color) { |
| 690 | mWriter.setLayerColor(translate<int64_t>(display), translate<int64_t>(layer), color); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 691 | return Error::NONE; |
| 692 | } |
| 693 | |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 694 | Error AidlComposer::setLayerCompositionType( |
| 695 | Display display, Layer layer, |
| 696 | aidl::android::hardware::graphics::composer3::Composition type) { |
| 697 | mWriter.setLayerCompositionType(translate<int64_t>(display), translate<int64_t>(layer), type); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 698 | return Error::NONE; |
| 699 | } |
| 700 | |
| 701 | Error AidlComposer::setLayerDataspace(Display display, Layer layer, Dataspace dataspace) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 702 | mWriter.setLayerDataspace(translate<int64_t>(display), translate<int64_t>(layer), |
| 703 | translate<AidlDataspace>(dataspace)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 704 | return Error::NONE; |
| 705 | } |
| 706 | |
| 707 | Error AidlComposer::setLayerDisplayFrame(Display display, Layer layer, |
| 708 | const IComposerClient::Rect& frame) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 709 | mWriter.setLayerDisplayFrame(translate<int64_t>(display), translate<int64_t>(layer), |
| 710 | translate<AidlRect>(frame)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 711 | return Error::NONE; |
| 712 | } |
| 713 | |
| 714 | Error AidlComposer::setLayerPlaneAlpha(Display display, Layer layer, float alpha) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 715 | mWriter.setLayerPlaneAlpha(translate<int64_t>(display), translate<int64_t>(layer), alpha); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 716 | return Error::NONE; |
| 717 | } |
| 718 | |
| 719 | Error AidlComposer::setLayerSidebandStream(Display display, Layer layer, |
| 720 | const native_handle_t* stream) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 721 | mWriter.setLayerSidebandStream(translate<int64_t>(display), translate<int64_t>(layer), stream); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 722 | return Error::NONE; |
| 723 | } |
| 724 | |
| 725 | Error AidlComposer::setLayerSourceCrop(Display display, Layer layer, |
| 726 | const IComposerClient::FRect& crop) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 727 | mWriter.setLayerSourceCrop(translate<int64_t>(display), translate<int64_t>(layer), |
| 728 | translate<AidlFRect>(crop)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 729 | return Error::NONE; |
| 730 | } |
| 731 | |
| 732 | Error AidlComposer::setLayerTransform(Display display, Layer layer, Transform transform) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 733 | mWriter.setLayerTransform(translate<int64_t>(display), translate<int64_t>(layer), |
| 734 | translate<AidlTransform>(transform)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 735 | return Error::NONE; |
| 736 | } |
| 737 | |
| 738 | Error AidlComposer::setLayerVisibleRegion(Display display, Layer layer, |
| 739 | const std::vector<IComposerClient::Rect>& visible) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 740 | mWriter.setLayerVisibleRegion(translate<int64_t>(display), translate<int64_t>(layer), |
| 741 | translate<AidlRect>(visible)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 742 | return Error::NONE; |
| 743 | } |
| 744 | |
| 745 | Error AidlComposer::setLayerZOrder(Display display, Layer layer, uint32_t z) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 746 | mWriter.setLayerZOrder(translate<int64_t>(display), translate<int64_t>(layer), z); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 747 | return Error::NONE; |
| 748 | } |
| 749 | |
| 750 | Error AidlComposer::execute() { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 751 | const auto& commands = mWriter.getPendingCommands(); |
| 752 | if (commands.empty()) { |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 753 | mWriter.reset(); |
| 754 | return Error::NONE; |
| 755 | } |
| 756 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 757 | { // scope for results |
| 758 | std::vector<CommandResultPayload> results; |
| 759 | auto status = mAidlComposerClient->executeCommands(commands, &results); |
| 760 | if (!status.isOk()) { |
| 761 | ALOGE("executeCommands failed %s", status.getDescription().c_str()); |
| 762 | return static_cast<Error>(status.getServiceSpecificError()); |
| 763 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 764 | |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 765 | mReader.parse(std::move(results)); |
| 766 | } |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 767 | const auto commandErrors = mReader.takeErrors(); |
| 768 | Error error = Error::NONE; |
| 769 | for (const auto& cmdErr : commandErrors) { |
| 770 | const auto index = static_cast<size_t>(cmdErr.commandIndex); |
| 771 | if (index < 0 || index >= commands.size()) { |
| 772 | ALOGE("invalid command index %zu", index); |
| 773 | return Error::BAD_PARAMETER; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 774 | } |
| 775 | |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 776 | const auto& command = commands[index]; |
Ady Abraham | 4297736 | 2021-12-07 21:04:49 -0800 | [diff] [blame] | 777 | if (command.validateDisplay || command.presentDisplay || command.presentOrValidateDisplay) { |
| 778 | error = translate<Error>(cmdErr.errorCode); |
| 779 | } else { |
| 780 | ALOGW("command '%s' generated error %" PRId32, command.toString().c_str(), |
| 781 | cmdErr.errorCode); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 782 | } |
| 783 | } |
| 784 | |
| 785 | mWriter.reset(); |
| 786 | |
| 787 | return error; |
| 788 | } |
| 789 | |
| 790 | Error AidlComposer::setLayerPerFrameMetadata( |
| 791 | Display display, Layer layer, |
| 792 | const std::vector<IComposerClient::PerFrameMetadata>& perFrameMetadatas) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 793 | mWriter.setLayerPerFrameMetadata(translate<int64_t>(display), translate<int64_t>(layer), |
| 794 | translate<AidlPerFrameMetadata>(perFrameMetadatas)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 795 | return Error::NONE; |
| 796 | } |
| 797 | |
| 798 | std::vector<IComposerClient::PerFrameMetadataKey> AidlComposer::getPerFrameMetadataKeys( |
| 799 | Display display) { |
| 800 | std::vector<AidlPerFrameMetadataKey> keys; |
| 801 | const auto status = |
| 802 | mAidlComposerClient->getPerFrameMetadataKeys(translate<int64_t>(display), &keys); |
| 803 | if (!status.isOk()) { |
| 804 | ALOGE("getPerFrameMetadataKeys failed %s", status.getDescription().c_str()); |
| 805 | return {}; |
| 806 | } |
| 807 | return translate<IComposerClient::PerFrameMetadataKey>(keys); |
| 808 | } |
| 809 | |
| 810 | Error AidlComposer::getRenderIntents(Display display, ColorMode colorMode, |
| 811 | std::vector<RenderIntent>* outRenderIntents) { |
| 812 | std::vector<AidlRenderIntent> renderIntents; |
| 813 | const auto status = mAidlComposerClient->getRenderIntents(translate<int64_t>(display), |
| 814 | translate<AidlColorMode>(colorMode), |
| 815 | &renderIntents); |
| 816 | if (!status.isOk()) { |
| 817 | ALOGE("getRenderIntents failed %s", status.getDescription().c_str()); |
| 818 | return static_cast<Error>(status.getServiceSpecificError()); |
| 819 | } |
| 820 | *outRenderIntents = translate<RenderIntent>(renderIntents); |
| 821 | return Error::NONE; |
| 822 | } |
| 823 | |
| 824 | Error AidlComposer::getDataspaceSaturationMatrix(Dataspace dataspace, mat4* outMatrix) { |
| 825 | std::vector<float> matrix; |
| 826 | const auto status = |
| 827 | mAidlComposerClient->getDataspaceSaturationMatrix(translate<AidlDataspace>(dataspace), |
| 828 | &matrix); |
| 829 | if (!status.isOk()) { |
| 830 | ALOGE("getDataspaceSaturationMatrix failed %s", status.getDescription().c_str()); |
| 831 | return static_cast<Error>(status.getServiceSpecificError()); |
| 832 | } |
| 833 | *outMatrix = makeMat4(matrix); |
| 834 | return Error::NONE; |
| 835 | } |
| 836 | |
| 837 | Error AidlComposer::getDisplayIdentificationData(Display display, uint8_t* outPort, |
| 838 | std::vector<uint8_t>* outData) { |
| 839 | AidlDisplayIdentification displayIdentification; |
| 840 | const auto status = |
| 841 | mAidlComposerClient->getDisplayIdentificationData(translate<int64_t>(display), |
| 842 | &displayIdentification); |
| 843 | if (!status.isOk()) { |
| 844 | ALOGE("getDisplayIdentificationData failed %s", status.getDescription().c_str()); |
| 845 | return static_cast<Error>(status.getServiceSpecificError()); |
| 846 | } |
| 847 | |
| 848 | *outPort = static_cast<uint8_t>(displayIdentification.port); |
| 849 | *outData = displayIdentification.data; |
| 850 | |
| 851 | return Error::NONE; |
| 852 | } |
| 853 | |
| 854 | Error AidlComposer::setLayerColorTransform(Display display, Layer layer, const float* matrix) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 855 | mWriter.setLayerColorTransform(translate<int64_t>(display), translate<int64_t>(layer), matrix); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 856 | return Error::NONE; |
| 857 | } |
| 858 | |
| 859 | Error AidlComposer::getDisplayedContentSamplingAttributes(Display display, PixelFormat* outFormat, |
| 860 | Dataspace* outDataspace, |
| 861 | uint8_t* outComponentMask) { |
| 862 | if (!outFormat || !outDataspace || !outComponentMask) { |
| 863 | return Error::BAD_PARAMETER; |
| 864 | } |
| 865 | |
| 866 | AidlDisplayContentSamplingAttributes attributes; |
| 867 | const auto status = |
| 868 | mAidlComposerClient->getDisplayedContentSamplingAttributes(translate<int64_t>(display), |
| 869 | &attributes); |
| 870 | if (!status.isOk()) { |
| 871 | ALOGE("getDisplayedContentSamplingAttributes failed %s", status.getDescription().c_str()); |
| 872 | return static_cast<Error>(status.getServiceSpecificError()); |
| 873 | } |
| 874 | |
| 875 | *outFormat = translate<PixelFormat>(attributes.format); |
| 876 | *outDataspace = translate<Dataspace>(attributes.dataspace); |
| 877 | *outComponentMask = static_cast<uint8_t>(attributes.componentMask); |
| 878 | return Error::NONE; |
| 879 | } |
| 880 | |
| 881 | Error AidlComposer::setDisplayContentSamplingEnabled(Display display, bool enabled, |
| 882 | uint8_t componentMask, uint64_t maxFrames) { |
| 883 | const auto status = |
| 884 | mAidlComposerClient |
| 885 | ->setDisplayedContentSamplingEnabled(translate<int64_t>(display), enabled, |
| 886 | static_cast<AidlFormatColorComponent>( |
| 887 | componentMask), |
| 888 | static_cast<int64_t>(maxFrames)); |
| 889 | if (!status.isOk()) { |
| 890 | ALOGE("setDisplayedContentSamplingEnabled failed %s", status.getDescription().c_str()); |
| 891 | return static_cast<Error>(status.getServiceSpecificError()); |
| 892 | } |
| 893 | return Error::NONE; |
| 894 | } |
| 895 | |
| 896 | Error AidlComposer::getDisplayedContentSample(Display display, uint64_t maxFrames, |
| 897 | uint64_t timestamp, DisplayedFrameStats* outStats) { |
| 898 | if (!outStats) { |
| 899 | return Error::BAD_PARAMETER; |
| 900 | } |
| 901 | |
| 902 | AidlDisplayContentSample sample; |
| 903 | const auto status = |
| 904 | mAidlComposerClient->getDisplayedContentSample(translate<int64_t>(display), |
| 905 | static_cast<int64_t>(maxFrames), |
| 906 | static_cast<int64_t>(timestamp), |
| 907 | &sample); |
| 908 | if (!status.isOk()) { |
| 909 | ALOGE("getDisplayedContentSample failed %s", status.getDescription().c_str()); |
| 910 | return static_cast<Error>(status.getServiceSpecificError()); |
| 911 | } |
| 912 | *outStats = translate<DisplayedFrameStats>(sample); |
| 913 | return Error::NONE; |
| 914 | } |
| 915 | |
| 916 | Error AidlComposer::setLayerPerFrameMetadataBlobs( |
| 917 | Display display, Layer layer, |
| 918 | const std::vector<IComposerClient::PerFrameMetadataBlob>& metadata) { |
Ady Abraham | a6388c0 | 2021-11-11 21:11:51 -0800 | [diff] [blame] | 919 | mWriter.setLayerPerFrameMetadataBlobs(translate<int64_t>(display), translate<int64_t>(layer), |
| 920 | translate<AidlPerFrameMetadataBlob>(metadata)); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 921 | return Error::NONE; |
| 922 | } |
| 923 | |
Alec Mouri | cdf1679 | 2021-12-10 13:16:06 -0800 | [diff] [blame] | 924 | Error AidlComposer::setDisplayBrightness(Display display, float brightness, |
| 925 | const DisplayBrightnessOptions& options) { |
Alec Mouri | cdf1679 | 2021-12-10 13:16:06 -0800 | [diff] [blame] | 926 | mWriter.setDisplayBrightness(translate<int64_t>(display), brightness); |
| 927 | |
| 928 | if (options.applyImmediately) { |
| 929 | return execute(); |
| 930 | } |
| 931 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 932 | return Error::NONE; |
| 933 | } |
| 934 | |
| 935 | Error AidlComposer::getDisplayCapabilities(Display display, |
Leon Scroggins III | 5967aec | 2021-12-29 11:14:22 -0500 | [diff] [blame] | 936 | std::vector<AidlDisplayCapability>* outCapabilities) { |
| 937 | const auto status = mAidlComposerClient->getDisplayCapabilities(translate<int64_t>(display), |
| 938 | outCapabilities); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 939 | if (!status.isOk()) { |
| 940 | ALOGE("getDisplayCapabilities failed %s", status.getDescription().c_str()); |
Leon Scroggins III | 5967aec | 2021-12-29 11:14:22 -0500 | [diff] [blame] | 941 | outCapabilities->clear(); |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 942 | return static_cast<Error>(status.getServiceSpecificError()); |
| 943 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 944 | return Error::NONE; |
| 945 | } |
| 946 | |
| 947 | V2_4::Error AidlComposer::getDisplayConnectionType( |
| 948 | Display display, IComposerClient::DisplayConnectionType* outType) { |
| 949 | AidlDisplayConnectionType type; |
| 950 | const auto status = |
| 951 | mAidlComposerClient->getDisplayConnectionType(translate<int64_t>(display), &type); |
| 952 | if (!status.isOk()) { |
| 953 | ALOGE("getDisplayConnectionType failed %s", status.getDescription().c_str()); |
| 954 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 955 | } |
| 956 | *outType = translate<IComposerClient::DisplayConnectionType>(type); |
| 957 | return V2_4::Error::NONE; |
| 958 | } |
| 959 | |
| 960 | V2_4::Error AidlComposer::getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriod) { |
| 961 | int32_t vsyncPeriod; |
| 962 | const auto status = |
| 963 | mAidlComposerClient->getDisplayVsyncPeriod(translate<int64_t>(display), &vsyncPeriod); |
| 964 | if (!status.isOk()) { |
| 965 | ALOGE("getDisplayVsyncPeriod failed %s", status.getDescription().c_str()); |
| 966 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 967 | } |
| 968 | *outVsyncPeriod = translate<VsyncPeriodNanos>(vsyncPeriod); |
| 969 | return V2_4::Error::NONE; |
| 970 | } |
| 971 | |
| 972 | V2_4::Error AidlComposer::setActiveConfigWithConstraints( |
| 973 | Display display, Config config, |
| 974 | const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints, |
| 975 | VsyncPeriodChangeTimeline* outTimeline) { |
| 976 | AidlVsyncPeriodChangeTimeline timeline; |
| 977 | const auto status = |
| 978 | mAidlComposerClient |
| 979 | ->setActiveConfigWithConstraints(translate<int64_t>(display), |
| 980 | translate<int32_t>(config), |
| 981 | translate<AidlVsyncPeriodChangeConstraints>( |
| 982 | vsyncPeriodChangeConstraints), |
| 983 | &timeline); |
| 984 | if (!status.isOk()) { |
| 985 | ALOGE("setActiveConfigWithConstraints failed %s", status.getDescription().c_str()); |
| 986 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 987 | } |
| 988 | *outTimeline = translate<VsyncPeriodChangeTimeline>(timeline); |
| 989 | return V2_4::Error::NONE; |
| 990 | } |
| 991 | |
| 992 | V2_4::Error AidlComposer::setAutoLowLatencyMode(Display display, bool on) { |
| 993 | const auto status = mAidlComposerClient->setAutoLowLatencyMode(translate<int64_t>(display), on); |
| 994 | if (!status.isOk()) { |
| 995 | ALOGE("setAutoLowLatencyMode failed %s", status.getDescription().c_str()); |
| 996 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 997 | } |
| 998 | return V2_4::Error::NONE; |
| 999 | } |
| 1000 | |
| 1001 | V2_4::Error AidlComposer::getSupportedContentTypes( |
| 1002 | Display displayId, std::vector<IComposerClient::ContentType>* outSupportedContentTypes) { |
| 1003 | std::vector<AidlContentType> types; |
| 1004 | const auto status = |
| 1005 | mAidlComposerClient->getSupportedContentTypes(translate<int64_t>(displayId), &types); |
| 1006 | if (!status.isOk()) { |
| 1007 | ALOGE("getSupportedContentTypes failed %s", status.getDescription().c_str()); |
| 1008 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 1009 | } |
| 1010 | *outSupportedContentTypes = translate<IComposerClient::ContentType>(types); |
| 1011 | return V2_4::Error::NONE; |
| 1012 | } |
| 1013 | |
| 1014 | V2_4::Error AidlComposer::setContentType(Display display, |
| 1015 | IComposerClient::ContentType contentType) { |
| 1016 | const auto status = |
| 1017 | mAidlComposerClient->setContentType(translate<int64_t>(display), |
| 1018 | translate<AidlContentType>(contentType)); |
| 1019 | if (!status.isOk()) { |
| 1020 | ALOGE("setContentType failed %s", status.getDescription().c_str()); |
| 1021 | return static_cast<V2_4::Error>(status.getServiceSpecificError()); |
| 1022 | } |
| 1023 | return V2_4::Error::NONE; |
| 1024 | } |
| 1025 | |
Ady Abraham | 3f97675 | 2021-12-20 16:17:50 -0800 | [diff] [blame] | 1026 | V2_4::Error AidlComposer::setLayerGenericMetadata(Display, Layer, const std::string&, bool, |
| 1027 | const std::vector<uint8_t>&) { |
| 1028 | // There are no users for this API. See b/209691612. |
| 1029 | return V2_4::Error::UNSUPPORTED; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1030 | } |
| 1031 | |
| 1032 | V2_4::Error AidlComposer::getLayerGenericMetadataKeys( |
Ady Abraham | 3f97675 | 2021-12-20 16:17:50 -0800 | [diff] [blame] | 1033 | std::vector<IComposerClient::LayerGenericMetadataKey>*) { |
| 1034 | // There are no users for this API. See b/209691612. |
| 1035 | return V2_4::Error::UNSUPPORTED; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1036 | } |
| 1037 | |
Kriti Dang | 7defaf3 | 2021-11-15 11:55:43 +0100 | [diff] [blame] | 1038 | Error AidlComposer::setBootDisplayConfig(Display display, Config config) { |
| 1039 | const auto status = mAidlComposerClient->setBootDisplayConfig(translate<int64_t>(display), |
| 1040 | translate<int32_t>(config)); |
| 1041 | if (!status.isOk()) { |
| 1042 | ALOGE("setBootDisplayConfig failed %s", status.getDescription().c_str()); |
| 1043 | return static_cast<Error>(status.getServiceSpecificError()); |
| 1044 | } |
| 1045 | return Error::NONE; |
| 1046 | } |
| 1047 | |
| 1048 | Error AidlComposer::clearBootDisplayConfig(Display display) { |
| 1049 | const auto status = mAidlComposerClient->clearBootDisplayConfig(translate<int64_t>(display)); |
| 1050 | if (!status.isOk()) { |
| 1051 | ALOGE("clearBootDisplayConfig failed %s", status.getDescription().c_str()); |
| 1052 | return static_cast<Error>(status.getServiceSpecificError()); |
| 1053 | } |
| 1054 | return Error::NONE; |
| 1055 | } |
| 1056 | |
| 1057 | Error AidlComposer::getPreferredBootDisplayConfig(Display display, Config* config) { |
| 1058 | int32_t displayConfig; |
| 1059 | const auto status = |
| 1060 | mAidlComposerClient->getPreferredBootDisplayConfig(translate<int64_t>(display), |
| 1061 | &displayConfig); |
| 1062 | if (!status.isOk()) { |
| 1063 | ALOGE("getPreferredBootDisplayConfig failed %s", status.getDescription().c_str()); |
| 1064 | return static_cast<Error>(status.getServiceSpecificError()); |
| 1065 | } |
| 1066 | *config = translate<uint32_t>(displayConfig); |
| 1067 | return Error::NONE; |
| 1068 | } |
| 1069 | |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1070 | Error AidlComposer::getClientTargetProperty( |
Alec Mouri | cdf6cbc | 2021-11-01 17:21:15 -0700 | [diff] [blame] | 1071 | Display display, IComposerClient::ClientTargetProperty* outClientTargetProperty, |
| 1072 | float* whitePointNits) { |
Ady Abraham | de79278 | 2021-12-20 10:00:49 -0800 | [diff] [blame] | 1073 | const auto property = mReader.takeClientTargetProperty(translate<int64_t>(display)); |
| 1074 | *outClientTargetProperty = |
| 1075 | translate<IComposerClient::ClientTargetProperty>(property.clientTargetProperty); |
| 1076 | *whitePointNits = property.whitePointNits; |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1077 | return Error::NONE; |
| 1078 | } |
| 1079 | |
Alec Mouri | 6da0e27 | 2022-02-07 12:45:57 -0800 | [diff] [blame] | 1080 | Error AidlComposer::setLayerBrightness(Display display, Layer layer, float brightness) { |
| 1081 | mWriter.setLayerBrightness(translate<int64_t>(display), translate<int64_t>(layer), brightness); |
Alec Mouri | cdf6cbc | 2021-11-01 17:21:15 -0700 | [diff] [blame] | 1082 | return Error::NONE; |
| 1083 | } |
| 1084 | |
Leon Scroggins III | d77d316 | 2022-01-05 10:42:28 -0500 | [diff] [blame] | 1085 | Error AidlComposer::setLayerBlockingRegion(Display display, Layer layer, |
| 1086 | const std::vector<IComposerClient::Rect>& blocking) { |
| 1087 | mWriter.setLayerBlockingRegion(translate<int64_t>(display), translate<int64_t>(layer), |
| 1088 | translate<AidlRect>(blocking)); |
| 1089 | return Error::NONE; |
| 1090 | } |
Leon Scroggins III | e7c51c6 | 2022-02-01 15:53:54 -0500 | [diff] [blame] | 1091 | |
| 1092 | Error AidlComposer::getDisplayDecorationSupport(Display display, |
| 1093 | std::optional<DisplayDecorationSupport>* support) { |
| 1094 | const auto status = |
| 1095 | mAidlComposerClient->getDisplayDecorationSupport(translate<int64_t>(display), support); |
| 1096 | if (!status.isOk()) { |
| 1097 | ALOGE("getDisplayDecorationSupport failed %s", status.getDescription().c_str()); |
| 1098 | support->reset(); |
| 1099 | return static_cast<Error>(status.getServiceSpecificError()); |
| 1100 | } |
| 1101 | return Error::NONE; |
| 1102 | } |
Ady Abraham | e7385f7 | 2021-09-05 00:54:25 -0700 | [diff] [blame] | 1103 | } // namespace Hwc2 |
| 1104 | } // namespace android |