Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 17 | #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 18 | #include <android/native_window.h> |
| 19 | #include <android/surface_control.h> |
| 20 | |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 21 | #include <configstore/Utils.h> |
| 22 | |
| 23 | #include <gui/HdrMetadata.h> |
| 24 | #include <gui/ISurfaceComposer.h> |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 25 | #include <gui/Surface.h> |
| 26 | #include <gui/SurfaceComposerClient.h> |
| 27 | #include <gui/SurfaceControl.h> |
| 28 | |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 29 | #include <ui/HdrCapabilities.h> |
| 30 | |
| 31 | #include <utils/Timers.h> |
| 32 | |
| 33 | using namespace android::hardware::configstore; |
| 34 | using namespace android::hardware::configstore::V1_0; |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 35 | using namespace android; |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 36 | using android::hardware::configstore::V1_0::ISurfaceFlingerConfigs; |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 37 | |
| 38 | using Transaction = SurfaceComposerClient::Transaction; |
| 39 | |
| 40 | #define CHECK_NOT_NULL(name) \ |
| 41 | LOG_ALWAYS_FATAL_IF(name == nullptr, "nullptr passed as " #name " argument"); |
| 42 | |
| 43 | #define CHECK_VALID_RECT(name) \ |
| 44 | LOG_ALWAYS_FATAL_IF(!static_cast<const Rect&>(name).isValid(), \ |
| 45 | "invalid arg passed as " #name " argument"); |
| 46 | |
| 47 | Transaction* ASurfaceTransaction_to_Transaction(ASurfaceTransaction* aSurfaceTransaction) { |
| 48 | return reinterpret_cast<Transaction*>(aSurfaceTransaction); |
| 49 | } |
| 50 | |
| 51 | SurfaceControl* ASurfaceControl_to_SurfaceControl(ASurfaceControl* aSurfaceControl) { |
| 52 | return reinterpret_cast<SurfaceControl*>(aSurfaceControl); |
| 53 | } |
| 54 | |
| 55 | void SurfaceControl_acquire(SurfaceControl* surfaceControl) { |
| 56 | // incStrong/decStrong token must be the same, doesn't matter what it is |
| 57 | surfaceControl->incStrong((void*)SurfaceControl_acquire); |
| 58 | } |
| 59 | |
| 60 | void SurfaceControl_release(SurfaceControl* surfaceControl) { |
| 61 | // incStrong/decStrong token must be the same, doesn't matter what it is |
| 62 | surfaceControl->decStrong((void*)SurfaceControl_acquire); |
| 63 | } |
| 64 | |
| 65 | ASurfaceControl* ASurfaceControl_createFromWindow(ANativeWindow* window, const char* debug_name) { |
| 66 | CHECK_NOT_NULL(window); |
| 67 | CHECK_NOT_NULL(debug_name); |
| 68 | |
| 69 | sp<SurfaceComposerClient> client = new SurfaceComposerClient(); |
| 70 | if (client->initCheck() != NO_ERROR) { |
| 71 | return nullptr; |
| 72 | } |
| 73 | |
| 74 | uint32_t flags = ISurfaceComposerClient::eFXSurfaceBufferState; |
| 75 | sp<SurfaceControl> surfaceControl = |
| 76 | client->createWithSurfaceParent(String8(debug_name), 0 /* width */, 0 /* height */, |
| 77 | // Format is only relevant for buffer queue layers. |
| 78 | PIXEL_FORMAT_UNKNOWN /* format */, flags, |
| 79 | static_cast<Surface*>(window)); |
| 80 | if (!surfaceControl) { |
| 81 | return nullptr; |
| 82 | } |
| 83 | |
| 84 | SurfaceControl_acquire(surfaceControl.get()); |
| 85 | return reinterpret_cast<ASurfaceControl*>(surfaceControl.get()); |
| 86 | } |
| 87 | |
| 88 | ASurfaceControl* ASurfaceControl_create(ASurfaceControl* parent, const char* debug_name) { |
| 89 | CHECK_NOT_NULL(parent); |
| 90 | CHECK_NOT_NULL(debug_name); |
| 91 | |
| 92 | SurfaceComposerClient* client = ASurfaceControl_to_SurfaceControl(parent)->getClient().get(); |
| 93 | |
| 94 | SurfaceControl* surfaceControlParent = ASurfaceControl_to_SurfaceControl(parent); |
| 95 | |
| 96 | uint32_t flags = ISurfaceComposerClient::eFXSurfaceBufferState; |
| 97 | sp<SurfaceControl> surfaceControl = |
| 98 | client->createSurface(String8(debug_name), 0 /* width */, 0 /* height */, |
| 99 | // Format is only relevant for buffer queue layers. |
| 100 | PIXEL_FORMAT_UNKNOWN /* format */, flags, |
| 101 | surfaceControlParent); |
| 102 | if (!surfaceControl) { |
| 103 | return nullptr; |
| 104 | } |
| 105 | |
| 106 | SurfaceControl_acquire(surfaceControl.get()); |
| 107 | return reinterpret_cast<ASurfaceControl*>(surfaceControl.get()); |
| 108 | } |
| 109 | |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 110 | void ASurfaceControl_release(ASurfaceControl* aSurfaceControl) { |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 111 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 112 | |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 113 | SurfaceControl_release(surfaceControl.get()); |
| 114 | } |
| 115 | |
| 116 | ASurfaceTransaction* ASurfaceTransaction_create() { |
| 117 | Transaction* transaction = new Transaction; |
| 118 | return reinterpret_cast<ASurfaceTransaction*>(transaction); |
| 119 | } |
| 120 | |
| 121 | void ASurfaceTransaction_delete(ASurfaceTransaction* aSurfaceTransaction) { |
| 122 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 123 | delete transaction; |
| 124 | } |
| 125 | |
| 126 | void ASurfaceTransaction_apply(ASurfaceTransaction* aSurfaceTransaction) { |
| 127 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 128 | |
| 129 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 130 | |
| 131 | transaction->apply(); |
| 132 | } |
| 133 | |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 134 | typedef struct ASurfaceControlStats { |
| 135 | int64_t acquireTime; |
| 136 | sp<Fence> previousReleaseFence; |
| 137 | } ASurfaceControlStats; |
| 138 | |
| 139 | struct ASurfaceTransactionStats { |
| 140 | std::unordered_map<ASurfaceControl*, ASurfaceControlStats> aSurfaceControlStats; |
| 141 | int64_t latchTime; |
| 142 | sp<Fence> presentFence; |
| 143 | }; |
| 144 | |
| 145 | int64_t ASurfaceTransactionStats_getLatchTime(ASurfaceTransactionStats* aSurfaceTransactionStats) { |
| 146 | CHECK_NOT_NULL(aSurfaceTransactionStats); |
| 147 | return aSurfaceTransactionStats->latchTime; |
| 148 | } |
| 149 | |
| 150 | int ASurfaceTransactionStats_getPresentFenceFd(ASurfaceTransactionStats* aSurfaceTransactionStats) { |
| 151 | CHECK_NOT_NULL(aSurfaceTransactionStats); |
| 152 | auto& presentFence = aSurfaceTransactionStats->presentFence; |
| 153 | return (presentFence) ? presentFence->dup() : -1; |
| 154 | } |
| 155 | |
| 156 | void ASurfaceTransactionStats_getASurfaceControls(ASurfaceTransactionStats* aSurfaceTransactionStats, |
| 157 | ASurfaceControl*** outASurfaceControls, |
| 158 | size_t* outASurfaceControlsSize) { |
| 159 | CHECK_NOT_NULL(aSurfaceTransactionStats); |
| 160 | CHECK_NOT_NULL(outASurfaceControls); |
| 161 | CHECK_NOT_NULL(outASurfaceControlsSize); |
| 162 | |
| 163 | size_t size = aSurfaceTransactionStats->aSurfaceControlStats.size(); |
| 164 | |
| 165 | SurfaceControl** surfaceControls = new SurfaceControl*[size]; |
| 166 | ASurfaceControl** aSurfaceControls = reinterpret_cast<ASurfaceControl**>(surfaceControls); |
| 167 | |
| 168 | size_t i = 0; |
| 169 | for (auto& [aSurfaceControl, aSurfaceControlStats] : aSurfaceTransactionStats->aSurfaceControlStats) { |
| 170 | aSurfaceControls[i] = aSurfaceControl; |
| 171 | i++; |
| 172 | } |
| 173 | |
| 174 | *outASurfaceControls = aSurfaceControls; |
| 175 | *outASurfaceControlsSize = size; |
| 176 | } |
| 177 | |
| 178 | int64_t ASurfaceTransactionStats_getAcquireTime(ASurfaceTransactionStats* aSurfaceTransactionStats, |
| 179 | ASurfaceControl* aSurfaceControl) { |
| 180 | CHECK_NOT_NULL(aSurfaceTransactionStats); |
| 181 | CHECK_NOT_NULL(aSurfaceControl); |
| 182 | |
| 183 | const auto& aSurfaceControlStats = |
| 184 | aSurfaceTransactionStats->aSurfaceControlStats.find(aSurfaceControl); |
| 185 | LOG_ALWAYS_FATAL_IF( |
| 186 | aSurfaceControlStats == aSurfaceTransactionStats->aSurfaceControlStats.end(), |
| 187 | "ASurfaceControl not found"); |
| 188 | |
| 189 | return aSurfaceControlStats->second.acquireTime; |
| 190 | } |
| 191 | |
| 192 | int ASurfaceTransactionStats_getPreviousReleaseFenceFd( |
| 193 | ASurfaceTransactionStats* aSurfaceTransactionStats, ASurfaceControl* aSurfaceControl) { |
| 194 | CHECK_NOT_NULL(aSurfaceTransactionStats); |
| 195 | CHECK_NOT_NULL(aSurfaceControl); |
| 196 | |
| 197 | const auto& aSurfaceControlStats = |
| 198 | aSurfaceTransactionStats->aSurfaceControlStats.find(aSurfaceControl); |
| 199 | LOG_ALWAYS_FATAL_IF( |
| 200 | aSurfaceControlStats == aSurfaceTransactionStats->aSurfaceControlStats.end(), |
| 201 | "ASurfaceControl not found"); |
| 202 | |
| 203 | auto& previousReleaseFence = aSurfaceControlStats->second.previousReleaseFence; |
| 204 | return (previousReleaseFence) ? previousReleaseFence->dup() : -1; |
| 205 | } |
| 206 | |
| 207 | void ASurfaceTransactionStats_releaseASurfaceControls(ASurfaceControl** aSurfaceControls) { |
| 208 | CHECK_NOT_NULL(aSurfaceControls); |
| 209 | |
| 210 | SurfaceControl** surfaceControls = reinterpret_cast<SurfaceControl**>(aSurfaceControls); |
| 211 | delete[] surfaceControls; |
| 212 | } |
| 213 | |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 214 | void ASurfaceTransaction_setOnComplete(ASurfaceTransaction* aSurfaceTransaction, void* context, |
| 215 | ASurfaceTransaction_OnComplete func) { |
| 216 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 217 | CHECK_NOT_NULL(context); |
| 218 | CHECK_NOT_NULL(func); |
| 219 | |
| 220 | TransactionCompletedCallbackTakesContext callback = [func](void* callback_context, |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 221 | nsecs_t latchTime, |
| 222 | const sp<Fence>& presentFence, |
| 223 | const std::vector<SurfaceControlStats>& surfaceControlStats) { |
| 224 | ASurfaceTransactionStats aSurfaceTransactionStats; |
| 225 | |
| 226 | aSurfaceTransactionStats.latchTime = latchTime; |
| 227 | aSurfaceTransactionStats.presentFence = presentFence; |
| 228 | |
| 229 | auto& aSurfaceControlStats = aSurfaceTransactionStats.aSurfaceControlStats; |
| 230 | |
| 231 | for (const auto& [surfaceControl, acquireTime, previousReleaseFence] : surfaceControlStats) { |
| 232 | ASurfaceControl* aSurfaceControl = reinterpret_cast<ASurfaceControl*>(surfaceControl.get()); |
| 233 | aSurfaceControlStats[aSurfaceControl].acquireTime = acquireTime; |
| 234 | aSurfaceControlStats[aSurfaceControl].previousReleaseFence = previousReleaseFence; |
| 235 | } |
| 236 | |
| 237 | (*func)(callback_context, &aSurfaceTransactionStats); |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 238 | }; |
| 239 | |
| 240 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 241 | |
| 242 | transaction->addTransactionCompletedCallback(callback, context); |
| 243 | } |
| 244 | |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 245 | void ASurfaceTransaction_reparent(ASurfaceTransaction* aSurfaceTransaction, |
| 246 | ASurfaceControl* aSurfaceControl, |
| 247 | ASurfaceControl* newParentASurfaceControl) { |
| 248 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 249 | CHECK_NOT_NULL(aSurfaceControl); |
| 250 | |
| 251 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 252 | sp<SurfaceControl> newParentSurfaceControl = ASurfaceControl_to_SurfaceControl( |
| 253 | newParentASurfaceControl); |
| 254 | sp<IBinder> newParentHandle = (newParentSurfaceControl)? newParentSurfaceControl->getHandle() : nullptr; |
| 255 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 256 | |
| 257 | transaction->reparent(surfaceControl, newParentHandle); |
| 258 | } |
| 259 | |
| 260 | void ASurfaceTransaction_setVisibility(ASurfaceTransaction* aSurfaceTransaction, |
| 261 | ASurfaceControl* aSurfaceControl, |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 262 | int8_t visibility) { |
| 263 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 264 | CHECK_NOT_NULL(aSurfaceControl); |
| 265 | |
| 266 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 267 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 268 | |
| 269 | switch (visibility) { |
| 270 | case ASURFACE_TRANSACTION_VISIBILITY_SHOW: |
| 271 | transaction->show(surfaceControl); |
| 272 | break; |
| 273 | case ASURFACE_TRANSACTION_VISIBILITY_HIDE: |
| 274 | transaction->hide(surfaceControl); |
| 275 | break; |
| 276 | default: |
| 277 | LOG_ALWAYS_FATAL("invalid visibility %d", visibility); |
| 278 | } |
| 279 | } |
| 280 | |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 281 | void ASurfaceTransaction_setZOrder(ASurfaceTransaction* aSurfaceTransaction, |
| 282 | ASurfaceControl* aSurfaceControl, |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 283 | int32_t z_order) { |
| 284 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 285 | CHECK_NOT_NULL(aSurfaceControl); |
| 286 | |
| 287 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 288 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 289 | |
| 290 | transaction->setLayer(surfaceControl, z_order); |
| 291 | } |
| 292 | |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 293 | void ASurfaceTransaction_setBuffer(ASurfaceTransaction* aSurfaceTransaction, |
| 294 | ASurfaceControl* aSurfaceControl, |
| 295 | AHardwareBuffer* buffer, int acquire_fence_fd) { |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 296 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 297 | CHECK_NOT_NULL(aSurfaceControl); |
| 298 | |
| 299 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 300 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 301 | |
| 302 | sp<GraphicBuffer> graphic_buffer(reinterpret_cast<GraphicBuffer*>(buffer)); |
| 303 | |
| 304 | transaction->setBuffer(surfaceControl, graphic_buffer); |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 305 | if (acquire_fence_fd != -1) { |
| 306 | sp<Fence> fence = new Fence(acquire_fence_fd); |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 307 | transaction->setAcquireFence(surfaceControl, fence); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | void ASurfaceTransaction_setGeometry(ASurfaceTransaction* aSurfaceTransaction, |
| 312 | ASurfaceControl* aSurfaceControl, const ARect& source, |
| 313 | const ARect& destination, int32_t transform) { |
| 314 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 315 | CHECK_NOT_NULL(aSurfaceControl); |
| 316 | CHECK_VALID_RECT(source); |
| 317 | CHECK_VALID_RECT(destination); |
| 318 | |
| 319 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 320 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 321 | |
| 322 | transaction->setCrop(surfaceControl, static_cast<const Rect&>(source)); |
| 323 | transaction->setFrame(surfaceControl, static_cast<const Rect&>(destination)); |
| 324 | transaction->setTransform(surfaceControl, transform); |
| 325 | } |
| 326 | |
| 327 | void ASurfaceTransaction_setBufferTransparency(ASurfaceTransaction* aSurfaceTransaction, |
| 328 | ASurfaceControl* aSurfaceControl, |
| 329 | int8_t transparency) { |
| 330 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 331 | CHECK_NOT_NULL(aSurfaceControl); |
| 332 | |
| 333 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 334 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 335 | |
| 336 | uint32_t flags = (transparency == ASURFACE_TRANSACTION_TRANSPARENCY_OPAQUE) ? |
| 337 | layer_state_t::eLayerOpaque : 0; |
| 338 | transaction->setFlags(surfaceControl, flags, layer_state_t::eLayerOpaque); |
| 339 | } |
| 340 | |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 341 | void ASurfaceTransaction_setDamageRegion(ASurfaceTransaction* aSurfaceTransaction, |
| 342 | ASurfaceControl* aSurfaceControl, |
Marissa Wall | f6a73fa | 2018-12-10 10:41:08 -0800 | [diff] [blame] | 343 | const ARect rects[], uint32_t count) { |
| 344 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 345 | CHECK_NOT_NULL(aSurfaceControl); |
| 346 | |
| 347 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 348 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 349 | |
| 350 | Region region; |
| 351 | for (uint32_t i = 0; i < count; ++i) { |
| 352 | region.merge(static_cast<const Rect&>(rects[i])); |
| 353 | } |
| 354 | |
| 355 | transaction->setSurfaceDamageRegion(surfaceControl, region); |
| 356 | } |
Marissa Wall | 1be5a10 | 2019-01-18 16:14:04 -0800 | [diff] [blame^] | 357 | |
| 358 | void ASurfaceTransaction_setDesiredPresentTime(ASurfaceTransaction* aSurfaceTransaction, |
| 359 | int64_t desiredPresentTime) { |
| 360 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 361 | |
| 362 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 363 | |
| 364 | transaction->setDesiredPresentTime(static_cast<nsecs_t>(desiredPresentTime)); |
| 365 | } |
| 366 | |
| 367 | void ASurfaceTransaction_setBufferAlpha(ASurfaceTransaction* aSurfaceTransaction, |
| 368 | ASurfaceControl* aSurfaceControl, |
| 369 | float alpha) { |
| 370 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 371 | CHECK_NOT_NULL(aSurfaceControl); |
| 372 | |
| 373 | LOG_ALWAYS_FATAL_IF(alpha < 0.0 || alpha > 1.0, "invalid alpha"); |
| 374 | |
| 375 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 376 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 377 | |
| 378 | transaction->setAlpha(surfaceControl, alpha); |
| 379 | } |
| 380 | |
| 381 | void ASurfaceTransaction_setHdrMetadata_smpte2086(ASurfaceTransaction* aSurfaceTransaction, |
| 382 | ASurfaceControl* aSurfaceControl, |
| 383 | struct AHdrMetadata_smpte2086* metadata) { |
| 384 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 385 | CHECK_NOT_NULL(aSurfaceControl); |
| 386 | |
| 387 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 388 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 389 | |
| 390 | HdrMetadata hdrMetadata; |
| 391 | |
| 392 | if (metadata) { |
| 393 | hdrMetadata.smpte2086.displayPrimaryRed.x = metadata->displayPrimaryRed.x; |
| 394 | hdrMetadata.smpte2086.displayPrimaryRed.y = metadata->displayPrimaryRed.y; |
| 395 | hdrMetadata.smpte2086.displayPrimaryGreen.x = metadata->displayPrimaryGreen.x; |
| 396 | hdrMetadata.smpte2086.displayPrimaryGreen.y = metadata->displayPrimaryGreen.y; |
| 397 | hdrMetadata.smpte2086.displayPrimaryBlue.x = metadata->displayPrimaryBlue.x; |
| 398 | hdrMetadata.smpte2086.displayPrimaryBlue.y = metadata->displayPrimaryBlue.y; |
| 399 | hdrMetadata.smpte2086.whitePoint.x = metadata->whitePoint.x; |
| 400 | hdrMetadata.smpte2086.whitePoint.y = metadata->whitePoint.y; |
| 401 | hdrMetadata.smpte2086.minLuminance = metadata->minLuminance; |
| 402 | hdrMetadata.smpte2086.maxLuminance = metadata->maxLuminance; |
| 403 | |
| 404 | hdrMetadata.validTypes |= HdrMetadata::SMPTE2086; |
| 405 | } else { |
| 406 | hdrMetadata.validTypes &= ~HdrMetadata::SMPTE2086; |
| 407 | } |
| 408 | |
| 409 | transaction->setHdrMetadata(surfaceControl, hdrMetadata); |
| 410 | } |
| 411 | |
| 412 | void ASurfaceTransaction_setHdrMetadata_cta861_3(ASurfaceTransaction* aSurfaceTransaction, |
| 413 | ASurfaceControl* aSurfaceControl, |
| 414 | struct AHdrMetadata_cta861_3* metadata) { |
| 415 | CHECK_NOT_NULL(aSurfaceTransaction); |
| 416 | CHECK_NOT_NULL(aSurfaceControl); |
| 417 | |
| 418 | sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); |
| 419 | Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); |
| 420 | |
| 421 | HdrMetadata hdrMetadata; |
| 422 | |
| 423 | if (metadata) { |
| 424 | hdrMetadata.cta8613.maxContentLightLevel = metadata->maxContentLightLevel; |
| 425 | hdrMetadata.cta8613.maxFrameAverageLightLevel = metadata->maxFrameAverageLightLevel; |
| 426 | |
| 427 | hdrMetadata.validTypes |= HdrMetadata::CTA861_3; |
| 428 | } else { |
| 429 | hdrMetadata.validTypes &= ~HdrMetadata::CTA861_3; |
| 430 | } |
| 431 | |
| 432 | transaction->setHdrMetadata(surfaceControl, hdrMetadata); |
| 433 | } |