1 /* 2 * Copyright 2016 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 #ifndef ANDROID_SF_COMPOSER_HAL_H 18 #define ANDROID_SF_COMPOSER_HAL_H 19 20 #include <memory> 21 #include <string> 22 #include <unordered_map> 23 #include <utility> 24 #include <vector> 25 26 // TODO(b/129481165): remove the #pragma below and fix conversion issues 27 #pragma clang diagnostic push 28 #pragma clang diagnostic ignored "-Wconversion" 29 30 #if defined(USE_VR_COMPOSER) && USE_VR_COMPOSER 31 #include <android/frameworks/vr/composer/2.0/IVrComposerClient.h> 32 #endif // defined(USE_VR_COMPOSER) && USE_VR_COMPOSER 33 #include <android/hardware/graphics/common/1.1/types.h> 34 #include <android/hardware/graphics/composer/2.4/IComposer.h> 35 #include <android/hardware/graphics/composer/2.4/IComposerClient.h> 36 #include <composer-command-buffer/2.4/ComposerCommandBuffer.h> 37 #include <gui/HdrMetadata.h> 38 #include <math/mat4.h> 39 #include <ui/DisplayedFrameStats.h> 40 #include <ui/GraphicBuffer.h> 41 #include <utils/StrongPointer.h> 42 43 // TODO(b/129481165): remove the #pragma below and fix conversion issues 44 #pragma clang diagnostic pop // ignored "-Wconversion" 45 46 namespace android { 47 48 namespace Hwc2 { 49 50 #if defined(USE_VR_COMPOSER) && USE_VR_COMPOSER 51 using frameworks::vr::composer::V2_0::IVrComposerClient; 52 #endif // defined(USE_VR_COMPOSER) && USE_VR_COMPOSER 53 54 namespace types = hardware::graphics::common; 55 56 namespace V2_1 = hardware::graphics::composer::V2_1; 57 namespace V2_2 = hardware::graphics::composer::V2_2; 58 namespace V2_3 = hardware::graphics::composer::V2_3; 59 namespace V2_4 = hardware::graphics::composer::V2_4; 60 61 using types::V1_0::ColorTransform; 62 using types::V1_0::Transform; 63 using types::V1_1::RenderIntent; 64 using types::V1_2::ColorMode; 65 using types::V1_2::Dataspace; 66 using types::V1_2::Hdr; 67 using types::V1_2::PixelFormat; 68 69 using V2_1::Config; 70 using V2_1::Display; 71 using V2_1::Error; 72 using V2_1::Layer; 73 using V2_4::CommandReaderBase; 74 using V2_4::CommandWriterBase; 75 using V2_4::IComposer; 76 using V2_4::IComposerCallback; 77 using V2_4::IComposerClient; 78 using V2_4::VsyncPeriodChangeTimeline; 79 using V2_4::VsyncPeriodNanos; 80 using DisplayCapability = IComposerClient::DisplayCapability; 81 using PerFrameMetadata = IComposerClient::PerFrameMetadata; 82 using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey; 83 using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob; 84 85 class Composer { 86 public: 87 virtual ~Composer() = 0; 88 89 virtual std::vector<IComposer::Capability> getCapabilities() = 0; 90 virtual std::string dumpDebugInfo() = 0; 91 92 virtual void registerCallback(const sp<IComposerCallback>& callback) = 0; 93 94 // Returns true if the connected composer service is running in a remote 95 // process, false otherwise. This will return false if the service is 96 // configured in passthrough mode, for example. 97 virtual bool isRemote() = 0; 98 99 // Reset all pending commands in the command buffer. Useful if you want to 100 // skip a frame but have already queued some commands. 101 virtual void resetCommands() = 0; 102 103 // Explicitly flush all pending commands in the command buffer. 104 virtual Error executeCommands() = 0; 105 106 virtual uint32_t getMaxVirtualDisplayCount() = 0; 107 virtual bool isUsingVrComposer() const = 0; 108 virtual Error createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat* format, 109 Display* outDisplay) = 0; 110 virtual Error destroyVirtualDisplay(Display display) = 0; 111 112 virtual Error acceptDisplayChanges(Display display) = 0; 113 114 virtual Error createLayer(Display display, Layer* outLayer) = 0; 115 virtual Error destroyLayer(Display display, Layer layer) = 0; 116 117 virtual Error getActiveConfig(Display display, Config* outConfig) = 0; 118 virtual Error getChangedCompositionTypes( 119 Display display, std::vector<Layer>* outLayers, 120 std::vector<IComposerClient::Composition>* outTypes) = 0; 121 virtual Error getColorModes(Display display, std::vector<ColorMode>* outModes) = 0; 122 virtual Error getDisplayAttribute(Display display, Config config, 123 IComposerClient::Attribute attribute, int32_t* outValue) = 0; 124 virtual Error getDisplayConfigs(Display display, std::vector<Config>* outConfigs) = 0; 125 virtual Error getDisplayName(Display display, std::string* outName) = 0; 126 127 virtual Error getDisplayRequests(Display display, uint32_t* outDisplayRequestMask, 128 std::vector<Layer>* outLayers, 129 std::vector<uint32_t>* outLayerRequestMasks) = 0; 130 131 virtual Error getDozeSupport(Display display, bool* outSupport) = 0; 132 virtual Error getHdrCapabilities(Display display, std::vector<Hdr>* outTypes, 133 float* outMaxLuminance, float* outMaxAverageLuminance, 134 float* outMinLuminance) = 0; 135 136 virtual Error getReleaseFences(Display display, std::vector<Layer>* outLayers, 137 std::vector<int>* outReleaseFences) = 0; 138 139 virtual Error presentDisplay(Display display, int* outPresentFence) = 0; 140 141 virtual Error setActiveConfig(Display display, Config config) = 0; 142 143 /* 144 * The composer caches client targets internally. When target is nullptr, 145 * the composer uses slot to look up the client target from its cache. 146 * When target is not nullptr, the cache is updated with the new target. 147 */ 148 virtual Error setClientTarget(Display display, uint32_t slot, const sp<GraphicBuffer>& target, 149 int acquireFence, Dataspace dataspace, 150 const std::vector<IComposerClient::Rect>& damage) = 0; 151 virtual Error setColorMode(Display display, ColorMode mode, RenderIntent renderIntent) = 0; 152 virtual Error setColorTransform(Display display, const float* matrix, ColorTransform hint) = 0; 153 virtual Error setOutputBuffer(Display display, const native_handle_t* buffer, 154 int releaseFence) = 0; 155 virtual Error setPowerMode(Display display, IComposerClient::PowerMode mode) = 0; 156 virtual Error setVsyncEnabled(Display display, IComposerClient::Vsync enabled) = 0; 157 158 virtual Error setClientTargetSlotCount(Display display) = 0; 159 160 virtual Error validateDisplay(Display display, uint32_t* outNumTypes, 161 uint32_t* outNumRequests) = 0; 162 163 virtual Error presentOrValidateDisplay(Display display, uint32_t* outNumTypes, 164 uint32_t* outNumRequests, int* outPresentFence, 165 uint32_t* state) = 0; 166 167 virtual Error setCursorPosition(Display display, Layer layer, int32_t x, int32_t y) = 0; 168 /* see setClientTarget for the purpose of slot */ 169 virtual Error setLayerBuffer(Display display, Layer layer, uint32_t slot, 170 const sp<GraphicBuffer>& buffer, int acquireFence) = 0; 171 virtual Error setLayerSurfaceDamage(Display display, Layer layer, 172 const std::vector<IComposerClient::Rect>& damage) = 0; 173 virtual Error setLayerBlendMode(Display display, Layer layer, 174 IComposerClient::BlendMode mode) = 0; 175 virtual Error setLayerColor(Display display, Layer layer, 176 const IComposerClient::Color& color) = 0; 177 virtual Error setLayerCompositionType(Display display, Layer layer, 178 IComposerClient::Composition type) = 0; 179 virtual Error setLayerDataspace(Display display, Layer layer, Dataspace dataspace) = 0; 180 virtual Error setLayerDisplayFrame(Display display, Layer layer, 181 const IComposerClient::Rect& frame) = 0; 182 virtual Error setLayerPlaneAlpha(Display display, Layer layer, float alpha) = 0; 183 virtual Error setLayerSidebandStream(Display display, Layer layer, 184 const native_handle_t* stream) = 0; 185 virtual Error setLayerSourceCrop(Display display, Layer layer, 186 const IComposerClient::FRect& crop) = 0; 187 virtual Error setLayerTransform(Display display, Layer layer, Transform transform) = 0; 188 virtual Error setLayerVisibleRegion(Display display, Layer layer, 189 const std::vector<IComposerClient::Rect>& visible) = 0; 190 virtual Error setLayerZOrder(Display display, Layer layer, uint32_t z) = 0; 191 virtual Error setLayerInfo(Display display, Layer layer, uint32_t type, uint32_t appId) = 0; 192 193 // Composer HAL 2.2 194 virtual Error setLayerPerFrameMetadata( 195 Display display, Layer layer, 196 const std::vector<IComposerClient::PerFrameMetadata>& perFrameMetadatas) = 0; 197 virtual std::vector<IComposerClient::PerFrameMetadataKey> getPerFrameMetadataKeys( 198 Display display) = 0; 199 virtual Error getRenderIntents(Display display, ColorMode colorMode, 200 std::vector<RenderIntent>* outRenderIntents) = 0; 201 virtual Error getDataspaceSaturationMatrix(Dataspace dataspace, mat4* outMatrix) = 0; 202 203 // Composer HAL 2.3 204 virtual Error getDisplayIdentificationData(Display display, uint8_t* outPort, 205 std::vector<uint8_t>* outData) = 0; 206 virtual Error setLayerColorTransform(Display display, Layer layer, 207 const float* matrix) = 0; 208 virtual Error getDisplayedContentSamplingAttributes(Display display, PixelFormat* outFormat, 209 Dataspace* outDataspace, 210 uint8_t* outComponentMask) = 0; 211 virtual Error setDisplayContentSamplingEnabled(Display display, bool enabled, 212 uint8_t componentMask, uint64_t maxFrames) = 0; 213 virtual Error getDisplayedContentSample(Display display, uint64_t maxFrames, uint64_t timestamp, 214 DisplayedFrameStats* outStats) = 0; 215 virtual Error setLayerPerFrameMetadataBlobs( 216 Display display, Layer layer, const std::vector<PerFrameMetadataBlob>& metadata) = 0; 217 virtual Error setDisplayBrightness(Display display, float brightness) = 0; 218 219 // Composer HAL 2.4 220 virtual bool isVsyncPeriodSwitchSupported() = 0; 221 virtual Error getDisplayCapabilities(Display display, 222 std::vector<DisplayCapability>* outCapabilities) = 0; 223 virtual V2_4::Error getDisplayConnectionType( 224 Display display, IComposerClient::DisplayConnectionType* outType) = 0; 225 virtual V2_4::Error getDisplayVsyncPeriod(Display display, 226 VsyncPeriodNanos* outVsyncPeriod) = 0; 227 virtual V2_4::Error setActiveConfigWithConstraints( 228 Display display, Config config, 229 const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints, 230 VsyncPeriodChangeTimeline* outTimeline) = 0; 231 232 virtual V2_4::Error setAutoLowLatencyMode(Display displayId, bool on) = 0; 233 virtual V2_4::Error getSupportedContentTypes( 234 Display displayId, 235 std::vector<IComposerClient::ContentType>* outSupportedContentTypes) = 0; 236 virtual V2_4::Error setContentType(Display displayId, 237 IComposerClient::ContentType contentType) = 0; 238 virtual V2_4::Error setLayerGenericMetadata(Display display, Layer layer, 239 const std::string& key, bool mandatory, 240 const std::vector<uint8_t>& value) = 0; 241 virtual V2_4::Error getLayerGenericMetadataKeys( 242 std::vector<IComposerClient::LayerGenericMetadataKey>* outKeys) = 0; 243 virtual Error getClientTargetProperty( 244 Display display, IComposerClient::ClientTargetProperty* outClientTargetProperty) = 0; 245 }; 246 247 namespace impl { 248 249 class CommandReader : public CommandReaderBase { 250 public: 251 ~CommandReader(); 252 253 // Parse and execute commands from the command queue. The commands are 254 // actually return values from the server and will be saved in ReturnData. 255 Error parse(); 256 257 // Get and clear saved errors. 258 struct CommandError { 259 uint32_t location; 260 Error error; 261 }; 262 std::vector<CommandError> takeErrors(); 263 264 bool hasChanges(Display display, uint32_t* outNumChangedCompositionTypes, 265 uint32_t* outNumLayerRequestMasks) const; 266 267 // Get and clear saved changed composition types. 268 void takeChangedCompositionTypes(Display display, 269 std::vector<Layer>* outLayers, 270 std::vector<IComposerClient::Composition>* outTypes); 271 272 // Get and clear saved display requests. 273 void takeDisplayRequests(Display display, 274 uint32_t* outDisplayRequestMask, std::vector<Layer>* outLayers, 275 std::vector<uint32_t>* outLayerRequestMasks); 276 277 // Get and clear saved release fences. 278 void takeReleaseFences(Display display, std::vector<Layer>* outLayers, 279 std::vector<int>* outReleaseFences); 280 281 // Get and clear saved present fence. 282 void takePresentFence(Display display, int* outPresentFence); 283 284 // Get what stage succeeded during PresentOrValidate: Present or Validate 285 void takePresentOrValidateStage(Display display, uint32_t * state); 286 287 // Get the client target properties requested by hardware composer. 288 void takeClientTargetProperty(Display display, 289 IComposerClient::ClientTargetProperty* outClientTargetProperty); 290 291 private: 292 void resetData(); 293 294 bool parseSelectDisplay(uint16_t length); 295 bool parseSetError(uint16_t length); 296 bool parseSetChangedCompositionTypes(uint16_t length); 297 bool parseSetDisplayRequests(uint16_t length); 298 bool parseSetPresentFence(uint16_t length); 299 bool parseSetReleaseFences(uint16_t length); 300 bool parseSetPresentOrValidateDisplayResult(uint16_t length); 301 bool parseSetClientTargetProperty(uint16_t length); 302 303 struct ReturnData { 304 uint32_t displayRequests = 0; 305 306 std::vector<Layer> changedLayers; 307 std::vector<IComposerClient::Composition> compositionTypes; 308 309 std::vector<Layer> requestedLayers; 310 std::vector<uint32_t> requestMasks; 311 312 int presentFence = -1; 313 314 std::vector<Layer> releasedLayers; 315 std::vector<int> releaseFences; 316 317 uint32_t presentOrValidateState; 318 319 // Composer 2.4 implementation can return a client target property 320 // structure to indicate the client target properties that hardware 321 // composer requests. The composer client must change the client target 322 // properties to match this request. 323 IComposerClient::ClientTargetProperty clientTargetProperty{PixelFormat::RGBA_8888, 324 Dataspace::UNKNOWN}; 325 }; 326 327 std::vector<CommandError> mErrors; 328 std::unordered_map<Display, ReturnData> mReturnData; 329 330 // When SELECT_DISPLAY is parsed, this is updated to point to the 331 // display's return data in mReturnData. We use it to avoid repeated 332 // map lookups. 333 ReturnData* mCurrentReturnData; 334 }; 335 336 // Composer is a wrapper to IComposer, a proxy to server-side composer. 337 class Composer final : public Hwc2::Composer { 338 public: 339 explicit Composer(const std::string& serviceName); 340 ~Composer() override; 341 342 std::vector<IComposer::Capability> getCapabilities() override; 343 std::string dumpDebugInfo() override; 344 345 void registerCallback(const sp<IComposerCallback>& callback) override; 346 347 // Returns true if the connected composer service is running in a remote 348 // process, false otherwise. This will return false if the service is 349 // configured in passthrough mode, for example. 350 bool isRemote() override; 351 352 // Reset all pending commands in the command buffer. Useful if you want to 353 // skip a frame but have already queued some commands. 354 void resetCommands() override; 355 356 // Explicitly flush all pending commands in the command buffer. 357 Error executeCommands() override; 358 359 uint32_t getMaxVirtualDisplayCount() override; isUsingVrComposer()360 bool isUsingVrComposer() const override { return mIsUsingVrComposer; } 361 Error createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat* format, 362 Display* outDisplay) override; 363 Error destroyVirtualDisplay(Display display) override; 364 365 Error acceptDisplayChanges(Display display) override; 366 367 Error createLayer(Display display, Layer* outLayer) override; 368 Error destroyLayer(Display display, Layer layer) override; 369 370 Error getActiveConfig(Display display, Config* outConfig) override; 371 Error getChangedCompositionTypes(Display display, std::vector<Layer>* outLayers, 372 std::vector<IComposerClient::Composition>* outTypes) override; 373 Error getColorModes(Display display, std::vector<ColorMode>* outModes) override; 374 Error getDisplayAttribute(Display display, Config config, IComposerClient::Attribute attribute, 375 int32_t* outValue) override; 376 Error getDisplayConfigs(Display display, std::vector<Config>* outConfigs); 377 Error getDisplayName(Display display, std::string* outName) override; 378 379 Error getDisplayRequests(Display display, uint32_t* outDisplayRequestMask, 380 std::vector<Layer>* outLayers, 381 std::vector<uint32_t>* outLayerRequestMasks) override; 382 383 Error getDozeSupport(Display display, bool* outSupport) override; 384 Error getHdrCapabilities(Display display, std::vector<Hdr>* outTypes, float* outMaxLuminance, 385 float* outMaxAverageLuminance, float* outMinLuminance) override; 386 387 Error getReleaseFences(Display display, std::vector<Layer>* outLayers, 388 std::vector<int>* outReleaseFences) override; 389 390 Error presentDisplay(Display display, int* outPresentFence) override; 391 392 Error setActiveConfig(Display display, Config config) override; 393 394 /* 395 * The composer caches client targets internally. When target is nullptr, 396 * the composer uses slot to look up the client target from its cache. 397 * When target is not nullptr, the cache is updated with the new target. 398 */ 399 Error setClientTarget(Display display, uint32_t slot, const sp<GraphicBuffer>& target, 400 int acquireFence, Dataspace dataspace, 401 const std::vector<IComposerClient::Rect>& damage) override; 402 Error setColorMode(Display display, ColorMode mode, RenderIntent renderIntent) override; 403 Error setColorTransform(Display display, const float* matrix, ColorTransform hint) override; 404 Error setOutputBuffer(Display display, const native_handle_t* buffer, 405 int releaseFence) override; 406 Error setPowerMode(Display display, IComposerClient::PowerMode mode) override; 407 Error setVsyncEnabled(Display display, IComposerClient::Vsync enabled) override; 408 409 Error setClientTargetSlotCount(Display display) override; 410 411 Error validateDisplay(Display display, uint32_t* outNumTypes, 412 uint32_t* outNumRequests) override; 413 414 Error presentOrValidateDisplay(Display display, uint32_t* outNumTypes, uint32_t* outNumRequests, 415 int* outPresentFence, uint32_t* state) override; 416 417 Error setCursorPosition(Display display, Layer layer, int32_t x, int32_t y) override; 418 /* see setClientTarget for the purpose of slot */ 419 Error setLayerBuffer(Display display, Layer layer, uint32_t slot, 420 const sp<GraphicBuffer>& buffer, int acquireFence) override; 421 Error setLayerSurfaceDamage(Display display, Layer layer, 422 const std::vector<IComposerClient::Rect>& damage) override; 423 Error setLayerBlendMode(Display display, Layer layer, IComposerClient::BlendMode mode) override; 424 Error setLayerColor(Display display, Layer layer, const IComposerClient::Color& color) override; 425 Error setLayerCompositionType(Display display, Layer layer, 426 IComposerClient::Composition type) override; 427 Error setLayerDataspace(Display display, Layer layer, Dataspace dataspace) override; 428 Error setLayerDisplayFrame(Display display, Layer layer, 429 const IComposerClient::Rect& frame) override; 430 Error setLayerPlaneAlpha(Display display, Layer layer, float alpha) override; 431 Error setLayerSidebandStream(Display display, Layer layer, 432 const native_handle_t* stream) override; 433 Error setLayerSourceCrop(Display display, Layer layer, 434 const IComposerClient::FRect& crop) override; 435 Error setLayerTransform(Display display, Layer layer, Transform transform) override; 436 Error setLayerVisibleRegion(Display display, Layer layer, 437 const std::vector<IComposerClient::Rect>& visible) override; 438 Error setLayerZOrder(Display display, Layer layer, uint32_t z) override; 439 Error setLayerInfo(Display display, Layer layer, uint32_t type, uint32_t appId) override; 440 441 // Composer HAL 2.2 442 Error setLayerPerFrameMetadata( 443 Display display, Layer layer, 444 const std::vector<IComposerClient::PerFrameMetadata>& perFrameMetadatas) override; 445 std::vector<IComposerClient::PerFrameMetadataKey> getPerFrameMetadataKeys( 446 Display display) override; 447 Error getRenderIntents(Display display, ColorMode colorMode, 448 std::vector<RenderIntent>* outRenderIntents) override; 449 Error getDataspaceSaturationMatrix(Dataspace dataspace, mat4* outMatrix) override; 450 451 // Composer HAL 2.3 452 Error getDisplayIdentificationData(Display display, uint8_t* outPort, 453 std::vector<uint8_t>* outData) override; 454 Error setLayerColorTransform(Display display, Layer layer, const float* matrix) override; 455 Error getDisplayedContentSamplingAttributes(Display display, PixelFormat* outFormat, 456 Dataspace* outDataspace, 457 uint8_t* outComponentMask) override; 458 Error setDisplayContentSamplingEnabled(Display display, bool enabled, uint8_t componentMask, 459 uint64_t maxFrames) override; 460 Error getDisplayedContentSample(Display display, uint64_t maxFrames, uint64_t timestamp, 461 DisplayedFrameStats* outStats) override; 462 Error setLayerPerFrameMetadataBlobs( 463 Display display, Layer layer, 464 const std::vector<IComposerClient::PerFrameMetadataBlob>& metadata) override; 465 Error setDisplayBrightness(Display display, float brightness) override; 466 467 // Composer HAL 2.4 isVsyncPeriodSwitchSupported()468 bool isVsyncPeriodSwitchSupported() override { return mClient_2_4 != nullptr; } 469 Error getDisplayCapabilities(Display display, 470 std::vector<DisplayCapability>* outCapabilities) override; 471 V2_4::Error getDisplayConnectionType(Display display, 472 IComposerClient::DisplayConnectionType* outType) override; 473 V2_4::Error getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriod) override; 474 V2_4::Error setActiveConfigWithConstraints( 475 Display display, Config config, 476 const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints, 477 VsyncPeriodChangeTimeline* outTimeline) override; 478 V2_4::Error setAutoLowLatencyMode(Display displayId, bool on) override; 479 V2_4::Error getSupportedContentTypes( 480 Display displayId, 481 std::vector<IComposerClient::ContentType>* outSupportedContentTypes) override; 482 V2_4::Error setContentType(Display displayId, 483 IComposerClient::ContentType contentType) override; 484 V2_4::Error setLayerGenericMetadata(Display display, Layer layer, const std::string& key, 485 bool mandatory, const std::vector<uint8_t>& value) override; 486 V2_4::Error getLayerGenericMetadataKeys( 487 std::vector<IComposerClient::LayerGenericMetadataKey>* outKeys) override; 488 Error getClientTargetProperty( 489 Display display, 490 IComposerClient::ClientTargetProperty* outClientTargetProperty) override; 491 492 private: 493 #if defined(USE_VR_COMPOSER) && USE_VR_COMPOSER 494 class CommandWriter : public CommandWriterBase { 495 public: 496 explicit CommandWriter(uint32_t initialMaxSize); 497 ~CommandWriter() override; 498 499 void setLayerInfo(uint32_t type, uint32_t appId); 500 void setClientTargetMetadata( 501 const IVrComposerClient::BufferMetadata& metadata); 502 void setLayerBufferMetadata( 503 const IVrComposerClient::BufferMetadata& metadata); 504 505 private: 506 void writeBufferMetadata( 507 const IVrComposerClient::BufferMetadata& metadata); 508 }; 509 #else 510 class CommandWriter : public CommandWriterBase { 511 public: 512 explicit CommandWriter(uint32_t initialMaxSize) : CommandWriterBase(initialMaxSize) {} 513 ~CommandWriter() override {} 514 }; 515 #endif // defined(USE_VR_COMPOSER) && USE_VR_COMPOSER 516 517 // Many public functions above simply write a command into the command 518 // queue to batch the calls. validateDisplay and presentDisplay will call 519 // this function to execute the command queue. 520 Error execute(); 521 522 sp<V2_1::IComposer> mComposer; 523 524 sp<V2_1::IComposerClient> mClient; 525 sp<V2_2::IComposerClient> mClient_2_2; 526 sp<V2_3::IComposerClient> mClient_2_3; 527 sp<IComposerClient> mClient_2_4; 528 529 // 64KiB minus a small space for metadata such as read/write pointers 530 static constexpr size_t kWriterInitialSize = 531 64 * 1024 / sizeof(uint32_t) - 16; 532 CommandWriter mWriter; 533 CommandReader mReader; 534 535 // When true, the we attach to the vr_hwcomposer service instead of the 536 // hwcomposer. This allows us to redirect surfaces to 3d surfaces in vr. 537 const bool mIsUsingVrComposer; 538 }; 539 540 } // namespace impl 541 542 } // namespace Hwc2 543 544 } // namespace android 545 546 #endif // ANDROID_SF_COMPOSER_HAL_H 547