blob: 9db8794fd6a28af0205921f975d56401c6beca46 [file] [log] [blame]
ramindanibab8ba92021-11-18 01:24:11 +00001/**
2 * Copyright (c) 2021, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "graphics_composer_aidl_hal_readback_tests@3"
18
19#include <aidl/Gtest.h>
20#include <aidl/Vintf.h>
Brian Lindahle887a252023-01-17 14:54:19 -070021#include <aidl/android/hardware/graphics/common/BufferUsage.h>
Ady Abraham46219f52021-12-20 09:44:31 -080022#include <aidl/android/hardware/graphics/composer3/IComposer.h>
ramindanibab8ba92021-11-18 01:24:11 +000023#include <gtest/gtest.h>
Alec Mouri51067012022-01-06 17:28:39 -080024#include <ui/DisplayId.h>
25#include <ui/DisplayIdentification.h>
ramindanibab8ba92021-11-18 01:24:11 +000026#include <ui/GraphicBuffer.h>
ramindanibab8ba92021-11-18 01:24:11 +000027#include <ui/PixelFormat.h>
28#include <ui/Rect.h>
ramindani458e53e2022-02-23 17:30:16 +000029#include "GraphicsComposerCallback.h"
30#include "ReadbackVts.h"
31#include "RenderEngineVts.h"
32#include "VtsComposerClient.h"
Alec Mouri51067012022-01-06 17:28:39 -080033
ramindanibab8ba92021-11-18 01:24:11 +000034namespace aidl::android::hardware::graphics::composer3::vts {
35namespace {
36
37using ::android::Rect;
38using common::Dataspace;
39using common::PixelFormat;
40
41class GraphicsCompositionTestBase : public ::testing::Test {
42 protected:
43 void SetUpBase(const std::string& name) {
ramindanidcecfd42022-02-03 23:52:19 +000044 mComposerClient = std::make_shared<VtsComposerClient>(name);
45 ASSERT_TRUE(mComposerClient->createClient().isOk());
ramindanibab8ba92021-11-18 01:24:11 +000046
ramindanidcecfd42022-02-03 23:52:19 +000047 const auto& [status, displays] = mComposerClient->getDisplays();
48 ASSERT_TRUE(status.isOk());
49 mDisplays = displays;
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -040050 mWriter.reset(new ComposerClientWriter(getPrimaryDisplayId()));
ramindanibab8ba92021-11-18 01:24:11 +000051
52 setTestColorModes();
53
54 // explicitly disable vsync
ramindanidcecfd42022-02-03 23:52:19 +000055 for (const auto& display : mDisplays) {
56 EXPECT_TRUE(mComposerClient->setVsync(display.getDisplayId(), /*enable*/ false).isOk());
57 }
58 mComposerClient->setVsyncAllowed(/*isAllowed*/ false);
ramindanibab8ba92021-11-18 01:24:11 +000059
ramindanidcecfd42022-02-03 23:52:19 +000060 EXPECT_TRUE(mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::ON).isOk());
ramindanibab8ba92021-11-18 01:24:11 +000061
Alec Mouri19e90fa2024-05-13 17:09:25 +000062 const auto format = getHasReadbackBuffer() ? mPixelFormat : common::PixelFormat::RGBA_8888;
63
ramindanibab8ba92021-11-18 01:24:11 +000064 ASSERT_NO_FATAL_FAILURE(
65 mTestRenderEngine = std::unique_ptr<TestRenderEngine>(new TestRenderEngine(
66 ::android::renderengine::RenderEngineCreationArgs::Builder()
Alec Mouri19e90fa2024-05-13 17:09:25 +000067 .setPixelFormat(static_cast<int>(format))
ramindanibab8ba92021-11-18 01:24:11 +000068 .setImageCacheSize(TestRenderEngine::sMaxFrameBufferAcquireBuffers)
ramindanibab8ba92021-11-18 01:24:11 +000069 .setEnableProtectedContext(false)
70 .setPrecacheToneMapperShaderOnly(false)
71 .setContextPriority(::android::renderengine::RenderEngine::
72 ContextPriority::HIGH)
73 .build())));
74
Alec Mourif6c039a2023-10-06 23:02:17 +000075 mClientCompositionDisplaySettings.physicalDisplay =
76 Rect(getDisplayWidth(), getDisplayHeight());
77 mClientCompositionDisplaySettings.clip = mClientCompositionDisplaySettings.physicalDisplay;
ramindanibab8ba92021-11-18 01:24:11 +000078
Brian Lindahle887a252023-01-17 14:54:19 -070079 mTestRenderEngine->initGraphicBuffer(
80 static_cast<uint32_t>(getDisplayWidth()), static_cast<uint32_t>(getDisplayHeight()),
81 /*layerCount*/ 1U,
82 static_cast<uint64_t>(
83 static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
84 static_cast<uint64_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
85 static_cast<uint64_t>(common::BufferUsage::GPU_RENDER_TARGET)));
Alec Mourif6c039a2023-10-06 23:02:17 +000086 mTestRenderEngine->setDisplaySettings(mClientCompositionDisplaySettings);
ramindanibab8ba92021-11-18 01:24:11 +000087 }
88
89 void TearDown() override {
Leon Scroggins III94f4b202024-01-09 11:43:45 -050090 ASSERT_FALSE(mDisplays.empty());
ramindanidcecfd42022-02-03 23:52:19 +000091 ASSERT_TRUE(mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::OFF).isOk());
Ady Abrahama00d2462023-12-26 14:21:20 -080092 ASSERT_TRUE(mComposerClient->tearDown(mWriter.get()));
ramindanidcecfd42022-02-03 23:52:19 +000093 mComposerClient.reset();
Ady Abraham3192f3d2021-12-03 16:08:56 -080094 const auto errors = mReader.takeErrors();
95 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanidcecfd42022-02-03 23:52:19 +000096 ASSERT_TRUE(mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty());
ramindanibab8ba92021-11-18 01:24:11 +000097 }
98
ramindanidcecfd42022-02-03 23:52:19 +000099 const VtsDisplay& getPrimaryDisplay() const { return mDisplays[0]; }
100
101 int64_t getPrimaryDisplayId() const { return getPrimaryDisplay().getDisplayId(); }
102
103 int64_t getInvalidDisplayId() const { return mComposerClient->getInvalidDisplayId(); }
104
105 int32_t getDisplayWidth() const { return getPrimaryDisplay().getDisplayWidth(); }
106
107 int32_t getDisplayHeight() const { return getPrimaryDisplay().getDisplayHeight(); }
108
ramindanid5751092022-04-22 22:30:20 +0000109 void assertServiceSpecificError(const ScopedAStatus& status, int32_t serviceSpecificError) {
110 ASSERT_EQ(status.getExceptionCode(), EX_SERVICE_SPECIFIC);
111 ASSERT_EQ(status.getServiceSpecificError(), serviceSpecificError);
112 }
113
Brian Lindahle887a252023-01-17 14:54:19 -0700114 std::pair<bool, ::android::sp<::android::GraphicBuffer>> allocateBuffer(uint32_t usage) {
115 const auto width = static_cast<uint32_t>(getDisplayWidth());
116 const auto height = static_cast<uint32_t>(getDisplayHeight());
117
118 const auto& graphicBuffer = ::android::sp<::android::GraphicBuffer>::make(
119 width, height, ::android::PIXEL_FORMAT_RGBA_8888,
120 /*layerCount*/ 1u, usage, "VtsHalGraphicsComposer3_ReadbackTest");
ramindani0a2bee42022-02-10 01:27:42 +0000121
122 if (graphicBuffer && ::android::OK == graphicBuffer->initCheck()) {
Brian Lindahle887a252023-01-17 14:54:19 -0700123 return {true, graphicBuffer};
ramindani0a2bee42022-02-10 01:27:42 +0000124 }
Brian Lindahle887a252023-01-17 14:54:19 -0700125 return {false, graphicBuffer};
ramindanibab8ba92021-11-18 01:24:11 +0000126 }
127
ramindanibab8ba92021-11-18 01:24:11 +0000128 void writeLayers(const std::vector<std::shared_ptr<TestLayer>>& layers) {
ramindanidcecfd42022-02-03 23:52:19 +0000129 for (const auto& layer : layers) {
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400130 layer->write(*mWriter);
ramindanibab8ba92021-11-18 01:24:11 +0000131 }
132 execute();
133 }
134
135 void execute() {
Huihong Luo651806f2023-04-21 18:48:48 +0000136 auto commands = mWriter->takePendingCommands();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800137 if (commands.empty()) {
Ady Abraham3192f3d2021-12-03 16:08:56 -0800138 return;
ramindanibab8ba92021-11-18 01:24:11 +0000139 }
140
ramindanidcecfd42022-02-03 23:52:19 +0000141 auto [status, results] = mComposerClient->executeCommands(commands);
Ady Abraham3192f3d2021-12-03 16:08:56 -0800142 ASSERT_TRUE(status.isOk()) << "executeCommands failed " << status.getDescription();
ramindanibab8ba92021-11-18 01:24:11 +0000143
Ady Abraham46219f52021-12-20 09:44:31 -0800144 mReader.parse(std::move(results));
ramindanibab8ba92021-11-18 01:24:11 +0000145 }
146
ramindani44c952f2022-02-28 23:29:29 +0000147 bool getHasReadbackBuffer() {
ramindanidcecfd42022-02-03 23:52:19 +0000148 auto [status, readBackBufferAttributes] =
149 mComposerClient->getReadbackBufferAttributes(getPrimaryDisplayId());
150 if (status.isOk()) {
151 mPixelFormat = readBackBufferAttributes.format;
152 mDataspace = readBackBufferAttributes.dataspace;
ramindani44c952f2022-02-28 23:29:29 +0000153 return ReadbackHelper::readbackSupported(mPixelFormat, mDataspace);
ramindanidcecfd42022-02-03 23:52:19 +0000154 }
ramindanid5751092022-04-22 22:30:20 +0000155 EXPECT_NO_FATAL_FAILURE(
156 assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED));
ramindani44c952f2022-02-28 23:29:29 +0000157 return false;
ramindanib27f33b2021-12-03 19:36:10 +0000158 }
159
ramindanidcecfd42022-02-03 23:52:19 +0000160 std::shared_ptr<VtsComposerClient> mComposerClient;
161 std::vector<VtsDisplay> mDisplays;
162 // use the slot count usually set by SF
ramindanibab8ba92021-11-18 01:24:11 +0000163 std::vector<ColorMode> mTestColorModes;
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400164 std::unique_ptr<ComposerClientWriter> mWriter;
Ady Abraham91c9d1a2021-12-15 18:14:45 -0800165 ComposerClientReader mReader;
ramindanibab8ba92021-11-18 01:24:11 +0000166 std::unique_ptr<TestRenderEngine> mTestRenderEngine;
ramindanibab8ba92021-11-18 01:24:11 +0000167 common::PixelFormat mPixelFormat;
168 common::Dataspace mDataspace;
Alec Mourif6c039a2023-10-06 23:02:17 +0000169 ::android::renderengine::DisplaySettings mClientCompositionDisplaySettings;
ramindanibab8ba92021-11-18 01:24:11 +0000170
171 static constexpr uint32_t kClientTargetSlotCount = 64;
172
173 private:
ramindanibab8ba92021-11-18 01:24:11 +0000174 void setTestColorModes() {
175 mTestColorModes.clear();
ramindanidcecfd42022-02-03 23:52:19 +0000176 const auto& [status, modes] = mComposerClient->getColorModes(getPrimaryDisplayId());
177 ASSERT_TRUE(status.isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000178
179 for (ColorMode mode : modes) {
180 if (std::find(ReadbackHelper::colorModes.begin(), ReadbackHelper::colorModes.end(),
181 mode) != ReadbackHelper::colorModes.end()) {
182 mTestColorModes.push_back(mode);
183 }
184 }
185 }
186};
187
188class GraphicsCompositionTest : public GraphicsCompositionTestBase,
189 public testing::WithParamInterface<std::string> {
190 public:
191 void SetUp() override { SetUpBase(GetParam()); }
192};
193
194TEST_P(GraphicsCompositionTest, SingleSolidColorLayer) {
195 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +0000196 EXPECT_TRUE(mComposerClient
197 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
198 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000199
ramindani44c952f2022-02-28 23:29:29 +0000200 bool isSupported;
201 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000202 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +0000203 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
204 return;
205 }
206
Ady Abrahama00d2462023-12-26 14:21:20 -0800207 auto layer =
208 std::make_shared<TestColorLayer>(mComposerClient, getPrimaryDisplayId(), *mWriter);
ramindanidcecfd42022-02-03 23:52:19 +0000209 common::Rect coloredSquare({0, 0, getDisplayWidth(), getDisplayHeight()});
ramindanibab8ba92021-11-18 01:24:11 +0000210 layer->setColor(BLUE);
211 layer->setDisplayFrame(coloredSquare);
212 layer->setZOrder(10);
213
214 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
215
216 // expected color for each pixel
ramindanidcecfd42022-02-03 23:52:19 +0000217 std::vector<Color> expectedColors(
218 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
219 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), coloredSquare, BLUE);
ramindanibab8ba92021-11-18 01:24:11 +0000220
ramindanidcecfd42022-02-03 23:52:19 +0000221 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -0700222 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +0000223 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
224
225 writeLayers(layers);
Ady Abraham3192f3d2021-12-03 16:08:56 -0800226 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -0800227 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
228 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000229 execute();
230 // if hwc cannot handle and asks for composition change,
231 // just succeed the test
ramindanidcecfd42022-02-03 23:52:19 +0000232 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +0000233 GTEST_SUCCEED();
234 return;
235 }
Ady Abraham3192f3d2021-12-03 16:08:56 -0800236 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400237 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000238 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800239 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000240
241 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
242 mTestRenderEngine->setRenderLayers(layers);
243 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
244 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
245 }
246}
247
248TEST_P(GraphicsCompositionTest, SetLayerBuffer) {
249 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +0000250 EXPECT_TRUE(mComposerClient
251 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
252 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000253
ramindani44c952f2022-02-28 23:29:29 +0000254 bool isSupported;
255 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000256 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +0000257 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
258 return;
259 }
260
ramindanidcecfd42022-02-03 23:52:19 +0000261 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -0700262 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +0000263 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000264 std::vector<Color> expectedColors(
265 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
266 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
267 {0, 0, getDisplayWidth(), getDisplayHeight() / 4}, RED);
268 ReadbackHelper::fillColorsArea(
269 expectedColors, getDisplayWidth(),
270 {0, getDisplayHeight() / 4, getDisplayWidth(), getDisplayHeight() / 2}, GREEN);
271 ReadbackHelper::fillColorsArea(
272 expectedColors, getDisplayWidth(),
273 {0, getDisplayHeight() / 2, getDisplayWidth(), getDisplayHeight()}, BLUE);
ramindanibab8ba92021-11-18 01:24:11 +0000274
275 auto layer = std::make_shared<TestBufferLayer>(
ramindani0a2bee42022-02-10 01:27:42 +0000276 mComposerClient, *mTestRenderEngine, getPrimaryDisplayId(), getDisplayWidth(),
Ady Abrahama00d2462023-12-26 14:21:20 -0800277 getDisplayHeight(), common::PixelFormat::RGBA_8888, *mWriter);
ramindanidcecfd42022-02-03 23:52:19 +0000278 layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()});
ramindanibab8ba92021-11-18 01:24:11 +0000279 layer->setZOrder(10);
Alec Mourif6c039a2023-10-06 23:02:17 +0000280 layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode));
ramindanibab8ba92021-11-18 01:24:11 +0000281 ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors));
282
283 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
284
285 writeLayers(layers);
Ady Abraham3192f3d2021-12-03 16:08:56 -0800286 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -0800287 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
288 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000289 execute();
290
ramindanidcecfd42022-02-03 23:52:19 +0000291 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +0000292 GTEST_SUCCEED();
293 return;
294 }
Ady Abraham3192f3d2021-12-03 16:08:56 -0800295 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000296
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400297 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000298 execute();
299
Ady Abraham3192f3d2021-12-03 16:08:56 -0800300 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000301
302 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
303 mTestRenderEngine->setRenderLayers(layers);
304 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
305 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
306 }
307}
308
309TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
310 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +0000311 EXPECT_TRUE(mComposerClient
312 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
313 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000314
ramindani44c952f2022-02-28 23:29:29 +0000315 bool isSupported;
316 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000317 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +0000318 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
319 return;
320 }
321
Ady Abrahama00d2462023-12-26 14:21:20 -0800322 auto layer =
323 std::make_shared<TestColorLayer>(mComposerClient, getPrimaryDisplayId(), *mWriter);
ramindanidcecfd42022-02-03 23:52:19 +0000324 common::Rect coloredSquare({0, 0, getDisplayWidth(), getDisplayHeight()});
ramindanibab8ba92021-11-18 01:24:11 +0000325 layer->setColor(BLUE);
326 layer->setDisplayFrame(coloredSquare);
327 layer->setZOrder(10);
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400328 layer->write(*mWriter);
ramindanibab8ba92021-11-18 01:24:11 +0000329
330 // This following buffer call should have no effect
Brian Lindahle887a252023-01-17 14:54:19 -0700331 const auto usage = static_cast<uint32_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
332 static_cast<uint32_t>(common::BufferUsage::CPU_READ_OFTEN);
333 const auto& [graphicBufferStatus, graphicBuffer] = allocateBuffer(usage);
334 ASSERT_TRUE(graphicBufferStatus);
ramindani0a2bee42022-02-10 01:27:42 +0000335 const auto& buffer = graphicBuffer->handle;
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400336 mWriter->setLayerBuffer(getPrimaryDisplayId(), layer->getLayer(), /*slot*/ 0, buffer,
337 /*acquireFence*/ -1);
ramindanibab8ba92021-11-18 01:24:11 +0000338
339 // expected color for each pixel
ramindanidcecfd42022-02-03 23:52:19 +0000340 std::vector<Color> expectedColors(
341 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
342 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), coloredSquare, BLUE);
ramindanibab8ba92021-11-18 01:24:11 +0000343
ramindanidcecfd42022-02-03 23:52:19 +0000344 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -0700345 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +0000346 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
347
ramindanicdcfcaf2023-11-09 10:00:10 -0800348 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
349 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000350 execute();
351
ramindanidcecfd42022-02-03 23:52:19 +0000352 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +0000353 GTEST_SUCCEED();
354 return;
355 }
Ady Abraham3192f3d2021-12-03 16:08:56 -0800356 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400357 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000358 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800359 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000360
361 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
362 }
363}
364
ramindanib27f33b2021-12-03 19:36:10 +0000365TEST_P(GraphicsCompositionTest, SetReadbackBuffer) {
ramindani44c952f2022-02-28 23:29:29 +0000366 bool isSupported;
367 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000368 if (!isSupported) {
ramindanib27f33b2021-12-03 19:36:10 +0000369 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
370 return;
371 }
372
ramindanidcecfd42022-02-03 23:52:19 +0000373 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -0700374 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanib27f33b2021-12-03 19:36:10 +0000375
376 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
377}
378
ramindanidcecfd42022-02-03 23:52:19 +0000379TEST_P(GraphicsCompositionTest, SetReadbackBuffer_BadDisplay) {
ramindani44c952f2022-02-28 23:29:29 +0000380 bool isSupported;
381 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000382 if (!isSupported) {
ramindanib27f33b2021-12-03 19:36:10 +0000383 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
384 return;
385 }
386
Brian Lindahle887a252023-01-17 14:54:19 -0700387 const auto usage = static_cast<uint32_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
388 static_cast<uint32_t>(common::BufferUsage::CPU_READ_OFTEN);
389 const auto& [graphicBufferStatus, graphicBuffer] = allocateBuffer(usage);
390 ASSERT_TRUE(graphicBufferStatus);
ramindani0a2bee42022-02-10 01:27:42 +0000391 const auto& bufferHandle = graphicBuffer->handle;
ramindanib27f33b2021-12-03 19:36:10 +0000392 ::ndk::ScopedFileDescriptor fence = ::ndk::ScopedFileDescriptor(-1);
393
ramindanidcecfd42022-02-03 23:52:19 +0000394 const auto status =
395 mComposerClient->setReadbackBuffer(getInvalidDisplayId(), bufferHandle, fence);
ramindanib27f33b2021-12-03 19:36:10 +0000396
ramindanidcecfd42022-02-03 23:52:19 +0000397 EXPECT_FALSE(status.isOk());
ramindanid5751092022-04-22 22:30:20 +0000398 EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
ramindanib27f33b2021-12-03 19:36:10 +0000399}
400
ramindanidcecfd42022-02-03 23:52:19 +0000401TEST_P(GraphicsCompositionTest, SetReadbackBuffer_BadParameter) {
ramindani44c952f2022-02-28 23:29:29 +0000402 bool isSupported;
403 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000404 if (!isSupported) {
ramindanib27f33b2021-12-03 19:36:10 +0000405 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
406 return;
407 }
408
ramindanidcecfd42022-02-03 23:52:19 +0000409 const native_handle_t bufferHandle{};
ramindanib27f33b2021-12-03 19:36:10 +0000410 ndk::ScopedFileDescriptor releaseFence = ndk::ScopedFileDescriptor(-1);
ramindanidcecfd42022-02-03 23:52:19 +0000411 const auto status =
412 mComposerClient->setReadbackBuffer(getPrimaryDisplayId(), &bufferHandle, releaseFence);
ramindanib27f33b2021-12-03 19:36:10 +0000413
ramindanidcecfd42022-02-03 23:52:19 +0000414 EXPECT_FALSE(status.isOk());
ramindanid5751092022-04-22 22:30:20 +0000415 EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_PARAMETER));
ramindanib27f33b2021-12-03 19:36:10 +0000416}
417
418TEST_P(GraphicsCompositionTest, GetReadbackBufferFenceInactive) {
ramindani44c952f2022-02-28 23:29:29 +0000419 bool isSupported;
420 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000421 if (!isSupported) {
ramindanib27f33b2021-12-03 19:36:10 +0000422 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
423 return;
424 }
425
ramindanidcecfd42022-02-03 23:52:19 +0000426 const auto& [status, releaseFence] =
427 mComposerClient->getReadbackBufferFence(getPrimaryDisplayId());
ramindanib27f33b2021-12-03 19:36:10 +0000428
ramindanidcecfd42022-02-03 23:52:19 +0000429 EXPECT_FALSE(status.isOk());
ramindanid5751092022-04-22 22:30:20 +0000430 EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED));
Alec Mouri62ae37b2022-01-20 17:16:38 -0800431 EXPECT_EQ(-1, releaseFence.get());
ramindanib27f33b2021-12-03 19:36:10 +0000432}
433
ramindanibab8ba92021-11-18 01:24:11 +0000434TEST_P(GraphicsCompositionTest, ClientComposition) {
ramindanidcecfd42022-02-03 23:52:19 +0000435 EXPECT_TRUE(
436 mComposerClient->setClientTargetSlotCount(getPrimaryDisplayId(), kClientTargetSlotCount)
437 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000438
439 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +0000440 EXPECT_TRUE(mComposerClient
441 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
ramindanibab8ba92021-11-18 01:24:11 +0000442 .isOk());
443
ramindani44c952f2022-02-28 23:29:29 +0000444 bool isSupported;
445 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000446 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +0000447 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
448 return;
449 }
450
ramindanidcecfd42022-02-03 23:52:19 +0000451 std::vector<Color> expectedColors(
452 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
453 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
454 {0, 0, getDisplayWidth(), getDisplayHeight() / 4}, RED);
455 ReadbackHelper::fillColorsArea(
456 expectedColors, getDisplayWidth(),
457 {0, getDisplayHeight() / 4, getDisplayWidth(), getDisplayHeight() / 2}, GREEN);
458 ReadbackHelper::fillColorsArea(
459 expectedColors, getDisplayWidth(),
460 {0, getDisplayHeight() / 2, getDisplayWidth(), getDisplayHeight()}, BLUE);
ramindanibab8ba92021-11-18 01:24:11 +0000461
Ady Abrahama00d2462023-12-26 14:21:20 -0800462 auto layer = std::make_shared<TestBufferLayer>(
463 mComposerClient, *mTestRenderEngine, getPrimaryDisplayId(), getDisplayWidth(),
464 getDisplayHeight(), PixelFormat::RGBA_FP16, *mWriter);
ramindanidcecfd42022-02-03 23:52:19 +0000465 layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()});
ramindanibab8ba92021-11-18 01:24:11 +0000466 layer->setZOrder(10);
Alec Mourif6c039a2023-10-06 23:02:17 +0000467 layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode));
ramindanibab8ba92021-11-18 01:24:11 +0000468
469 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
470
ramindanidcecfd42022-02-03 23:52:19 +0000471 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -0700472 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +0000473 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
474 writeLayers(layers);
Ady Abraham3192f3d2021-12-03 16:08:56 -0800475 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -0800476 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
477 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000478 execute();
479
ramindanidcecfd42022-02-03 23:52:19 +0000480 auto changedCompositionTypes = mReader.takeChangedCompositionTypes(getPrimaryDisplayId());
Ady Abraham46219f52021-12-20 09:44:31 -0800481 if (!changedCompositionTypes.empty()) {
Ady Abraham3192f3d2021-12-03 16:08:56 -0800482 ASSERT_EQ(1, changedCompositionTypes.size());
Ady Abraham46219f52021-12-20 09:44:31 -0800483 ASSERT_EQ(Composition::CLIENT, changedCompositionTypes[0].composition);
ramindanibab8ba92021-11-18 01:24:11 +0000484
485 PixelFormat clientFormat = PixelFormat::RGBA_8888;
Brian Lindahle887a252023-01-17 14:54:19 -0700486 auto clientUsage = static_cast<uint32_t>(
487 static_cast<uint32_t>(common::BufferUsage::CPU_READ_OFTEN) |
488 static_cast<uint32_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
489 static_cast<uint32_t>(common::BufferUsage::COMPOSER_CLIENT_TARGET));
ramindanibab8ba92021-11-18 01:24:11 +0000490 Dataspace clientDataspace = ReadbackHelper::getDataspaceForColorMode(mode);
ramindanidcecfd42022-02-03 23:52:19 +0000491 common::Rect damage{0, 0, getDisplayWidth(), getDisplayHeight()};
ramindanibab8ba92021-11-18 01:24:11 +0000492
493 // create client target buffer
Brian Lindahle887a252023-01-17 14:54:19 -0700494 const auto& [graphicBufferStatus, graphicBuffer] = allocateBuffer(clientUsage);
495 ASSERT_TRUE(graphicBufferStatus);
ramindani0a2bee42022-02-10 01:27:42 +0000496 const auto& buffer = graphicBuffer->handle;
ramindanibab8ba92021-11-18 01:24:11 +0000497 void* clientBufData;
ramindani0a2bee42022-02-10 01:27:42 +0000498 const auto stride = static_cast<uint32_t>(graphicBuffer->stride);
Alec Mouri6a000222024-08-16 23:08:09 +0000499 int bytesPerPixel = -1;
500 int bytesPerStride = -1;
501 graphicBuffer->lock(clientUsage, layer->getAccessRegion(), &clientBufData,
502 &bytesPerPixel, &bytesPerStride);
ramindanibab8ba92021-11-18 01:24:11 +0000503
Alec Mouri6a000222024-08-16 23:08:09 +0000504 ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(
505 layer->getWidth(), layer->getHeight(), stride, bytesPerPixel, clientBufData,
506 clientFormat, expectedColors));
ramindanib1144212022-02-10 01:51:24 +0000507 int32_t clientFence;
508 const auto unlockStatus = graphicBuffer->unlockAsync(&clientFence);
509 ASSERT_EQ(::android::OK, unlockStatus);
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400510 mWriter->setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, buffer, clientFence,
Alec Mouri8062f1f2023-09-06 02:14:47 +0000511 clientDataspace, std::vector<common::Rect>(1, damage), 1.f);
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400512 layer->setToClientComposition(*mWriter);
ramindanicdcfcaf2023-11-09 10:00:10 -0800513 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
514 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000515 execute();
ramindanidcecfd42022-02-03 23:52:19 +0000516 changedCompositionTypes = mReader.takeChangedCompositionTypes(getPrimaryDisplayId());
Ady Abraham46219f52021-12-20 09:44:31 -0800517 ASSERT_TRUE(changedCompositionTypes.empty());
ramindanibab8ba92021-11-18 01:24:11 +0000518 }
Ady Abraham3192f3d2021-12-03 16:08:56 -0800519 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000520
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400521 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000522 execute();
523
Ady Abraham3192f3d2021-12-03 16:08:56 -0800524 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000525
526 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
527 }
528}
529
Sally Qi0ca29272024-02-23 11:07:08 -0800530TEST_P(GraphicsCompositionTest, MixedColorSpaces) {
531 ASSERT_TRUE(
532 mComposerClient->setClientTargetSlotCount(getPrimaryDisplayId(), kClientTargetSlotCount)
533 .isOk());
534 const auto& [status, properties] = mComposerClient->getOverlaySupport();
535 if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC &&
536 status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) {
537 GTEST_SUCCEED() << "getOverlaySupport is not supported";
538 return;
539 }
540
541 if (properties.supportMixedColorSpaces == false) {
542 GTEST_SUCCEED() << "supportMixedColorSpaces is not supported";
543 return;
544 }
545
546 for (ColorMode mode : mTestColorModes) {
547 EXPECT_TRUE(mComposerClient
548 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
549 .isOk());
550
551 bool isSupported;
552 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
553 if (!isSupported) {
554 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
555 return;
556 }
557
558 // sRGB layer
559 auto srgbLayer = std::make_shared<TestBufferLayer>(
560 mComposerClient, *mTestRenderEngine, getPrimaryDisplayId(), getDisplayWidth(),
561 getDisplayHeight() / 2, PixelFormat::RGBA_8888, *mWriter);
562 std::vector<Color> sRgbDeviceColors(srgbLayer->getWidth() * srgbLayer->getHeight());
563 ReadbackHelper::fillColorsArea(sRgbDeviceColors, getDisplayWidth(),
564 {0, 0, static_cast<int32_t>(srgbLayer->getWidth()),
565 static_cast<int32_t>(srgbLayer->getHeight())},
566 GREEN);
567 srgbLayer->setDisplayFrame({0, 0, static_cast<int32_t>(srgbLayer->getWidth()),
568 static_cast<int32_t>(srgbLayer->getHeight())});
569 srgbLayer->setZOrder(10);
570 srgbLayer->setDataspace(Dataspace::SRGB);
571 ASSERT_NO_FATAL_FAILURE(srgbLayer->setBuffer(sRgbDeviceColors));
572
573 // display P3 layer
574 auto displayP3Layer = std::make_shared<TestBufferLayer>(
575 mComposerClient, *mTestRenderEngine, getPrimaryDisplayId(), getDisplayWidth(),
576 getDisplayHeight() / 2, PixelFormat::RGBA_8888, *mWriter);
577 std::vector<Color> displayP3DeviceColors(
578 static_cast<size_t>(displayP3Layer->getWidth() * displayP3Layer->getHeight()));
579 ReadbackHelper::fillColorsArea(displayP3DeviceColors, getDisplayWidth(),
580 {0, 0, static_cast<int32_t>(displayP3Layer->getWidth()),
581 static_cast<int32_t>(displayP3Layer->getHeight())},
582 RED);
583 displayP3Layer->setDisplayFrame(
584 {0, getDisplayHeight() / 2, getDisplayWidth(), getDisplayHeight()});
585 displayP3Layer->setZOrder(10);
586 displayP3Layer->setDataspace(Dataspace::DISPLAY_P3);
587 ASSERT_NO_FATAL_FAILURE(displayP3Layer->setBuffer(displayP3DeviceColors));
588
589 writeLayers({srgbLayer, displayP3Layer});
590
591 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
592 VtsComposerClient::kNoFrameIntervalNs);
593 execute();
594
595 auto changedCompositionTypes = mReader.takeChangedCompositionTypes(getPrimaryDisplayId());
596 ASSERT_TRUE(changedCompositionTypes.empty());
597
598 mWriter->presentDisplay(getPrimaryDisplayId());
599 execute();
600
601 changedCompositionTypes = mReader.takeChangedCompositionTypes(getPrimaryDisplayId());
602 ASSERT_TRUE(changedCompositionTypes.empty());
603 ASSERT_TRUE(mReader.takeErrors().empty());
604 }
605}
606
ramindanibab8ba92021-11-18 01:24:11 +0000607TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
ramindanidcecfd42022-02-03 23:52:19 +0000608 ASSERT_TRUE(
609 mComposerClient->setClientTargetSlotCount(getPrimaryDisplayId(), kClientTargetSlotCount)
610 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000611
612 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +0000613 EXPECT_TRUE(mComposerClient
614 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
615 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000616
ramindani44c952f2022-02-28 23:29:29 +0000617 bool isSupported;
618 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000619 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +0000620 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
621 return;
622 }
623
ramindanidcecfd42022-02-03 23:52:19 +0000624 std::vector<Color> expectedColors(
625 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
626 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
627 {0, 0, getDisplayWidth(), getDisplayHeight() / 2}, GREEN);
628 ReadbackHelper::fillColorsArea(
629 expectedColors, getDisplayWidth(),
630 {0, getDisplayHeight() / 2, getDisplayWidth(), getDisplayHeight()}, RED);
ramindanibab8ba92021-11-18 01:24:11 +0000631
ramindanidcecfd42022-02-03 23:52:19 +0000632 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -0700633 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +0000634 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
635
636 auto deviceLayer = std::make_shared<TestBufferLayer>(
ramindani0a2bee42022-02-10 01:27:42 +0000637 mComposerClient, *mTestRenderEngine, getPrimaryDisplayId(), getDisplayWidth(),
Ady Abrahama00d2462023-12-26 14:21:20 -0800638 getDisplayHeight() / 2, PixelFormat::RGBA_8888, *mWriter);
ramindanibab8ba92021-11-18 01:24:11 +0000639 std::vector<Color> deviceColors(deviceLayer->getWidth() * deviceLayer->getHeight());
640 ReadbackHelper::fillColorsArea(deviceColors, static_cast<int32_t>(deviceLayer->getWidth()),
641 {0, 0, static_cast<int32_t>(deviceLayer->getWidth()),
642 static_cast<int32_t>(deviceLayer->getHeight())},
643 GREEN);
644 deviceLayer->setDisplayFrame({0, 0, static_cast<int32_t>(deviceLayer->getWidth()),
645 static_cast<int32_t>(deviceLayer->getHeight())});
646 deviceLayer->setZOrder(10);
Alec Mourif6c039a2023-10-06 23:02:17 +0000647 deviceLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode));
ramindanibab8ba92021-11-18 01:24:11 +0000648 ASSERT_NO_FATAL_FAILURE(deviceLayer->setBuffer(deviceColors));
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400649 deviceLayer->write(*mWriter);
ramindanibab8ba92021-11-18 01:24:11 +0000650
651 PixelFormat clientFormat = PixelFormat::RGBA_8888;
Brian Lindahle887a252023-01-17 14:54:19 -0700652 auto clientUsage = static_cast<uint32_t>(
653 static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
654 static_cast<uint32_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
655 static_cast<uint32_t>(common::BufferUsage::COMPOSER_CLIENT_TARGET));
ramindanibab8ba92021-11-18 01:24:11 +0000656 Dataspace clientDataspace = ReadbackHelper::getDataspaceForColorMode(mode);
ramindanidcecfd42022-02-03 23:52:19 +0000657 int32_t clientWidth = getDisplayWidth();
658 int32_t clientHeight = getDisplayHeight() / 2;
ramindanibab8ba92021-11-18 01:24:11 +0000659
660 auto clientLayer = std::make_shared<TestBufferLayer>(
ramindani0a2bee42022-02-10 01:27:42 +0000661 mComposerClient, *mTestRenderEngine, getPrimaryDisplayId(), clientWidth,
Ady Abrahama00d2462023-12-26 14:21:20 -0800662 clientHeight, PixelFormat::RGBA_FP16, *mWriter, Composition::DEVICE);
ramindanidcecfd42022-02-03 23:52:19 +0000663 common::Rect clientFrame = {0, getDisplayHeight() / 2, getDisplayWidth(),
664 getDisplayHeight()};
ramindanibab8ba92021-11-18 01:24:11 +0000665 clientLayer->setDisplayFrame(clientFrame);
666 clientLayer->setZOrder(0);
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400667 clientLayer->write(*mWriter);
ramindanicdcfcaf2023-11-09 10:00:10 -0800668 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
669 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000670 execute();
671
ramindanidcecfd42022-02-03 23:52:19 +0000672 auto changedCompositionTypes = mReader.takeChangedCompositionTypes(getPrimaryDisplayId());
Ady Abraham3192f3d2021-12-03 16:08:56 -0800673 if (changedCompositionTypes.size() != 1) {
ramindanibab8ba92021-11-18 01:24:11 +0000674 continue;
675 }
676 // create client target buffer
Ady Abraham46219f52021-12-20 09:44:31 -0800677 ASSERT_EQ(Composition::CLIENT, changedCompositionTypes[0].composition);
Brian Lindahle887a252023-01-17 14:54:19 -0700678 const auto& [graphicBufferStatus, graphicBuffer] = allocateBuffer(clientUsage);
679 ASSERT_TRUE(graphicBufferStatus);
ramindani0a2bee42022-02-10 01:27:42 +0000680 const auto& buffer = graphicBuffer->handle;
ramindanibab8ba92021-11-18 01:24:11 +0000681
682 void* clientBufData;
Alec Mouri6a000222024-08-16 23:08:09 +0000683 int bytesPerPixel = -1;
684 int bytesPerStride = -1;
ramindani0a2bee42022-02-10 01:27:42 +0000685 graphicBuffer->lock(clientUsage, {0, 0, getDisplayWidth(), getDisplayHeight()},
Alec Mouri6a000222024-08-16 23:08:09 +0000686 &clientBufData, &bytesPerPixel, &bytesPerStride);
ramindanibab8ba92021-11-18 01:24:11 +0000687
ramindanidcecfd42022-02-03 23:52:19 +0000688 std::vector<Color> clientColors(
689 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
690 ReadbackHelper::fillColorsArea(clientColors, getDisplayWidth(), clientFrame, RED);
ramindanibab8ba92021-11-18 01:24:11 +0000691 ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(
ramindanidcecfd42022-02-03 23:52:19 +0000692 static_cast<uint32_t>(getDisplayWidth()), static_cast<uint32_t>(getDisplayHeight()),
Alec Mouri6a000222024-08-16 23:08:09 +0000693 graphicBuffer->getStride(), bytesPerPixel, clientBufData, clientFormat,
694 clientColors));
ramindanib1144212022-02-10 01:51:24 +0000695 int32_t clientFence;
696 const auto unlockStatus = graphicBuffer->unlockAsync(&clientFence);
697 ASSERT_EQ(::android::OK, unlockStatus);
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400698 mWriter->setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, buffer, clientFence,
Alec Mouri8062f1f2023-09-06 02:14:47 +0000699 clientDataspace, std::vector<common::Rect>(1, clientFrame), 1.f);
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400700 clientLayer->setToClientComposition(*mWriter);
ramindanicdcfcaf2023-11-09 10:00:10 -0800701 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
702 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000703 execute();
ramindanidcecfd42022-02-03 23:52:19 +0000704 changedCompositionTypes = mReader.takeChangedCompositionTypes(getPrimaryDisplayId());
Ady Abraham46219f52021-12-20 09:44:31 -0800705 ASSERT_TRUE(changedCompositionTypes.empty());
Ady Abraham3192f3d2021-12-03 16:08:56 -0800706 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000707
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400708 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000709 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800710 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000711 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
712 }
713}
714
715TEST_P(GraphicsCompositionTest, SetLayerDamage) {
716 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +0000717 EXPECT_TRUE(mComposerClient
718 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
719 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000720
ramindani44c952f2022-02-28 23:29:29 +0000721 bool isSupported;
722 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000723 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +0000724 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
725 return;
726 }
727
ramindanidcecfd42022-02-03 23:52:19 +0000728 common::Rect redRect = {0, 0, getDisplayWidth() / 4, getDisplayHeight() / 4};
ramindanibab8ba92021-11-18 01:24:11 +0000729
ramindanidcecfd42022-02-03 23:52:19 +0000730 std::vector<Color> expectedColors(
731 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
732 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), redRect, RED);
ramindanibab8ba92021-11-18 01:24:11 +0000733
Ady Abrahama00d2462023-12-26 14:21:20 -0800734 auto layer = std::make_shared<TestBufferLayer>(
735 mComposerClient, *mTestRenderEngine, getPrimaryDisplayId(), getDisplayWidth(),
736 getDisplayHeight(), PixelFormat::RGBA_8888, *mWriter);
ramindanidcecfd42022-02-03 23:52:19 +0000737 layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()});
ramindanibab8ba92021-11-18 01:24:11 +0000738 layer->setZOrder(10);
Alec Mourif6c039a2023-10-06 23:02:17 +0000739 layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode));
ramindanibab8ba92021-11-18 01:24:11 +0000740 ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors));
741
742 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
743
ramindanidcecfd42022-02-03 23:52:19 +0000744 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -0700745 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +0000746 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
747
748 writeLayers(layers);
Ady Abraham3192f3d2021-12-03 16:08:56 -0800749 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -0800750 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
751 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000752 execute();
ramindanidcecfd42022-02-03 23:52:19 +0000753 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +0000754 GTEST_SUCCEED();
755 return;
756 }
Ady Abraham3192f3d2021-12-03 16:08:56 -0800757 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400758 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000759 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800760 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000761
762 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
763
764 // update surface damage and recheck
ramindanidcecfd42022-02-03 23:52:19 +0000765 redRect = {getDisplayWidth() / 4, getDisplayHeight() / 4, getDisplayWidth() / 2,
766 getDisplayHeight() / 2};
767 ReadbackHelper::clearColors(expectedColors, getDisplayWidth(), getDisplayHeight(),
768 getDisplayWidth());
769 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), redRect, RED);
ramindanibab8ba92021-11-18 01:24:11 +0000770
771 ASSERT_NO_FATAL_FAILURE(layer->fillBuffer(expectedColors));
772 layer->setSurfaceDamage(
ramindanidcecfd42022-02-03 23:52:19 +0000773 std::vector<common::Rect>(1, {0, 0, getDisplayWidth() / 2, getDisplayWidth() / 2}));
ramindanibab8ba92021-11-18 01:24:11 +0000774
775 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
776
777 writeLayers(layers);
Ady Abraham3192f3d2021-12-03 16:08:56 -0800778 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -0800779 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
780 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000781 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800782 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanidcecfd42022-02-03 23:52:19 +0000783 ASSERT_TRUE(mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400784 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000785 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800786 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000787
788 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
789 }
790}
791
792TEST_P(GraphicsCompositionTest, SetLayerPlaneAlpha) {
793 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +0000794 EXPECT_TRUE(mComposerClient
795 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
796 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000797
ramindani44c952f2022-02-28 23:29:29 +0000798 bool isSupported;
799 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000800 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +0000801 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
802 return;
803 }
804
Ady Abrahama00d2462023-12-26 14:21:20 -0800805 auto layer =
806 std::make_shared<TestColorLayer>(mComposerClient, getPrimaryDisplayId(), *mWriter);
ramindanibab8ba92021-11-18 01:24:11 +0000807 layer->setColor(RED);
ramindanidcecfd42022-02-03 23:52:19 +0000808 layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()});
ramindanibab8ba92021-11-18 01:24:11 +0000809 layer->setZOrder(10);
810 layer->setAlpha(0);
811 layer->setBlendMode(BlendMode::PREMULTIPLIED);
812
813 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
814
ramindanidcecfd42022-02-03 23:52:19 +0000815 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -0700816 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +0000817
818 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
819
820 writeLayers(layers);
Ady Abraham3192f3d2021-12-03 16:08:56 -0800821 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -0800822 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
823 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000824 execute();
ramindanidcecfd42022-02-03 23:52:19 +0000825 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +0000826 GTEST_SUCCEED();
827 return;
828 }
Ady Abraham3192f3d2021-12-03 16:08:56 -0800829 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000830
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400831 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000832 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800833 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000834
ramindanidcecfd42022-02-03 23:52:19 +0000835 std::vector<Color> expectedColors(
836 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
ramindanibab8ba92021-11-18 01:24:11 +0000837
838 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
839 mTestRenderEngine->setRenderLayers(layers);
840 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
841 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
842 }
843}
844
845TEST_P(GraphicsCompositionTest, SetLayerSourceCrop) {
846 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +0000847 EXPECT_TRUE(mComposerClient
848 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
849 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000850
ramindani44c952f2022-02-28 23:29:29 +0000851 bool isSupported;
852 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000853 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +0000854 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
855 return;
856 }
857
ramindanidcecfd42022-02-03 23:52:19 +0000858 std::vector<Color> expectedColors(
859 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
860 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
861 {0, 0, getDisplayWidth(), getDisplayHeight() / 4}, RED);
862 ReadbackHelper::fillColorsArea(
863 expectedColors, getDisplayWidth(),
864 {0, getDisplayHeight() / 2, getDisplayWidth(), getDisplayHeight()}, BLUE);
ramindanibab8ba92021-11-18 01:24:11 +0000865
Ady Abrahama00d2462023-12-26 14:21:20 -0800866 auto layer = std::make_shared<TestBufferLayer>(
867 mComposerClient, *mTestRenderEngine, getPrimaryDisplayId(), getDisplayWidth(),
868 getDisplayHeight(), PixelFormat::RGBA_8888, *mWriter);
ramindanidcecfd42022-02-03 23:52:19 +0000869 layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()});
ramindanibab8ba92021-11-18 01:24:11 +0000870 layer->setZOrder(10);
Alec Mourif6c039a2023-10-06 23:02:17 +0000871 layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode));
ramindanidcecfd42022-02-03 23:52:19 +0000872 layer->setSourceCrop({0, static_cast<float>(getDisplayHeight() / 2),
873 static_cast<float>(getDisplayWidth()),
874 static_cast<float>(getDisplayHeight())});
ramindanibab8ba92021-11-18 01:24:11 +0000875 ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors));
876
877 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
878
879 // update expected colors to match crop
ramindanidcecfd42022-02-03 23:52:19 +0000880 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
881 {0, 0, getDisplayWidth(), getDisplayHeight()}, BLUE);
882 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -0700883 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +0000884 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
885 writeLayers(layers);
Ady Abraham3192f3d2021-12-03 16:08:56 -0800886 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -0800887 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
888 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000889 execute();
ramindanidcecfd42022-02-03 23:52:19 +0000890 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +0000891 GTEST_SUCCEED();
892 return;
893 }
Ady Abraham3192f3d2021-12-03 16:08:56 -0800894 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400895 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000896 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800897 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000898 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
899 mTestRenderEngine->setRenderLayers(layers);
900 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
901 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
902 }
903}
904
905TEST_P(GraphicsCompositionTest, SetLayerZOrder) {
906 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +0000907 EXPECT_TRUE(mComposerClient
908 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
909 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +0000910
ramindani44c952f2022-02-28 23:29:29 +0000911 bool isSupported;
912 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000913 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +0000914 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
915 return;
916 }
917
ramindanidcecfd42022-02-03 23:52:19 +0000918 common::Rect redRect = {0, 0, getDisplayWidth(), getDisplayHeight() / 2};
919 common::Rect blueRect = {0, getDisplayHeight() / 4, getDisplayWidth(), getDisplayHeight()};
Ady Abrahama00d2462023-12-26 14:21:20 -0800920 auto redLayer =
921 std::make_shared<TestColorLayer>(mComposerClient, getPrimaryDisplayId(), *mWriter);
ramindanibab8ba92021-11-18 01:24:11 +0000922 redLayer->setColor(RED);
923 redLayer->setDisplayFrame(redRect);
924
Ady Abrahama00d2462023-12-26 14:21:20 -0800925 auto blueLayer =
926 std::make_shared<TestColorLayer>(mComposerClient, getPrimaryDisplayId(), *mWriter);
ramindanibab8ba92021-11-18 01:24:11 +0000927 blueLayer->setColor(BLUE);
928 blueLayer->setDisplayFrame(blueRect);
929 blueLayer->setZOrder(5);
930
931 std::vector<std::shared_ptr<TestLayer>> layers = {redLayer, blueLayer};
ramindanidcecfd42022-02-03 23:52:19 +0000932 std::vector<Color> expectedColors(
933 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
ramindanibab8ba92021-11-18 01:24:11 +0000934
935 // red in front of blue
936 redLayer->setZOrder(10);
937
938 // fill blue first so that red will overwrite on overlap
ramindanidcecfd42022-02-03 23:52:19 +0000939 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), blueRect, BLUE);
940 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), redRect, RED);
ramindanibab8ba92021-11-18 01:24:11 +0000941
ramindanidcecfd42022-02-03 23:52:19 +0000942 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -0700943 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +0000944 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
945
946 writeLayers(layers);
Ady Abraham3192f3d2021-12-03 16:08:56 -0800947 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -0800948 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
949 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000950 execute();
ramindanidcecfd42022-02-03 23:52:19 +0000951 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +0000952 GTEST_SUCCEED();
953 return;
954 }
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400955 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000956 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800957 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000958
959 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
960
961 redLayer->setZOrder(1);
ramindanidcecfd42022-02-03 23:52:19 +0000962 ReadbackHelper::clearColors(expectedColors, getDisplayWidth(), getDisplayHeight(),
963 getDisplayWidth());
964 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), redRect, RED);
965 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), blueRect, BLUE);
ramindanibab8ba92021-11-18 01:24:11 +0000966
967 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
968
969 writeLayers(layers);
Ady Abraham3192f3d2021-12-03 16:08:56 -0800970 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -0800971 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
972 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +0000973 execute();
ramindanidcecfd42022-02-03 23:52:19 +0000974 ASSERT_TRUE(mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty());
Ady Abraham3192f3d2021-12-03 16:08:56 -0800975 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -0400976 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +0000977 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -0800978 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +0000979
980 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
981 mTestRenderEngine->setRenderLayers(layers);
982 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
983 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
984 }
985}
986
Alec Mourib1f16722022-02-07 13:03:44 -0800987TEST_P(GraphicsCompositionTest, SetLayerBrightnessDims) {
Alec Mouri51067012022-01-06 17:28:39 -0800988 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +0000989 EXPECT_TRUE(mComposerClient
990 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
991 .isOk());
Alec Mouri51067012022-01-06 17:28:39 -0800992
ramindani44c952f2022-02-28 23:29:29 +0000993 bool isSupported;
994 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +0000995 if (!isSupported) {
Alec Mouri51067012022-01-06 17:28:39 -0800996 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace for "
997 "color mode: "
998 << toString(mode);
999 continue;
1000 }
ramindanidcecfd42022-02-03 23:52:19 +00001001 const common::Rect redRect = {0, 0, getDisplayWidth(), getDisplayHeight() / 2};
1002 const common::Rect dimmerRedRect = {0, getDisplayHeight() / 2, getDisplayWidth(),
1003 getDisplayHeight()};
Alec Mouri712b3d92023-09-29 00:21:37 +00001004
1005 static constexpr float kMaxBrightnessNits = 300.f;
1006
ramindanidcecfd42022-02-03 23:52:19 +00001007 const auto redLayer =
Ady Abrahama00d2462023-12-26 14:21:20 -08001008 std::make_shared<TestColorLayer>(mComposerClient, getPrimaryDisplayId(), *mWriter);
Alec Mouri51067012022-01-06 17:28:39 -08001009 redLayer->setColor(RED);
1010 redLayer->setDisplayFrame(redRect);
Alec Mouri712b3d92023-09-29 00:21:37 +00001011 redLayer->setWhitePointNits(kMaxBrightnessNits);
Alec Mourib1f16722022-02-07 13:03:44 -08001012 redLayer->setBrightness(1.f);
Alec Mouri51067012022-01-06 17:28:39 -08001013
1014 const auto dimmerRedLayer =
Ady Abrahama00d2462023-12-26 14:21:20 -08001015 std::make_shared<TestColorLayer>(mComposerClient, getPrimaryDisplayId(), *mWriter);
Alec Mouri51067012022-01-06 17:28:39 -08001016 dimmerRedLayer->setColor(RED);
1017 dimmerRedLayer->setDisplayFrame(dimmerRedRect);
1018 // Intentionally use a small dimming ratio as some implementations may be more likely to
1019 // kick into GPU composition to apply dithering when the dimming ratio is high.
1020 static constexpr float kDimmingRatio = 0.9f;
Alec Mouri712b3d92023-09-29 00:21:37 +00001021 dimmerRedLayer->setWhitePointNits(kMaxBrightnessNits * kDimmingRatio);
Alec Mourib1f16722022-02-07 13:03:44 -08001022 dimmerRedLayer->setBrightness(kDimmingRatio);
Alec Mouri51067012022-01-06 17:28:39 -08001023
1024 const std::vector<std::shared_ptr<TestLayer>> layers = {redLayer, dimmerRedLayer};
ramindanidcecfd42022-02-03 23:52:19 +00001025 std::vector<Color> expectedColors(
1026 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
Alec Mouri51067012022-01-06 17:28:39 -08001027
ramindanidcecfd42022-02-03 23:52:19 +00001028 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), redRect, RED);
1029 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(), dimmerRedRect, DIM_RED);
Alec Mouri51067012022-01-06 17:28:39 -08001030
ramindanidcecfd42022-02-03 23:52:19 +00001031 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -07001032 getDisplayHeight(), mPixelFormat, mDataspace);
Alec Mouri51067012022-01-06 17:28:39 -08001033 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1034
1035 writeLayers(layers);
1036 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -08001037 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
1038 VtsComposerClient::kNoFrameIntervalNs);
Alec Mouri51067012022-01-06 17:28:39 -08001039 execute();
ramindanidcecfd42022-02-03 23:52:19 +00001040 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
Alec Mouri51067012022-01-06 17:28:39 -08001041 GTEST_SUCCEED()
1042 << "Readback verification not supported for GPU composition for color mode: "
1043 << toString(mode);
1044 continue;
1045 }
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -04001046 mWriter->presentDisplay(getPrimaryDisplayId());
Alec Mouri51067012022-01-06 17:28:39 -08001047 execute();
1048 ASSERT_TRUE(mReader.takeErrors().empty());
1049
1050 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1051 mTestRenderEngine->setRenderLayers(layers);
1052 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1053 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1054 }
1055}
1056
ramindanibab8ba92021-11-18 01:24:11 +00001057class GraphicsBlendModeCompositionTest
1058 : public GraphicsCompositionTestBase,
1059 public testing::WithParamInterface<std::tuple<std::string, std::string>> {
1060 public:
1061 void SetUp() override {
1062 SetUpBase(std::get<0>(GetParam()));
ramindanib636af22022-02-10 02:55:56 +00001063 // TODO(b/219590743) we should remove the below SRGB color mode
1064 // once we have the BlendMode test fix for all the versions of the ColorMode
ramindania4e76362022-03-02 01:48:06 +00001065 mTestColorModes.erase(
1066 std::remove_if(mTestColorModes.begin(), mTestColorModes.end(),
1067 [](ColorMode mode) { return mode != ColorMode::SRGB; }),
1068 mTestColorModes.end());
ramindanibab8ba92021-11-18 01:24:11 +00001069 mBackgroundColor = BLACK;
1070 mTopLayerColor = RED;
1071 }
1072
1073 void setBackgroundColor(Color color) { mBackgroundColor = color; }
1074
1075 void setTopLayerColor(Color color) { mTopLayerColor = color; }
1076
1077 void setUpLayers(BlendMode blendMode) {
1078 mLayers.clear();
ramindanidcecfd42022-02-03 23:52:19 +00001079 std::vector<Color> topLayerPixelColors(
1080 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
1081 ReadbackHelper::fillColorsArea(topLayerPixelColors, getDisplayWidth(),
1082 {0, 0, getDisplayWidth(), getDisplayHeight()},
1083 mTopLayerColor);
ramindanibab8ba92021-11-18 01:24:11 +00001084
ramindanidcecfd42022-02-03 23:52:19 +00001085 auto backgroundLayer =
Ady Abrahama00d2462023-12-26 14:21:20 -08001086 std::make_shared<TestColorLayer>(mComposerClient, getPrimaryDisplayId(), *mWriter);
ramindanidcecfd42022-02-03 23:52:19 +00001087 backgroundLayer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()});
ramindanibab8ba92021-11-18 01:24:11 +00001088 backgroundLayer->setZOrder(0);
1089 backgroundLayer->setColor(mBackgroundColor);
1090
Ady Abrahama00d2462023-12-26 14:21:20 -08001091 auto layer = std::make_shared<TestBufferLayer>(
1092 mComposerClient, *mTestRenderEngine, getPrimaryDisplayId(), getDisplayWidth(),
1093 getDisplayHeight(), PixelFormat::RGBA_8888, *mWriter);
ramindanidcecfd42022-02-03 23:52:19 +00001094 layer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()});
ramindanibab8ba92021-11-18 01:24:11 +00001095 layer->setZOrder(10);
Alec Mourif6c039a2023-10-06 23:02:17 +00001096 layer->setDataspace(Dataspace::UNKNOWN);
ramindanibab8ba92021-11-18 01:24:11 +00001097 ASSERT_NO_FATAL_FAILURE(layer->setBuffer(topLayerPixelColors));
1098
1099 layer->setBlendMode(blendMode);
1100 layer->setAlpha(std::stof(std::get<1>(GetParam())));
1101
1102 mLayers.push_back(backgroundLayer);
1103 mLayers.push_back(layer);
1104 }
1105
1106 void setExpectedColors(std::vector<Color>& expectedColors) {
1107 ASSERT_EQ(2, mLayers.size());
ramindanidcecfd42022-02-03 23:52:19 +00001108 ReadbackHelper::clearColors(expectedColors, getDisplayWidth(), getDisplayHeight(),
1109 getDisplayWidth());
ramindanibab8ba92021-11-18 01:24:11 +00001110
1111 auto layer = mLayers[1];
1112 BlendMode blendMode = layer->getBlendMode();
Ady Abraham1bee7ab2022-01-06 17:22:08 -08001113 float alpha = mTopLayerColor.a * layer->getAlpha();
ramindanibab8ba92021-11-18 01:24:11 +00001114 if (blendMode == BlendMode::NONE) {
1115 for (auto& expectedColor : expectedColors) {
Ady Abraham1bee7ab2022-01-06 17:22:08 -08001116 expectedColor.r = mTopLayerColor.r * layer->getAlpha();
1117 expectedColor.g = mTopLayerColor.g * layer->getAlpha();
1118 expectedColor.b = mTopLayerColor.b * layer->getAlpha();
1119 expectedColor.a = alpha;
ramindanibab8ba92021-11-18 01:24:11 +00001120 }
1121 } else if (blendMode == BlendMode::PREMULTIPLIED) {
1122 for (auto& expectedColor : expectedColors) {
Ady Abraham1bee7ab2022-01-06 17:22:08 -08001123 expectedColor.r =
1124 mTopLayerColor.r * layer->getAlpha() + mBackgroundColor.r * (1.0f - alpha);
1125 expectedColor.g =
1126 mTopLayerColor.g * layer->getAlpha() + mBackgroundColor.g * (1.0f - alpha);
1127 expectedColor.b =
1128 mTopLayerColor.b * layer->getAlpha() + mBackgroundColor.b * (1.0f - alpha);
1129 expectedColor.a = alpha + mBackgroundColor.a * (1.0f - alpha);
ramindanibab8ba92021-11-18 01:24:11 +00001130 }
1131 } else if (blendMode == BlendMode::COVERAGE) {
1132 for (auto& expectedColor : expectedColors) {
Ady Abraham1bee7ab2022-01-06 17:22:08 -08001133 expectedColor.r = mTopLayerColor.r * alpha + mBackgroundColor.r * (1.0f - alpha);
1134 expectedColor.g = mTopLayerColor.g * alpha + mBackgroundColor.g * (1.0f - alpha);
1135 expectedColor.b = mTopLayerColor.b * alpha + mBackgroundColor.b * (1.0f - alpha);
1136 expectedColor.a = mTopLayerColor.a * alpha + mBackgroundColor.a * (1.0f - alpha);
ramindanibab8ba92021-11-18 01:24:11 +00001137 }
1138 }
1139 }
1140
1141 protected:
1142 std::vector<std::shared_ptr<TestLayer>> mLayers;
1143 Color mBackgroundColor;
1144 Color mTopLayerColor;
1145};
ramindanic7585d92022-04-15 18:30:41 +00001146
1147TEST_P(GraphicsBlendModeCompositionTest, None) {
ramindanibab8ba92021-11-18 01:24:11 +00001148 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +00001149 EXPECT_TRUE(mComposerClient
1150 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
1151 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +00001152
ramindani44c952f2022-02-28 23:29:29 +00001153 bool isSupported;
1154 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +00001155 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +00001156 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1157 return;
1158 }
1159
ramindanidcecfd42022-02-03 23:52:19 +00001160 std::vector<Color> expectedColors(
1161 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
ramindanibab8ba92021-11-18 01:24:11 +00001162
1163 setBackgroundColor(BLACK);
1164 setTopLayerColor(TRANSLUCENT_RED);
1165 setUpLayers(BlendMode::NONE);
1166 setExpectedColors(expectedColors);
1167
ramindanidcecfd42022-02-03 23:52:19 +00001168 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -07001169 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +00001170 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1171 writeLayers(mLayers);
Ady Abraham3192f3d2021-12-03 16:08:56 -08001172 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -08001173 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
1174 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +00001175 execute();
ramindanidcecfd42022-02-03 23:52:19 +00001176 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +00001177 GTEST_SUCCEED();
1178 return;
1179 }
Ady Abraham3192f3d2021-12-03 16:08:56 -08001180 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -04001181 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +00001182 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -08001183 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +00001184
1185 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1186 mTestRenderEngine->setRenderLayers(mLayers);
1187 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1188 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1189 }
1190}
1191
ramindani07e6f842022-02-15 15:28:33 +00001192TEST_P(GraphicsBlendModeCompositionTest, Coverage) {
ramindanibab8ba92021-11-18 01:24:11 +00001193 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +00001194 EXPECT_TRUE(mComposerClient
1195 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
1196 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +00001197
ramindani44c952f2022-02-28 23:29:29 +00001198 bool isSupported;
1199 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +00001200 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +00001201 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1202 return;
1203 }
1204
ramindanidcecfd42022-02-03 23:52:19 +00001205 std::vector<Color> expectedColors(
1206 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
ramindanibab8ba92021-11-18 01:24:11 +00001207
1208 setBackgroundColor(BLACK);
1209 setTopLayerColor(TRANSLUCENT_RED);
1210
1211 setUpLayers(BlendMode::COVERAGE);
1212 setExpectedColors(expectedColors);
1213
ramindanidcecfd42022-02-03 23:52:19 +00001214 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -07001215 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +00001216 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1217 writeLayers(mLayers);
Ady Abraham3192f3d2021-12-03 16:08:56 -08001218 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -08001219 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
1220 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +00001221 execute();
ramindanidcecfd42022-02-03 23:52:19 +00001222 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +00001223 GTEST_SUCCEED();
1224 return;
1225 }
Ady Abraham3192f3d2021-12-03 16:08:56 -08001226 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -04001227 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +00001228 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -08001229 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +00001230 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1231 }
1232}
1233
1234TEST_P(GraphicsBlendModeCompositionTest, Premultiplied) {
1235 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +00001236 EXPECT_TRUE(mComposerClient
1237 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
1238 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +00001239
ramindani44c952f2022-02-28 23:29:29 +00001240 bool isSupported;
1241 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +00001242 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +00001243 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1244 return;
1245 }
ramindanibab8ba92021-11-18 01:24:11 +00001246
ramindanidcecfd42022-02-03 23:52:19 +00001247 std::vector<Color> expectedColors(
1248 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
ramindanibab8ba92021-11-18 01:24:11 +00001249
1250 setBackgroundColor(BLACK);
1251 setTopLayerColor(TRANSLUCENT_RED);
1252 setUpLayers(BlendMode::PREMULTIPLIED);
1253 setExpectedColors(expectedColors);
1254
ramindanidcecfd42022-02-03 23:52:19 +00001255 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -07001256 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +00001257 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1258 writeLayers(mLayers);
Ady Abraham3192f3d2021-12-03 16:08:56 -08001259 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -08001260 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
1261 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +00001262 execute();
ramindanidcecfd42022-02-03 23:52:19 +00001263 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +00001264 GTEST_SUCCEED();
1265 return;
1266 }
Ady Abraham3192f3d2021-12-03 16:08:56 -08001267 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -04001268 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +00001269 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -08001270 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +00001271 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1272 mTestRenderEngine->setRenderLayers(mLayers);
1273 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1274 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1275 }
1276}
1277
1278class GraphicsTransformCompositionTest : public GraphicsCompositionTest {
1279 protected:
1280 void SetUp() override {
1281 GraphicsCompositionTest::SetUp();
Ady Abraham3192f3d2021-12-03 16:08:56 -08001282
ramindanidcecfd42022-02-03 23:52:19 +00001283 auto backgroundLayer =
Ady Abrahama00d2462023-12-26 14:21:20 -08001284 std::make_shared<TestColorLayer>(mComposerClient, getPrimaryDisplayId(), *mWriter);
Ady Abraham1bee7ab2022-01-06 17:22:08 -08001285 backgroundLayer->setColor({0.0f, 0.0f, 0.0f, 0.0f});
ramindanidcecfd42022-02-03 23:52:19 +00001286 backgroundLayer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()});
ramindanibab8ba92021-11-18 01:24:11 +00001287 backgroundLayer->setZOrder(0);
1288
ramindanidcecfd42022-02-03 23:52:19 +00001289 mSideLength =
1290 getDisplayWidth() < getDisplayHeight() ? getDisplayWidth() : getDisplayHeight();
ramindanibab8ba92021-11-18 01:24:11 +00001291 common::Rect redRect = {0, 0, mSideLength / 2, mSideLength / 2};
1292 common::Rect blueRect = {mSideLength / 2, mSideLength / 2, mSideLength, mSideLength};
1293
ramindani0a2bee42022-02-10 01:27:42 +00001294 mLayer = std::make_shared<TestBufferLayer>(mComposerClient, *mTestRenderEngine,
1295 getPrimaryDisplayId(), mSideLength, mSideLength,
Ady Abrahama00d2462023-12-26 14:21:20 -08001296 PixelFormat::RGBA_8888, *mWriter);
ramindanibab8ba92021-11-18 01:24:11 +00001297 mLayer->setDisplayFrame({0, 0, mSideLength, mSideLength});
1298 mLayer->setZOrder(10);
1299
1300 std::vector<Color> baseColors(static_cast<size_t>(mSideLength * mSideLength));
1301 ReadbackHelper::fillColorsArea(baseColors, mSideLength, redRect, RED);
1302 ReadbackHelper::fillColorsArea(baseColors, mSideLength, blueRect, BLUE);
1303 ASSERT_NO_FATAL_FAILURE(mLayer->setBuffer(baseColors));
1304 mLayers = {backgroundLayer, mLayer};
1305 }
1306
1307 protected:
1308 std::shared_ptr<TestBufferLayer> mLayer;
1309 std::vector<std::shared_ptr<TestLayer>> mLayers;
1310 int mSideLength;
1311};
1312
1313TEST_P(GraphicsTransformCompositionTest, FLIP_H) {
1314 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +00001315 auto status = mComposerClient->setColorMode(getPrimaryDisplayId(), mode,
1316 RenderIntent::COLORIMETRIC);
ramindanid5751092022-04-22 22:30:20 +00001317 if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC &&
ramindanidcecfd42022-02-03 23:52:19 +00001318 (status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED ||
1319 status.getServiceSpecificError() == IComposerClient::EX_BAD_PARAMETER)) {
ramindanibab8ba92021-11-18 01:24:11 +00001320 SUCCEED() << "ColorMode not supported, skip test";
1321 return;
1322 }
1323
ramindani44c952f2022-02-28 23:29:29 +00001324 bool isSupported;
1325 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +00001326 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +00001327 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1328 return;
1329 }
ramindanidcecfd42022-02-03 23:52:19 +00001330 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -07001331 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +00001332 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1333 mLayer->setTransform(Transform::FLIP_H);
Alec Mourif6c039a2023-10-06 23:02:17 +00001334 mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode));
ramindanibab8ba92021-11-18 01:24:11 +00001335
ramindanidcecfd42022-02-03 23:52:19 +00001336 std::vector<Color> expectedColors(
1337 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
1338 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
ramindanibab8ba92021-11-18 01:24:11 +00001339 {mSideLength / 2, 0, mSideLength, mSideLength / 2}, RED);
ramindanidcecfd42022-02-03 23:52:19 +00001340 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
ramindanibab8ba92021-11-18 01:24:11 +00001341 {0, mSideLength / 2, mSideLength / 2, mSideLength}, BLUE);
1342
1343 writeLayers(mLayers);
Ady Abraham3192f3d2021-12-03 16:08:56 -08001344 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -08001345 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
1346 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +00001347 execute();
ramindanidcecfd42022-02-03 23:52:19 +00001348 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +00001349 GTEST_SUCCEED();
1350 return;
1351 }
Ady Abraham3192f3d2021-12-03 16:08:56 -08001352 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -04001353 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +00001354 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -08001355 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +00001356
1357 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1358 mTestRenderEngine->setRenderLayers(mLayers);
1359 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1360 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1361 }
1362}
1363
1364TEST_P(GraphicsTransformCompositionTest, FLIP_V) {
1365 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +00001366 EXPECT_TRUE(mComposerClient
1367 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
1368 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +00001369
ramindani44c952f2022-02-28 23:29:29 +00001370 bool isSupported;
1371 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +00001372 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +00001373 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1374 return;
1375 }
ramindanidcecfd42022-02-03 23:52:19 +00001376 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -07001377 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +00001378 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1379
1380 mLayer->setTransform(Transform::FLIP_V);
Alec Mourif6c039a2023-10-06 23:02:17 +00001381 mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode));
ramindanibab8ba92021-11-18 01:24:11 +00001382
ramindanidcecfd42022-02-03 23:52:19 +00001383 std::vector<Color> expectedColors(
1384 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
1385 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
ramindanibab8ba92021-11-18 01:24:11 +00001386 {0, mSideLength / 2, mSideLength / 2, mSideLength}, RED);
ramindanidcecfd42022-02-03 23:52:19 +00001387 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
ramindanibab8ba92021-11-18 01:24:11 +00001388 {mSideLength / 2, 0, mSideLength, mSideLength / 2}, BLUE);
1389
1390 writeLayers(mLayers);
Ady Abraham3192f3d2021-12-03 16:08:56 -08001391 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -08001392 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
1393 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +00001394 execute();
ramindanidcecfd42022-02-03 23:52:19 +00001395 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +00001396 GTEST_SUCCEED();
1397 return;
1398 }
Ady Abraham3192f3d2021-12-03 16:08:56 -08001399 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -04001400 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +00001401 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -08001402 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +00001403 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1404 mTestRenderEngine->setRenderLayers(mLayers);
1405 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1406 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1407 }
1408}
1409
1410TEST_P(GraphicsTransformCompositionTest, ROT_180) {
1411 for (ColorMode mode : mTestColorModes) {
ramindanidcecfd42022-02-03 23:52:19 +00001412 EXPECT_TRUE(mComposerClient
1413 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
1414 .isOk());
ramindanibab8ba92021-11-18 01:24:11 +00001415
ramindani44c952f2022-02-28 23:29:29 +00001416 bool isSupported;
1417 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
ramindanidcecfd42022-02-03 23:52:19 +00001418 if (!isSupported) {
ramindanibab8ba92021-11-18 01:24:11 +00001419 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1420 return;
1421 }
ramindanidcecfd42022-02-03 23:52:19 +00001422 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
Brian Lindahle887a252023-01-17 14:54:19 -07001423 getDisplayHeight(), mPixelFormat, mDataspace);
ramindanibab8ba92021-11-18 01:24:11 +00001424 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1425
1426 mLayer->setTransform(Transform::ROT_180);
Alec Mourif6c039a2023-10-06 23:02:17 +00001427 mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode));
ramindanibab8ba92021-11-18 01:24:11 +00001428
ramindanidcecfd42022-02-03 23:52:19 +00001429 std::vector<Color> expectedColors(
1430 static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
1431 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
ramindanibab8ba92021-11-18 01:24:11 +00001432 {mSideLength / 2, mSideLength / 2, mSideLength, mSideLength},
1433 RED);
ramindanidcecfd42022-02-03 23:52:19 +00001434 ReadbackHelper::fillColorsArea(expectedColors, getDisplayWidth(),
ramindanibab8ba92021-11-18 01:24:11 +00001435 {0, 0, mSideLength / 2, mSideLength / 2}, BLUE);
1436
1437 writeLayers(mLayers);
Ady Abraham3192f3d2021-12-03 16:08:56 -08001438 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -08001439 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
1440 VtsComposerClient::kNoFrameIntervalNs);
ramindanibab8ba92021-11-18 01:24:11 +00001441 execute();
ramindanidcecfd42022-02-03 23:52:19 +00001442 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
ramindanibab8ba92021-11-18 01:24:11 +00001443 GTEST_SUCCEED();
1444 return;
1445 }
Ady Abraham3192f3d2021-12-03 16:08:56 -08001446 ASSERT_TRUE(mReader.takeErrors().empty());
Leon Scroggins IIIc3d695d2022-09-16 15:34:59 -04001447 mWriter->presentDisplay(getPrimaryDisplayId());
ramindanibab8ba92021-11-18 01:24:11 +00001448 execute();
Ady Abraham3192f3d2021-12-03 16:08:56 -08001449 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanibab8ba92021-11-18 01:24:11 +00001450 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1451 mTestRenderEngine->setRenderLayers(mLayers);
1452 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1453 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1454 }
1455}
1456
Alec Mourif6c039a2023-10-06 23:02:17 +00001457class GraphicsColorManagementCompositionTest
1458 : public GraphicsCompositionTestBase,
1459 public testing::WithParamInterface<std::tuple<std::string, Dataspace, Dataspace, Dataspace>> {
1460 public:
1461 void SetUp() override {
1462 SetUpBase(std::get<0>(GetParam()));
1463 // for some reason only sRGB reliably works
1464 mTestColorModes.erase(
1465 std::remove_if(mTestColorModes.begin(), mTestColorModes.end(),
1466 [](ColorMode mode) { return mode != ColorMode::SRGB; }),
1467 mTestColorModes.end());
1468 auto standard = std::get<1>(GetParam());
1469 auto transfer = std::get<2>(GetParam());
1470 auto range = std::get<3>(GetParam());
1471
1472 mLayerDataspace = static_cast<Dataspace>(static_cast<int32_t>(standard) |
1473 static_cast<int32_t>(transfer) |
1474 static_cast<int32_t>(range));
1475 ALOGD("Invoking test for dataspace: {%s, %s, %s}", toString(standard).c_str(),
1476 toString(transfer).c_str(), toString(range).c_str());
1477 }
1478
1479 void makeLayer() {
1480 mLayer = std::make_shared<TestBufferLayer>(
1481 mComposerClient, *mTestRenderEngine, getPrimaryDisplayId(), getDisplayWidth(),
Ady Abrahama00d2462023-12-26 14:21:20 -08001482 getDisplayHeight(), common::PixelFormat::RGBA_8888, *mWriter);
Alec Mourif6c039a2023-10-06 23:02:17 +00001483 mLayer->setDisplayFrame({0, 0, getDisplayWidth(), getDisplayHeight()});
1484 mLayer->setZOrder(10);
1485 mLayer->setAlpha(1.f);
1486 mLayer->setDataspace(mLayerDataspace);
1487 }
1488
1489 void fillColor(Color color) {
1490 std::vector<Color> baseColors(static_cast<size_t>(getDisplayWidth() * getDisplayHeight()));
1491 ReadbackHelper::fillColorsArea(baseColors, getDisplayWidth(),
1492 common::Rect{.left = 0,
1493 .top = 0,
1494 .right = getDisplayWidth(),
1495 .bottom = getDisplayHeight()},
1496 color);
1497 ASSERT_NO_FATAL_FAILURE(mLayer->setBuffer(baseColors));
1498 }
1499
1500 Dataspace mLayerDataspace;
1501 std::shared_ptr<TestBufferLayer> mLayer;
1502};
1503
1504TEST_P(GraphicsColorManagementCompositionTest, ColorConversion) {
1505 for (ColorMode mode : mTestColorModes) {
1506 EXPECT_TRUE(mComposerClient
1507 ->setColorMode(getPrimaryDisplayId(), mode, RenderIntent::COLORIMETRIC)
1508 .isOk());
1509
1510 bool isSupported;
1511 ASSERT_NO_FATAL_FAILURE(isSupported = getHasReadbackBuffer());
1512 if (!isSupported) {
1513 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1514 return;
1515 }
1516
1517 mClientCompositionDisplaySettings.outputDataspace =
1518 static_cast<::android::ui::Dataspace>(mDataspace);
1519 mTestRenderEngine->setDisplaySettings(mClientCompositionDisplaySettings);
1520
1521 makeLayer();
1522 for (auto color : {LIGHT_RED, LIGHT_GREEN, LIGHT_BLUE}) {
1523 ALOGD("Testing color: %f, %f, %f, %f with color mode: %d", color.r, color.g, color.b,
1524 color.a, mode);
1525 ReadbackBuffer readbackBuffer(getPrimaryDisplayId(), mComposerClient, getDisplayWidth(),
1526 getDisplayHeight(), mPixelFormat, mDataspace);
1527 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1528 fillColor(color);
1529 writeLayers({mLayer});
1530 EXPECT_TRUE(mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::ON).isOk());
1531
1532 ASSERT_TRUE(mReader.takeErrors().empty());
ramindanicdcfcaf2023-11-09 10:00:10 -08001533 mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
1534 VtsComposerClient::kNoFrameIntervalNs);
Alec Mourif6c039a2023-10-06 23:02:17 +00001535 execute();
1536 if (!mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()) {
1537 continue;
1538 }
1539 ASSERT_TRUE(mReader.takeErrors().empty());
1540 mWriter->presentDisplay(getPrimaryDisplayId());
1541 execute();
1542 ASSERT_TRUE(mReader.takeErrors().empty());
1543
1544 mTestRenderEngine->setRenderLayers({mLayer});
1545 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1546 ASSERT_NO_FATAL_FAILURE(
1547 mTestRenderEngine->checkColorBuffer(readbackBuffer.getBuffer()));
1548 }
1549 }
1550}
1551
ramindanibab8ba92021-11-18 01:24:11 +00001552GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsCompositionTest);
1553INSTANTIATE_TEST_SUITE_P(
1554 PerInstance, GraphicsCompositionTest,
1555 testing::ValuesIn(::android::getAidlHalInstanceNames(IComposer::descriptor)),
1556 ::android::PrintInstanceNameToString);
1557
1558GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsBlendModeCompositionTest);
1559INSTANTIATE_TEST_SUITE_P(BlendMode, GraphicsBlendModeCompositionTest,
1560 testing::Combine(testing::ValuesIn(::android::getAidlHalInstanceNames(
1561 IComposer::descriptor)),
1562 testing::Values("0.2", "1.0")));
1563
1564GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsTransformCompositionTest);
1565INSTANTIATE_TEST_SUITE_P(
1566 PerInstance, GraphicsTransformCompositionTest,
1567 testing::ValuesIn(::android::getAidlHalInstanceNames(IComposer::descriptor)),
1568 ::android::PrintInstanceNameToString);
1569
Alec Mourif6c039a2023-10-06 23:02:17 +00001570GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsColorManagementCompositionTest);
1571INSTANTIATE_TEST_SUITE_P(PerInstance, GraphicsColorManagementCompositionTest,
1572 testing::Combine(testing::ValuesIn(::android::getAidlHalInstanceNames(
1573 IComposer::descriptor)),
1574 // Only check sRGB, but verify that extended range
1575 // doesn't trigger any gamma shifts
1576 testing::Values(Dataspace::STANDARD_BT709),
1577 testing::Values(Dataspace::TRANSFER_SRGB),
1578 // Don't test limited range until we send YUV overlays
1579 testing::Values(Dataspace::RANGE_FULL,
1580 Dataspace::RANGE_EXTENDED)));
1581
ramindanibab8ba92021-11-18 01:24:11 +00001582} // namespace
Ady Abraham3192f3d2021-12-03 16:08:56 -08001583} // namespace aidl::android::hardware::graphics::composer3::vts