From c3d695db50f1a24adefa8c88d28f85a7e7abeb4c Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Fri, 16 Sep 2022 15:34:59 -0400 Subject: [PATCH] ComposerClient[Writer/Reader]: enforce a specific display Add a new parameter and member to ComposerClient[Writer/Reader] representing the only display it should apply to. The caller is responsible for ensuring that they only ever refer to that same display. The display is recorded here for error checking. This isn't strictly necessary, but crashing here verifies that we only use the proper display. This is helpful for use with DisplayCapability.MULTI_THREADED_PRESENT, although it is fine to use a single display per writer/reader without the capability. For the Reader, make the display optional, so that a single reader can continue to be used for multiple displays. This allows devices without the new DisplayCapability to continue to work without changes. Remove copy constructor and operator=. Add a move constructor. This ensures it will be properly moved when used in containers. Bug: 241285491 Test: make Change-Id: Ic7116e64138280747a32500c67dedeeabd7c669b --- .../graphics/composer3/ComposerClientReader.h | 23 +- .../graphics/composer3/ComposerClientWriter.h | 11 +- .../composer/aidl/vts/VtsComposerClient.h | 1 + .../VtsHalGraphicsComposer3_ReadbackTest.cpp | 129 ++++---- .../VtsHalGraphicsComposer3_TargetTest.cpp | 298 ++++++++++-------- 5 files changed, 269 insertions(+), 193 deletions(-) diff --git a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientReader.h b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientReader.h index 27dce76377..76ba24b0b2 100644 --- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientReader.h +++ b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientReader.h @@ -19,8 +19,8 @@ #include #include #include +#include #include -#include #include #include @@ -41,8 +41,15 @@ namespace aidl::android::hardware::graphics::composer3 { class ComposerClientReader { public: + explicit ComposerClientReader(std::optional display = {}) : mDisplay(display) {} + ~ComposerClientReader() { resetData(); } + ComposerClientReader(ComposerClientReader&&) = default; + + ComposerClientReader(const ComposerClientReader&) = delete; + ComposerClientReader& operator=(const ComposerClientReader&) = delete; + // Parse and execute commands from the command queue. The commands are // actually return values from the server and will be saved in ReturnData. void parse(std::vector&& results) { @@ -85,6 +92,7 @@ class ComposerClientReader { void hasChanges(int64_t display, uint32_t* outNumChangedCompositionTypes, uint32_t* outNumLayerRequestMasks) const { + LOG_ALWAYS_FATAL_IF(mDisplay && display != *mDisplay); auto found = mReturnData.find(display); if (found == mReturnData.end()) { *outNumChangedCompositionTypes = 0; @@ -100,6 +108,7 @@ class ComposerClientReader { // Get and clear saved changed composition types. std::vector takeChangedCompositionTypes(int64_t display) { + LOG_ALWAYS_FATAL_IF(mDisplay && display != *mDisplay); auto found = mReturnData.find(display); if (found == mReturnData.end()) { return {}; @@ -111,6 +120,7 @@ class ComposerClientReader { // Get and clear saved display requests. DisplayRequest takeDisplayRequests(int64_t display) { + LOG_ALWAYS_FATAL_IF(mDisplay && display != *mDisplay); auto found = mReturnData.find(display); if (found == mReturnData.end()) { return {}; @@ -122,6 +132,7 @@ class ComposerClientReader { // Get and clear saved release fences. std::vector takeReleaseFences(int64_t display) { + LOG_ALWAYS_FATAL_IF(mDisplay && display != *mDisplay); auto found = mReturnData.find(display); if (found == mReturnData.end()) { return {}; @@ -133,6 +144,7 @@ class ComposerClientReader { // Get and clear saved present fence. ndk::ScopedFileDescriptor takePresentFence(int64_t display) { + LOG_ALWAYS_FATAL_IF(mDisplay && display != *mDisplay); auto found = mReturnData.find(display); if (found == mReturnData.end()) { return {}; @@ -144,6 +156,7 @@ class ComposerClientReader { // Get what stage succeeded during PresentOrValidate: Present or Validate std::optional takePresentOrValidateStage(int64_t display) { + LOG_ALWAYS_FATAL_IF(mDisplay && display != *mDisplay); auto found = mReturnData.find(display); if (found == mReturnData.end()) { return std::nullopt; @@ -154,6 +167,7 @@ class ComposerClientReader { // Get the client target properties requested by hardware composer. ClientTargetPropertyWithBrightness takeClientTargetProperty(int64_t display) { + LOG_ALWAYS_FATAL_IF(mDisplay && display != *mDisplay); auto found = mReturnData.find(display); // If not found, return the default values. @@ -177,32 +191,38 @@ class ComposerClientReader { void parseSetError(CommandError&& error) { mErrors.emplace_back(error); } void parseSetChangedCompositionTypes(ChangedCompositionTypes&& changedCompositionTypes) { + LOG_ALWAYS_FATAL_IF(mDisplay && changedCompositionTypes.display != *mDisplay); auto& data = mReturnData[changedCompositionTypes.display]; data.changedLayers = std::move(changedCompositionTypes.layers); } void parseSetDisplayRequests(DisplayRequest&& displayRequest) { + LOG_ALWAYS_FATAL_IF(mDisplay && displayRequest.display != *mDisplay); auto& data = mReturnData[displayRequest.display]; data.displayRequests = std::move(displayRequest); } void parseSetPresentFence(PresentFence&& presentFence) { + LOG_ALWAYS_FATAL_IF(mDisplay && presentFence.display != *mDisplay); auto& data = mReturnData[presentFence.display]; data.presentFence = std::move(presentFence.fence); } void parseSetReleaseFences(ReleaseFences&& releaseFences) { + LOG_ALWAYS_FATAL_IF(mDisplay && releaseFences.display != *mDisplay); auto& data = mReturnData[releaseFences.display]; data.releasedLayers = std::move(releaseFences.layers); } void parseSetPresentOrValidateDisplayResult(const PresentOrValidate&& presentOrValidate) { + LOG_ALWAYS_FATAL_IF(mDisplay && presentOrValidate.display != *mDisplay); auto& data = mReturnData[presentOrValidate.display]; data.presentOrValidateState = std::move(presentOrValidate.result); } void parseSetClientTargetProperty( const ClientTargetPropertyWithBrightness&& clientTargetProperty) { + LOG_ALWAYS_FATAL_IF(mDisplay && clientTargetProperty.display != *mDisplay); auto& data = mReturnData[clientTargetProperty.display]; data.clientTargetProperty = std::move(clientTargetProperty); } @@ -222,6 +242,7 @@ class ComposerClientReader { std::vector mErrors; std::unordered_map mReturnData; + const std::optional mDisplay; }; } // namespace aidl::android::hardware::graphics::composer3 diff --git a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h index 775ae9fa88..0c8742f887 100644 --- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h +++ b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h @@ -19,8 +19,6 @@ #include #include #include -#include -#include #include #include @@ -63,10 +61,15 @@ class ComposerClientWriter final { public: static constexpr std::optional kNoTimestamp = std::nullopt; - ComposerClientWriter() { reset(); } + explicit ComposerClientWriter(int64_t display) : mDisplay(display) { reset(); } ~ComposerClientWriter() { reset(); } + ComposerClientWriter(ComposerClientWriter&&) = default; + + ComposerClientWriter(const ComposerClientWriter&) = delete; + ComposerClientWriter& operator=(const ComposerClientWriter&) = delete; + void reset() { mDisplayCommand.reset(); mLayerCommand.reset(); @@ -229,6 +232,7 @@ class ComposerClientWriter final { std::optional mDisplayCommand; std::optional mLayerCommand; std::vector mCommands; + const int64_t mDisplay; Buffer getBuffer(uint32_t slot, const native_handle_t* bufferHandle, int fence) { Buffer bufferCommand; @@ -254,6 +258,7 @@ class ComposerClientWriter final { DisplayCommand& getDisplayCommand(int64_t display) { if (!mDisplayCommand.has_value() || mDisplayCommand->display != display) { + LOG_ALWAYS_FATAL_IF(display != mDisplay); flushLayerCommand(); flushDisplayCommand(); mDisplayCommand.emplace(); diff --git a/graphics/composer/aidl/vts/VtsComposerClient.h b/graphics/composer/aidl/vts/VtsComposerClient.h index 6358b85e0c..18833365e0 100644 --- a/graphics/composer/aidl/vts/VtsComposerClient.h +++ b/graphics/composer/aidl/vts/VtsComposerClient.h @@ -35,6 +35,7 @@ #include #include #include +#include #include "GraphicsComposerCallback.h" using aidl::android::hardware::graphics::common::Dataspace; diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp index 46dde09dd4..6fa33927f0 100644 --- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp +++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp @@ -53,6 +53,7 @@ class GraphicsCompositionTestBase : public ::testing::Test { const auto& [status, displays] = mComposerClient->getDisplays(); ASSERT_TRUE(status.isOk()); mDisplays = displays; + mWriter.reset(new ComposerClientWriter(getPrimaryDisplayId())); setTestColorModes(); @@ -200,15 +201,15 @@ class GraphicsCompositionTestBase : public ::testing::Test { void writeLayers(const std::vector>& layers) { for (const auto& layer : layers) { - layer->write(mWriter); + layer->write(*mWriter); } execute(); } void execute() { - const auto& commands = mWriter.getPendingCommands(); + const auto& commands = mWriter->getPendingCommands(); if (commands.empty()) { - mWriter.reset(); + mWriter->reset(); return; } @@ -216,7 +217,7 @@ class GraphicsCompositionTestBase : public ::testing::Test { ASSERT_TRUE(status.isOk()) << "executeCommands failed " << status.getDescription(); mReader.parse(std::move(results)); - mWriter.reset(); + mWriter->reset(); } bool getHasReadbackBuffer() { @@ -236,7 +237,7 @@ class GraphicsCompositionTestBase : public ::testing::Test { std::vector mDisplays; // use the slot count usually set by SF std::vector mTestColorModes; - ComposerClientWriter mWriter; + std::unique_ptr mWriter; ComposerClientReader mReader; std::unique_ptr mTestRenderEngine; common::PixelFormat mPixelFormat; @@ -297,7 +298,7 @@ TEST_P(GraphicsCompositionTest, SingleSolidColorLayer) { writeLayers(layers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); // if hwc cannot handle and asks for composition change, // just succeed the test @@ -306,7 +307,7 @@ TEST_P(GraphicsCompositionTest, SingleSolidColorLayer) { return; } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -349,14 +350,14 @@ TEST_P(GraphicsCompositionTest, SetLayerBuffer) { getDisplayHeight(), common::PixelFormat::RGBA_8888); layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()}); layer->setZOrder(10); - layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter); + layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), *mWriter); ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors)); std::vector> layers = {layer}; writeLayers(layers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { @@ -365,7 +366,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBuffer) { } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -395,7 +396,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) { layer->setColor(BLUE); layer->setDisplayFrame(coloredSquare); layer->setZOrder(10); - layer->write(mWriter); + layer->write(*mWriter); // This following buffer call should have no effect const auto usage = static_cast(common::BufferUsage::CPU_WRITE_OFTEN) | @@ -403,8 +404,8 @@ TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) { const auto& [graphicBufferStatus, graphicBuffer] = allocateBuffer(usage); ASSERT_TRUE(graphicBufferStatus); const auto& buffer = graphicBuffer->handle; - mWriter.setLayerBuffer(getPrimaryDisplayId(), layer->getLayer(), /*slot*/ 0, buffer, - /*acquireFence*/ -1); + mWriter->setLayerBuffer(getPrimaryDisplayId(), layer->getLayer(), /*slot*/ 0, buffer, + /*acquireFence*/ -1); // expected color for each pixel std::vector expectedColors( @@ -415,7 +416,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) { getDisplayHeight(), mPixelFormat, mDataspace); ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { @@ -423,7 +424,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) { return; } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -533,7 +534,7 @@ TEST_P(GraphicsCompositionTest, ClientComposition) { getDisplayHeight(), PixelFormat::RGBA_FP16); layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()}); layer->setZOrder(10); - layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter); + layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), *mWriter); std::vector> layers = {layer}; @@ -542,7 +543,7 @@ TEST_P(GraphicsCompositionTest, ClientComposition) { ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer()); writeLayers(layers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); auto changedCompositionTypes = mReader.takeChangedCompositionTypes(getPrimaryDisplayId()); @@ -572,17 +573,17 @@ TEST_P(GraphicsCompositionTest, ClientComposition) { int32_t clientFence; const auto unlockStatus = graphicBuffer->unlockAsync(&clientFence); ASSERT_EQ(::android::OK, unlockStatus); - mWriter.setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, buffer, clientFence, - clientDataspace, std::vector(1, damage)); - layer->setToClientComposition(mWriter); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, buffer, clientFence, + clientDataspace, std::vector(1, damage)); + layer->setToClientComposition(*mWriter); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); changedCompositionTypes = mReader.takeChangedCompositionTypes(getPrimaryDisplayId()); ASSERT_TRUE(changedCompositionTypes.empty()); } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -631,9 +632,9 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) { deviceLayer->setDisplayFrame({0, 0, static_cast(deviceLayer->getWidth()), static_cast(deviceLayer->getHeight())}); deviceLayer->setZOrder(10); - deviceLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter); + deviceLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), *mWriter); ASSERT_NO_FATAL_FAILURE(deviceLayer->setBuffer(deviceColors)); - deviceLayer->write(mWriter); + deviceLayer->write(*mWriter); PixelFormat clientFormat = PixelFormat::RGBA_8888; auto clientUsage = static_cast( @@ -651,8 +652,8 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) { getDisplayHeight()}; clientLayer->setDisplayFrame(clientFrame); clientLayer->setZOrder(0); - clientLayer->write(mWriter); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + clientLayer->write(*mWriter); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); auto changedCompositionTypes = mReader.takeChangedCompositionTypes(getPrimaryDisplayId()); @@ -678,16 +679,16 @@ TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) { int32_t clientFence; const auto unlockStatus = graphicBuffer->unlockAsync(&clientFence); ASSERT_EQ(::android::OK, unlockStatus); - mWriter.setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, buffer, clientFence, - clientDataspace, std::vector(1, clientFrame)); - clientLayer->setToClientComposition(mWriter); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, buffer, clientFence, + clientDataspace, std::vector(1, clientFrame)); + clientLayer->setToClientComposition(*mWriter); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); changedCompositionTypes = mReader.takeChangedCompositionTypes(getPrimaryDisplayId()); ASSERT_TRUE(changedCompositionTypes.empty()); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors)); @@ -718,7 +719,7 @@ TEST_P(GraphicsCompositionTest, SetLayerDamage) { getDisplayHeight(), PixelFormat::RGBA_8888); layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()}); layer->setZOrder(10); - layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter); + layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), *mWriter); ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors)); std::vector> layers = {layer}; @@ -729,14 +730,14 @@ TEST_P(GraphicsCompositionTest, SetLayerDamage) { writeLayers(layers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED(); return; } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -757,11 +758,11 @@ TEST_P(GraphicsCompositionTest, SetLayerDamage) { writeLayers(layers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); ASSERT_TRUE(mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -798,7 +799,7 @@ TEST_P(GraphicsCompositionTest, SetLayerPlaneAlpha) { writeLayers(layers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED(); @@ -806,7 +807,7 @@ TEST_P(GraphicsCompositionTest, SetLayerPlaneAlpha) { } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -846,7 +847,7 @@ TEST_P(GraphicsCompositionTest, SetLayerSourceCrop) { getDisplayHeight(), PixelFormat::RGBA_8888); layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()}); layer->setZOrder(10); - layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter); + layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), *mWriter); layer->setSourceCrop({0, static_cast(getDisplayHeight() / 2), static_cast(getDisplayWidth()), static_cast(getDisplayHeight())}); @@ -862,14 +863,14 @@ TEST_P(GraphicsCompositionTest, SetLayerSourceCrop) { ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer()); writeLayers(layers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED(); return; } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors)); @@ -920,13 +921,13 @@ TEST_P(GraphicsCompositionTest, SetLayerZOrder) { writeLayers(layers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED(); return; } - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -942,11 +943,11 @@ TEST_P(GraphicsCompositionTest, SetLayerZOrder) { writeLayers(layers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); ASSERT_TRUE(mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -980,7 +981,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBrightnessDims) { // Preconditions to successfully run are knowing the max brightness and successfully applying // the max brightness ASSERT_GT(maxBrightnessNits, 0.f); - mWriter.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 1.f, maxBrightnessNits); + mWriter->setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 1.f, maxBrightnessNits); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -1030,7 +1031,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBrightnessDims) { writeLayers(layers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED() @@ -1038,7 +1039,7 @@ TEST_P(GraphicsCompositionTest, SetLayerBrightnessDims) { << toString(mode); continue; } - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -1088,7 +1089,7 @@ class GraphicsBlendModeCompositionTest getDisplayHeight(), PixelFormat::RGBA_8888); layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()}); layer->setZOrder(10); - layer->setDataspace(Dataspace::UNKNOWN, mWriter); + layer->setDataspace(Dataspace::UNKNOWN, *mWriter); ASSERT_NO_FATAL_FAILURE(layer->setBuffer(topLayerPixelColors)); layer->setBlendMode(blendMode); @@ -1165,14 +1166,14 @@ TEST_P(GraphicsBlendModeCompositionTest, None) { ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer()); writeLayers(mLayers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED(); return; } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -1210,14 +1211,14 @@ TEST_P(GraphicsBlendModeCompositionTest, Coverage) { ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer()); writeLayers(mLayers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED(); return; } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors)); @@ -1250,14 +1251,14 @@ TEST_P(GraphicsBlendModeCompositionTest, Premultiplied) { ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer()); writeLayers(mLayers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED(); return; } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors)); @@ -1323,7 +1324,7 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_H) { getDisplayHeight(), mPixelFormat, mDataspace); ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer()); mLayer->setTransform(Transform::FLIP_H); - mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter); + mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), *mWriter); std::vector expectedColors( static_cast(getDisplayWidth() * getDisplayHeight())); @@ -1334,14 +1335,14 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_H) { writeLayers(mLayers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED(); return; } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); @@ -1369,7 +1370,7 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_V) { ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer()); mLayer->setTransform(Transform::FLIP_V); - mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter); + mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), *mWriter); std::vector expectedColors( static_cast(getDisplayWidth() * getDisplayHeight())); @@ -1380,14 +1381,14 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_V) { writeLayers(mLayers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED(); return; } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors)); @@ -1414,7 +1415,7 @@ TEST_P(GraphicsTransformCompositionTest, ROT_180) { ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer()); mLayer->setTransform(Transform::ROT_180); - mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter); + mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), *mWriter); std::vector expectedColors( static_cast(getDisplayWidth() * getDisplayHeight())); @@ -1426,14 +1427,14 @@ TEST_P(GraphicsTransformCompositionTest, ROT_180) { writeLayers(mLayers); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED(); return; } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + mWriter->presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors)); diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp index ed8a06c188..fa66812d6e 100644 --- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp +++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp @@ -33,9 +33,11 @@ #include #include #include +#include #include #include #include +#include #include "GraphicsComposerCallback.h" #include "VtsComposerClient.h" @@ -1078,17 +1080,23 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { } void execute() { - const auto& commands = mWriter.getPendingCommands(); - if (commands.empty()) { - mWriter.reset(); - return; + std::vector payloads; + for (auto& [_, writer] : mWriters) { + const auto& commands = writer.getPendingCommands(); + if (commands.empty()) { + writer.reset(); + continue; + } + + auto [status, results] = mComposerClient->executeCommands(commands); + ASSERT_TRUE(status.isOk()) << "executeCommands failed " << status.getDescription(); + writer.reset(); + + payloads.reserve(payloads.size() + results.size()); + payloads.insert(payloads.end(), std::make_move_iterator(results.begin()), + std::make_move_iterator(results.end())); } - - auto [status, results] = mComposerClient->executeCommands(commands); - ASSERT_TRUE(status.isOk()) << "executeCommands failed " << status.getDescription(); - - mReader.parse(std::move(results)); - mWriter.reset(); + mReader.parse(std::move(payloads)); } static inline auto toTimePoint(nsecs_t time) { @@ -1152,6 +1160,7 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { const auto& [status, layer] = mComposerClient->createLayer(display.getDisplayId(), kBufferSlotCount); EXPECT_TRUE(status.isOk()); + auto& writer = getWriter(display.getDisplayId()); { const auto buffer = allocate(::android::PIXEL_FORMAT_RGBA_8888); ASSERT_NE(nullptr, buffer); @@ -1160,15 +1169,15 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { configureLayer(display, layer, Composition::DEVICE, display.getFrameRect(), display.getCrop()); - mWriter.setLayerBuffer(display.getDisplayId(), layer, /*slot*/ 0, buffer->handle, - /*acquireFence*/ -1); - mWriter.setLayerDataspace(display.getDisplayId(), layer, common::Dataspace::UNKNOWN); + writer.setLayerBuffer(display.getDisplayId(), layer, /*slot*/ 0, buffer->handle, + /*acquireFence*/ -1); + writer.setLayerDataspace(display.getDisplayId(), layer, common::Dataspace::UNKNOWN); - mWriter.validateDisplay(display.getDisplayId(), ComposerClientWriter::kNoTimestamp); + writer.validateDisplay(display.getDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(display.getDisplayId()); + writer.presentDisplay(display.getDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); } @@ -1177,15 +1186,15 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { const auto buffer = allocate(::android::PIXEL_FORMAT_RGBA_8888); ASSERT_NE(nullptr, buffer->handle); - mWriter.setLayerBuffer(display.getDisplayId(), layer, /*slot*/ 0, buffer->handle, - /*acquireFence*/ -1); - mWriter.setLayerSurfaceDamage(display.getDisplayId(), layer, - std::vector(1, {0, 0, 10, 10})); - mWriter.validateDisplay(display.getDisplayId(), ComposerClientWriter::kNoTimestamp); + writer.setLayerBuffer(display.getDisplayId(), layer, /*slot*/ 0, buffer->handle, + /*acquireFence*/ -1); + writer.setLayerSurfaceDamage(display.getDisplayId(), layer, + std::vector(1, {0, 0, 10, 10})); + writer.validateDisplay(display.getDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(display.getDisplayId()); + writer.presentDisplay(display.getDisplayId()); execute(); } @@ -1194,11 +1203,12 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { sp<::android::Fence> presentAndGetFence( std::optional expectedPresentTime) { - mWriter.validateDisplay(getPrimaryDisplayId(), expectedPresentTime); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.validateDisplay(getPrimaryDisplayId(), expectedPresentTime); execute(); EXPECT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + writer.presentDisplay(getPrimaryDisplayId()); execute(); EXPECT_TRUE(mReader.takeErrors().empty()); @@ -1230,7 +1240,8 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { FRect cropRect{0, 0, (float)getPrimaryDisplay().getDisplayWidth(), (float)getPrimaryDisplay().getDisplayHeight()}; configureLayer(getPrimaryDisplay(), layer, Composition::DEVICE, displayFrame, cropRect); - mWriter.setLayerDataspace(getPrimaryDisplayId(), layer, common::Dataspace::UNKNOWN); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerDataspace(getPrimaryDisplayId(), layer, common::Dataspace::UNKNOWN); return layer; } @@ -1330,8 +1341,9 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { ASSERT_NE(nullptr, buffer2); const auto layer = createOnScreenLayer(); - mWriter.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, buffer1->handle, - /*acquireFence*/ -1); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, buffer1->handle, + /*acquireFence*/ -1); const sp<::android::Fence> presentFence1 = presentAndGetFence(ComposerClientWriter::kNoTimestamp); presentFence1->waitForever(LOG_TAG); @@ -1341,8 +1353,8 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { expectedPresentTime += *framesDelay * vsyncPeriod; } - mWriter.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, buffer2->handle, - /*acquireFence*/ -1); + writer.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, buffer2->handle, + /*acquireFence*/ -1); const auto setExpectedPresentTime = [&]() -> std::optional { if (!framesDelay.has_value()) { return ComposerClientWriter::kNoTimestamp; @@ -1363,17 +1375,18 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { void configureLayer(const VtsDisplay& display, int64_t layer, Composition composition, const Rect& displayFrame, const FRect& cropRect) { - mWriter.setLayerCompositionType(display.getDisplayId(), layer, composition); - mWriter.setLayerDisplayFrame(display.getDisplayId(), layer, displayFrame); - mWriter.setLayerPlaneAlpha(display.getDisplayId(), layer, /*alpha*/ 1); - mWriter.setLayerSourceCrop(display.getDisplayId(), layer, cropRect); - mWriter.setLayerTransform(display.getDisplayId(), layer, static_cast(0)); - mWriter.setLayerVisibleRegion(display.getDisplayId(), layer, - std::vector(1, displayFrame)); - mWriter.setLayerZOrder(display.getDisplayId(), layer, /*z*/ 10); - mWriter.setLayerBlendMode(display.getDisplayId(), layer, BlendMode::NONE); - mWriter.setLayerSurfaceDamage(display.getDisplayId(), layer, - std::vector(1, displayFrame)); + auto& writer = getWriter(display.getDisplayId()); + writer.setLayerCompositionType(display.getDisplayId(), layer, composition); + writer.setLayerDisplayFrame(display.getDisplayId(), layer, displayFrame); + writer.setLayerPlaneAlpha(display.getDisplayId(), layer, /*alpha*/ 1); + writer.setLayerSourceCrop(display.getDisplayId(), layer, cropRect); + writer.setLayerTransform(display.getDisplayId(), layer, static_cast(0)); + writer.setLayerVisibleRegion(display.getDisplayId(), layer, + std::vector(1, displayFrame)); + writer.setLayerZOrder(display.getDisplayId(), layer, /*z*/ 10); + writer.setLayerBlendMode(display.getDisplayId(), layer, BlendMode::NONE); + writer.setLayerSurfaceDamage(display.getDisplayId(), layer, + std::vector(1, displayFrame)); } // clang-format off const std::array kIdentity = {{ @@ -1384,12 +1397,20 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { }}; // clang-format on - ComposerClientWriter mWriter; + ComposerClientWriter& getWriter(int64_t display) { + auto [it, _] = mWriters.try_emplace(display, display); + return it->second; + } + ComposerClientReader mReader; + + private: + std::unordered_map mWriters; }; TEST_P(GraphicsComposerAidlCommandTest, SetColorTransform) { - mWriter.setColorTransform(getPrimaryDisplayId(), kIdentity.data()); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setColorTransform(getPrimaryDisplayId(), kIdentity.data()); execute(); } @@ -1397,7 +1418,8 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerColorTransform) { const auto& [status, layer] = mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(status.isOk()); - mWriter.setLayerColorTransform(getPrimaryDisplayId(), layer, kIdentity.data()); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerColorTransform(getPrimaryDisplayId(), layer, kIdentity.data()); execute(); const auto errors = mReader.takeErrors(); @@ -1413,8 +1435,9 @@ TEST_P(GraphicsComposerAidlCommandTest, SetDisplayBrightness) { ASSERT_TRUE(status.isOk()); bool brightnessSupport = std::find(capabilities.begin(), capabilities.end(), DisplayCapability::BRIGHTNESS) != capabilities.end(); + auto& writer = getWriter(getPrimaryDisplayId()); if (!brightnessSupport) { - mWriter.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 0.5f, -1.f); + writer.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 0.5f, -1.f); execute(); const auto errors = mReader.takeErrors(); EXPECT_EQ(1, errors.size()); @@ -1423,23 +1446,23 @@ TEST_P(GraphicsComposerAidlCommandTest, SetDisplayBrightness) { return; } - mWriter.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 0.0f, -1.f); + writer.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 0.0f, -1.f); execute(); EXPECT_TRUE(mReader.takeErrors().empty()); - mWriter.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 0.5f, -1.f); + writer.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 0.5f, -1.f); execute(); EXPECT_TRUE(mReader.takeErrors().empty()); - mWriter.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 1.0f, -1.f); + writer.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 1.0f, -1.f); execute(); EXPECT_TRUE(mReader.takeErrors().empty()); - mWriter.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ -1.0f, -1.f); + writer.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ -1.0f, -1.f); execute(); EXPECT_TRUE(mReader.takeErrors().empty()); - mWriter.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 2.0f, -1.f); + writer.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ 2.0f, -1.f); execute(); { const auto errors = mReader.takeErrors(); @@ -1447,7 +1470,7 @@ TEST_P(GraphicsComposerAidlCommandTest, SetDisplayBrightness) { EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, errors[0].errorCode); } - mWriter.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ -2.0f, -1.f); + writer.setDisplayBrightness(getPrimaryDisplayId(), /*brightness*/ -2.0f, -1.f); execute(); { const auto errors = mReader.takeErrors(); @@ -1460,8 +1483,9 @@ TEST_P(GraphicsComposerAidlCommandTest, SetClientTarget) { EXPECT_TRUE(mComposerClient->setClientTargetSlotCount(getPrimaryDisplayId(), kBufferSlotCount) .isOk()); - mWriter.setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, nullptr, /*acquireFence*/ -1, - Dataspace::UNKNOWN, std::vector()); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, nullptr, /*acquireFence*/ -1, + Dataspace::UNKNOWN, std::vector()); execute(); } @@ -1481,24 +1505,28 @@ TEST_P(GraphicsComposerAidlCommandTest, SetOutputBuffer) { const auto buffer = allocate(::android::PIXEL_FORMAT_RGBA_8888); const auto handle = buffer->handle; - mWriter.setOutputBuffer(display.display, /*slot*/ 0, handle, /*releaseFence*/ -1); + auto& writer = getWriter(display.display); + writer.setOutputBuffer(display.display, /*slot*/ 0, handle, /*releaseFence*/ -1); execute(); } TEST_P(GraphicsComposerAidlCommandTest, ValidDisplay) { - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); } TEST_P(GraphicsComposerAidlCommandTest, AcceptDisplayChanges) { - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); - mWriter.acceptDisplayChanges(getPrimaryDisplayId()); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + writer.acceptDisplayChanges(getPrimaryDisplayId()); execute(); } TEST_P(GraphicsComposerAidlCommandTest, PresentDisplay) { - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); - mWriter.presentDisplay(getPrimaryDisplayId()); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + writer.presentDisplay(getPrimaryDisplayId()); execute(); } @@ -1519,6 +1547,7 @@ TEST_P(GraphicsComposerAidlCommandTest, PresentDisplayNoLayerStateChanges) { const auto& [renderIntentsStatus, renderIntents] = mComposerClient->getRenderIntents(getPrimaryDisplayId(), ColorMode::NATIVE); EXPECT_TRUE(renderIntentsStatus.isOk()); + auto& writer = getWriter(getPrimaryDisplayId()); for (auto intent : renderIntents) { EXPECT_TRUE(mComposerClient->setColorMode(getPrimaryDisplayId(), ColorMode::NATIVE, intent) .isOk()); @@ -1536,10 +1565,10 @@ TEST_P(GraphicsComposerAidlCommandTest, PresentDisplayNoLayerStateChanges) { FRect cropRect{0, 0, (float)getPrimaryDisplay().getDisplayWidth(), (float)getPrimaryDisplay().getDisplayHeight()}; configureLayer(getPrimaryDisplay(), layer, Composition::CURSOR, displayFrame, cropRect); - mWriter.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, handle, - /*acquireFence*/ -1); - mWriter.setLayerDataspace(getPrimaryDisplayId(), layer, Dataspace::UNKNOWN); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + writer.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, handle, + /*acquireFence*/ -1); + writer.setLayerDataspace(getPrimaryDisplayId(), layer, Dataspace::UNKNOWN); + writer.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) { GTEST_SUCCEED() << "Composition change requested, skipping test"; @@ -1547,18 +1576,18 @@ TEST_P(GraphicsComposerAidlCommandTest, PresentDisplayNoLayerStateChanges) { } ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.presentDisplay(getPrimaryDisplayId()); + writer.presentDisplay(getPrimaryDisplayId()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); const auto buffer2 = allocate(::android::PIXEL_FORMAT_RGBA_8888); const auto handle2 = buffer2->handle; ASSERT_NE(nullptr, handle2); - mWriter.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, handle2, - /*acquireFence*/ -1); - mWriter.setLayerSurfaceDamage(getPrimaryDisplayId(), layer, - std::vector(1, {0, 0, 10, 10})); - mWriter.presentDisplay(getPrimaryDisplayId()); + writer.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, handle2, + /*acquireFence*/ -1); + writer.setLayerSurfaceDamage(getPrimaryDisplayId(), layer, + std::vector(1, {0, 0, 10, 10})); + writer.presentDisplay(getPrimaryDisplayId()); execute(); } } @@ -1572,15 +1601,16 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerCursorPosition) { const auto handle = buffer->handle; ASSERT_NE(nullptr, handle); - mWriter.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, handle, /*acquireFence*/ -1); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, handle, /*acquireFence*/ -1); Rect displayFrame{0, 0, getPrimaryDisplay().getDisplayWidth(), getPrimaryDisplay().getDisplayHeight()}; FRect cropRect{0, 0, (float)getPrimaryDisplay().getDisplayWidth(), (float)getPrimaryDisplay().getDisplayHeight()}; configureLayer(getPrimaryDisplay(), layer, Composition::CURSOR, displayFrame, cropRect); - mWriter.setLayerDataspace(getPrimaryDisplayId(), layer, Dataspace::UNKNOWN); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + writer.setLayerDataspace(getPrimaryDisplayId(), layer, Dataspace::UNKNOWN); + writer.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); @@ -1588,15 +1618,15 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerCursorPosition) { GTEST_SUCCEED() << "Composition change requested, skipping test"; return; } - mWriter.presentDisplay(getPrimaryDisplayId()); + writer.presentDisplay(getPrimaryDisplayId()); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerCursorPosition(getPrimaryDisplayId(), layer, /*x*/ 1, /*y*/ 1); + writer.setLayerCursorPosition(getPrimaryDisplayId(), layer, /*x*/ 1, /*y*/ 1); execute(); - mWriter.setLayerCursorPosition(getPrimaryDisplayId(), layer, /*x*/ 0, /*y*/ 0); - mWriter.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); - mWriter.presentDisplay(getPrimaryDisplayId()); + writer.setLayerCursorPosition(getPrimaryDisplayId(), layer, /*x*/ 0, /*y*/ 0); + writer.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp); + writer.presentDisplay(getPrimaryDisplayId()); execute(); } @@ -1608,7 +1638,8 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerBuffer) { const auto& [layerStatus, layer] = mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, handle, /*acquireFence*/ -1); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, handle, /*acquireFence*/ -1); execute(); } @@ -1620,15 +1651,16 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerSurfaceDamage) { Rect empty{0, 0, 0, 0}; Rect unit{0, 0, 1, 1}; - mWriter.setLayerSurfaceDamage(getPrimaryDisplayId(), layer, std::vector(1, empty)); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerSurfaceDamage(getPrimaryDisplayId(), layer, std::vector(1, empty)); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerSurfaceDamage(getPrimaryDisplayId(), layer, std::vector(1, unit)); + writer.setLayerSurfaceDamage(getPrimaryDisplayId(), layer, std::vector(1, unit)); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerSurfaceDamage(getPrimaryDisplayId(), layer, std::vector()); + writer.setLayerSurfaceDamage(getPrimaryDisplayId(), layer, std::vector()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); } @@ -1641,15 +1673,16 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerBlockingRegion) { Rect empty{0, 0, 0, 0}; Rect unit{0, 0, 1, 1}; - mWriter.setLayerBlockingRegion(getPrimaryDisplayId(), layer, std::vector(1, empty)); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerBlockingRegion(getPrimaryDisplayId(), layer, std::vector(1, empty)); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerBlockingRegion(getPrimaryDisplayId(), layer, std::vector(1, unit)); + writer.setLayerBlockingRegion(getPrimaryDisplayId(), layer, std::vector(1, unit)); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerBlockingRegion(getPrimaryDisplayId(), layer, std::vector()); + writer.setLayerBlockingRegion(getPrimaryDisplayId(), layer, std::vector()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); } @@ -1659,15 +1692,16 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerBlendMode) { mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerBlendMode(getPrimaryDisplayId(), layer, BlendMode::NONE); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerBlendMode(getPrimaryDisplayId(), layer, BlendMode::NONE); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerBlendMode(getPrimaryDisplayId(), layer, BlendMode::PREMULTIPLIED); + writer.setLayerBlendMode(getPrimaryDisplayId(), layer, BlendMode::PREMULTIPLIED); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerBlendMode(getPrimaryDisplayId(), layer, BlendMode::COVERAGE); + writer.setLayerBlendMode(getPrimaryDisplayId(), layer, BlendMode::COVERAGE); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); } @@ -1677,11 +1711,12 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerColor) { mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerColor(getPrimaryDisplayId(), layer, Color{1.0f, 1.0f, 1.0f, 1.0f}); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerColor(getPrimaryDisplayId(), layer, Color{1.0f, 1.0f, 1.0f, 1.0f}); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerColor(getPrimaryDisplayId(), layer, Color{0.0f, 0.0f, 0.0f, 0.0f}); + writer.setLayerColor(getPrimaryDisplayId(), layer, Color{0.0f, 0.0f, 0.0f, 0.0f}); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); } @@ -1691,19 +1726,20 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerCompositionType) { mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerCompositionType(getPrimaryDisplayId(), layer, Composition::CLIENT); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerCompositionType(getPrimaryDisplayId(), layer, Composition::CLIENT); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerCompositionType(getPrimaryDisplayId(), layer, Composition::DEVICE); + writer.setLayerCompositionType(getPrimaryDisplayId(), layer, Composition::DEVICE); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerCompositionType(getPrimaryDisplayId(), layer, Composition::SOLID_COLOR); + writer.setLayerCompositionType(getPrimaryDisplayId(), layer, Composition::SOLID_COLOR); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerCompositionType(getPrimaryDisplayId(), layer, Composition::CURSOR); + writer.setLayerCompositionType(getPrimaryDisplayId(), layer, Composition::CURSOR); execute(); } @@ -1734,9 +1770,10 @@ TEST_P(GraphicsComposerAidlCommandTest, DisplayDecoration) { configureLayer(display, layer, Composition::DISPLAY_DECORATION, display.getFrameRect(), display.getCrop()); - mWriter.setLayerBuffer(display.getDisplayId(), layer, /*slot*/ 0, decorBuffer->handle, - /*acquireFence*/ -1); - mWriter.validateDisplay(display.getDisplayId(), ComposerClientWriter::kNoTimestamp); + auto& writer = getWriter(display.getDisplayId()); + writer.setLayerBuffer(display.getDisplayId(), layer, /*slot*/ 0, decorBuffer->handle, + /*acquireFence*/ -1); + writer.validateDisplay(display.getDisplayId(), ComposerClientWriter::kNoTimestamp); execute(); if (support) { ASSERT_TRUE(mReader.takeErrors().empty()); @@ -1753,7 +1790,8 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerDataspace) { mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerDataspace(getPrimaryDisplayId(), layer, Dataspace::UNKNOWN); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerDataspace(getPrimaryDisplayId(), layer, Dataspace::UNKNOWN); execute(); } @@ -1762,7 +1800,8 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerDisplayFrame) { mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerDisplayFrame(getPrimaryDisplayId(), layer, Rect{0, 0, 1, 1}); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerDisplayFrame(getPrimaryDisplayId(), layer, Rect{0, 0, 1, 1}); execute(); } @@ -1771,11 +1810,12 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerPlaneAlpha) { mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerPlaneAlpha(getPrimaryDisplayId(), layer, /*alpha*/ 0.0f); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerPlaneAlpha(getPrimaryDisplayId(), layer, /*alpha*/ 0.0f); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerPlaneAlpha(getPrimaryDisplayId(), layer, /*alpha*/ 1.0f); + writer.setLayerPlaneAlpha(getPrimaryDisplayId(), layer, /*alpha*/ 1.0f); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); } @@ -1794,7 +1834,8 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerSidebandStream) { mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerSidebandStream(getPrimaryDisplayId(), layer, handle); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerSidebandStream(getPrimaryDisplayId(), layer, handle); execute(); } @@ -1803,7 +1844,8 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerSourceCrop) { mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerSourceCrop(getPrimaryDisplayId(), layer, FRect{0.0f, 0.0f, 1.0f, 1.0f}); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerSourceCrop(getPrimaryDisplayId(), layer, FRect{0.0f, 0.0f, 1.0f, 1.0f}); execute(); } @@ -1812,39 +1854,40 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerTransform) { mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerTransform(getPrimaryDisplayId(), layer, static_cast(0)); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerTransform(getPrimaryDisplayId(), layer, static_cast(0)); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerTransform(getPrimaryDisplayId(), layer, Transform::FLIP_H); + writer.setLayerTransform(getPrimaryDisplayId(), layer, Transform::FLIP_H); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerTransform(getPrimaryDisplayId(), layer, Transform::FLIP_V); + writer.setLayerTransform(getPrimaryDisplayId(), layer, Transform::FLIP_V); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerTransform(getPrimaryDisplayId(), layer, Transform::ROT_90); + writer.setLayerTransform(getPrimaryDisplayId(), layer, Transform::ROT_90); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerTransform(getPrimaryDisplayId(), layer, Transform::ROT_180); + writer.setLayerTransform(getPrimaryDisplayId(), layer, Transform::ROT_180); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerTransform(getPrimaryDisplayId(), layer, Transform::ROT_270); + writer.setLayerTransform(getPrimaryDisplayId(), layer, Transform::ROT_270); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerTransform(getPrimaryDisplayId(), layer, - static_cast(static_cast(Transform::FLIP_H) | - static_cast(Transform::ROT_90))); + writer.setLayerTransform(getPrimaryDisplayId(), layer, + static_cast(static_cast(Transform::FLIP_H) | + static_cast(Transform::ROT_90))); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerTransform(getPrimaryDisplayId(), layer, - static_cast(static_cast(Transform::FLIP_V) | - static_cast(Transform::ROT_90))); + writer.setLayerTransform(getPrimaryDisplayId(), layer, + static_cast(static_cast(Transform::FLIP_V) | + static_cast(Transform::ROT_90))); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); } @@ -1857,15 +1900,16 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerVisibleRegion) { Rect empty{0, 0, 0, 0}; Rect unit{0, 0, 1, 1}; - mWriter.setLayerVisibleRegion(getPrimaryDisplayId(), layer, std::vector(1, empty)); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerVisibleRegion(getPrimaryDisplayId(), layer, std::vector(1, empty)); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerVisibleRegion(getPrimaryDisplayId(), layer, std::vector(1, unit)); + writer.setLayerVisibleRegion(getPrimaryDisplayId(), layer, std::vector(1, unit)); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerVisibleRegion(getPrimaryDisplayId(), layer, std::vector()); + writer.setLayerVisibleRegion(getPrimaryDisplayId(), layer, std::vector()); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); } @@ -1875,11 +1919,12 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerZOrder) { mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); EXPECT_TRUE(layerStatus.isOk()); - mWriter.setLayerZOrder(getPrimaryDisplayId(), layer, /*z*/ 10); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerZOrder(getPrimaryDisplayId(), layer, /*z*/ 10); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerZOrder(getPrimaryDisplayId(), layer, /*z*/ 0); + writer.setLayerZOrder(getPrimaryDisplayId(), layer, /*z*/ 0); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); } @@ -1901,6 +1946,7 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerPerFrameMetadata) { * white (D65) 0.3127 0.3290 */ + auto& writer = getWriter(getPrimaryDisplayId()); std::vector aidlMetadata; aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_RED_PRIMARY_X, 0.680f}); aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_RED_PRIMARY_Y, 0.320f}); @@ -1914,7 +1960,7 @@ TEST_P(GraphicsComposerAidlCommandTest, SetLayerPerFrameMetadata) { aidlMetadata.push_back({PerFrameMetadataKey::MIN_LUMINANCE, 0.1f}); aidlMetadata.push_back({PerFrameMetadataKey::MAX_CONTENT_LIGHT_LEVEL, 78.0}); aidlMetadata.push_back({PerFrameMetadataKey::MAX_FRAME_AVERAGE_LIGHT_LEVEL, 62.0}); - mWriter.setLayerPerFrameMetadata(getPrimaryDisplayId(), layer, aidlMetadata); + writer.setLayerPerFrameMetadata(getPrimaryDisplayId(), layer, aidlMetadata); execute(); const auto errors = mReader.takeErrors(); @@ -1931,19 +1977,20 @@ TEST_P(GraphicsComposerAidlCommandTest, setLayerBrightness) { const auto& [layerStatus, layer] = mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount); - mWriter.setLayerBrightness(getPrimaryDisplayId(), layer, 0.2f); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerBrightness(getPrimaryDisplayId(), layer, 0.2f); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerBrightness(getPrimaryDisplayId(), layer, 1.f); + writer.setLayerBrightness(getPrimaryDisplayId(), layer, 1.f); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerBrightness(getPrimaryDisplayId(), layer, 0.f); + writer.setLayerBrightness(getPrimaryDisplayId(), layer, 0.f); execute(); ASSERT_TRUE(mReader.takeErrors().empty()); - mWriter.setLayerBrightness(getPrimaryDisplayId(), layer, -1.f); + writer.setLayerBrightness(getPrimaryDisplayId(), layer, -1.f); execute(); { const auto errors = mReader.takeErrors(); @@ -1951,7 +1998,7 @@ TEST_P(GraphicsComposerAidlCommandTest, setLayerBrightness) { EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, errors[0].errorCode); } - mWriter.setLayerBrightness(getPrimaryDisplayId(), layer, std::nanf("")); + writer.setLayerBrightness(getPrimaryDisplayId(), layer, std::nanf("")); execute(); { const auto errors = mReader.takeErrors(); @@ -2116,8 +2163,9 @@ TEST_P(GraphicsComposerAidlCommandTest, SetIdleTimerEnabled_Timeout_2) { ASSERT_NE(nullptr, buffer->handle); const auto layer = createOnScreenLayer(); - mWriter.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, buffer->handle, - /*acquireFence*/ -1); + auto& writer = getWriter(getPrimaryDisplayId()); + writer.setLayerBuffer(getPrimaryDisplayId(), layer, /*slot*/ 0, buffer->handle, + /*acquireFence*/ -1); int32_t vsyncIdleCount = mComposerClient->getVsyncIdleCount(); auto earlyVsyncIdleTime = systemTime() + std::chrono::nanoseconds(2s).count(); EXPECT_TRUE(