1 /*
2 * Copyright 2019 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_hidl_hal_readback_tests@2.2"
18
19 #include <composer-command-buffer/2.2/ComposerCommandBuffer.h>
20 #include <composer-vts/2.1/GraphicsComposerCallback.h>
21 #include <composer-vts/2.1/TestCommandReader.h>
22 #include <composer-vts/2.2/ComposerVts.h>
23 #include <composer-vts/2.2/ReadbackVts.h>
24 #include <composer-vts/2.2/RenderEngineVts.h>
25 #include <gtest/gtest.h>
26 #include <hidl/GtestPrinter.h>
27 #include <hidl/ServiceManagement.h>
28 #include <ui/GraphicBuffer.h>
29 #include <ui/GraphicBufferAllocator.h>
30 #include <ui/PixelFormat.h>
31 #include <ui/Rect.h>
32 #include <ui/Region.h>
33
34 namespace android {
35 namespace hardware {
36 namespace graphics {
37 namespace composer {
38 namespace V2_2 {
39 namespace vts {
40 namespace {
41
42 using android::Rect;
43 using common::V1_1::BufferUsage;
44 using common::V1_1::Dataspace;
45 using common::V1_1::PixelFormat;
46 using V2_1::Config;
47 using V2_1::Display;
48 using V2_1::vts::NativeHandleWrapper;
49 using V2_1::vts::TestCommandReader;
50 using vts::Gralloc;
51
52 class GraphicsCompositionTestBase : public ::testing::Test {
53 protected:
54 using PowerMode = V2_1::IComposerClient::PowerMode;
SetUpBase(const std::string & service_name)55 void SetUpBase(const std::string& service_name) {
56 ASSERT_NO_FATAL_FAILURE(
57 mComposer = std::make_unique<Composer>(IComposer::getService(service_name)));
58 ASSERT_NO_FATAL_FAILURE(mComposerClient = mComposer->createClient());
59 mComposerCallback = new V2_1::vts::GraphicsComposerCallback;
60 mComposerClient->registerCallback(mComposerCallback);
61
62 // assume the first display is primary and is never removed
63 mPrimaryDisplay = waitForFirstDisplay();
64 Config activeConfig;
65 ASSERT_NO_FATAL_FAILURE(activeConfig = mComposerClient->getActiveConfig(mPrimaryDisplay));
66 ASSERT_NO_FATAL_FAILURE(
67 mDisplayWidth = mComposerClient->getDisplayAttribute(
68 mPrimaryDisplay, activeConfig, IComposerClient::Attribute::WIDTH));
69 ASSERT_NO_FATAL_FAILURE(
70 mDisplayHeight = mComposerClient->getDisplayAttribute(
71 mPrimaryDisplay, activeConfig, IComposerClient::Attribute::HEIGHT));
72
73 setTestColorModes();
74
75 // explicitly disable vsync
76 ASSERT_NO_FATAL_FAILURE(mComposerClient->setVsyncEnabled(mPrimaryDisplay, false));
77 mComposerCallback->setVsyncAllowed(false);
78
79 // set up command writer/reader and gralloc
80 mWriter = std::make_shared<CommandWriterBase>(1024);
81 mReader = std::make_unique<TestCommandReader>();
82 mGralloc = std::make_shared<Gralloc>();
83
84 ASSERT_NO_FATAL_FAILURE(mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::ON));
85
86 ASSERT_NO_FATAL_FAILURE(
87 mTestRenderEngine = std::unique_ptr<TestRenderEngine>(new TestRenderEngine(
88 renderengine::RenderEngineCreationArgs::Builder()
89 .setPixelFormat(static_cast<int>(ui::PixelFormat::RGBA_8888))
90 .setImageCacheSize(TestRenderEngine::sMaxFrameBufferAcquireBuffers)
91 .setUseColorManagerment(true)
92 .setEnableProtectedContext(false)
93 .setPrecacheToneMapperShaderOnly(false)
94 .setContextPriority(renderengine::RenderEngine::ContextPriority::HIGH)
95 .build())));
96
97 renderengine::DisplaySettings clientCompositionDisplay;
98 clientCompositionDisplay.physicalDisplay = Rect(mDisplayWidth, mDisplayHeight);
99 clientCompositionDisplay.clip = clientCompositionDisplay.physicalDisplay;
100 clientCompositionDisplay.clearRegion = Region(clientCompositionDisplay.physicalDisplay);
101
102 mTestRenderEngine->initGraphicBuffer(
103 static_cast<uint32_t>(mDisplayWidth), static_cast<uint32_t>(mDisplayHeight), 1,
104 static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
105 BufferUsage::GPU_RENDER_TARGET));
106 mTestRenderEngine->setDisplaySettings(clientCompositionDisplay);
107 }
108
TearDown()109 void TearDown() override {
110 ASSERT_NO_FATAL_FAILURE(mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::OFF));
111 EXPECT_EQ(0, mReader->mErrors.size());
112 EXPECT_EQ(0, mReader->mCompositionChanges.size());
113 if (mComposerCallback != nullptr) {
114 EXPECT_EQ(0, mComposerCallback->getInvalidHotplugCount());
115 EXPECT_EQ(0, mComposerCallback->getInvalidRefreshCount());
116 EXPECT_EQ(0, mComposerCallback->getInvalidVsyncCount());
117 }
118 }
119
clearCommandReaderState()120 void clearCommandReaderState() {
121 mReader->mCompositionChanges.clear();
122 mReader->mErrors.clear();
123 }
124
writeLayers(const std::vector<std::shared_ptr<TestLayer>> & layers)125 void writeLayers(const std::vector<std::shared_ptr<TestLayer>>& layers) {
126 for (auto layer : layers) {
127 layer->write(mWriter);
128 }
129 execute();
130 }
131
execute()132 void execute() {
133 ASSERT_NO_FATAL_FAILURE(mComposerClient->execute(mReader.get(), mWriter.get()));
134 }
135
136 std::unique_ptr<Composer> mComposer;
137 std::shared_ptr<ComposerClient> mComposerClient;
138
139 sp<V2_1::vts::GraphicsComposerCallback> mComposerCallback;
140 // the first display and is assumed never to be removed
141 Display mPrimaryDisplay;
142 int32_t mDisplayWidth;
143 int32_t mDisplayHeight;
144 std::vector<ColorMode> mTestColorModes;
145 std::shared_ptr<CommandWriterBase> mWriter;
146 std::unique_ptr<TestCommandReader> mReader;
147 std::shared_ptr<Gralloc> mGralloc;
148 std::unique_ptr<TestRenderEngine> mTestRenderEngine;
149
150 bool mHasReadbackBuffer;
151 PixelFormat mPixelFormat;
152 Dataspace mDataspace;
153
154 static constexpr uint32_t kClientTargetSlotCount = 64;
155
156 private:
waitForFirstDisplay()157 Display waitForFirstDisplay() {
158 while (true) {
159 std::vector<Display> displays = mComposerCallback->getDisplays();
160 if (displays.empty()) {
161 usleep(5 * 1000);
162 continue;
163 }
164 return displays[0];
165 }
166 }
167
setTestColorModes()168 void setTestColorModes() {
169 mTestColorModes.clear();
170 mComposerClient->getRaw()->getColorModes_2_2(mPrimaryDisplay, [&](const auto& tmpError,
171 const auto& tmpModes) {
172 ASSERT_EQ(Error::NONE, tmpError);
173 for (ColorMode mode : tmpModes) {
174 if (std::find(ReadbackHelper::colorModes.begin(), ReadbackHelper::colorModes.end(),
175 mode) != ReadbackHelper::colorModes.end()) {
176 mTestColorModes.push_back(mode);
177 }
178 }
179 });
180 }
181 };
182
183 class GraphicsCompositionTest : public GraphicsCompositionTestBase,
184 public testing::WithParamInterface<std::string> {
185 public:
SetUp()186 void SetUp() override { SetUpBase(GetParam()); }
187 };
188
TEST_P(GraphicsCompositionTest,SingleSolidColorLayer)189 TEST_P(GraphicsCompositionTest, SingleSolidColorLayer) {
190 for (ColorMode mode : mTestColorModes) {
191 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
192 << std::endl;
193 mWriter->selectDisplay(mPrimaryDisplay);
194 ASSERT_NO_FATAL_FAILURE(
195 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
196
197 mComposerClient->getRaw()->getReadbackBufferAttributes(
198 mPrimaryDisplay,
199 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
200 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
201 tmpDataspace, tmpError);
202 mPixelFormat = tmpPixelFormat;
203 mDataspace = tmpDataspace;
204 });
205
206 if (!mHasReadbackBuffer) {
207 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
208 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
209 return;
210 }
211
212 auto layer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
213 IComposerClient::Rect coloredSquare({0, 0, mDisplayWidth, mDisplayHeight});
214 layer->setColor(BLUE);
215 layer->setDisplayFrame(coloredSquare);
216 layer->setZOrder(10);
217
218 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
219
220 // expected color for each pixel
221 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
222 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, coloredSquare, BLUE);
223
224 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
225 mDisplayHeight, mPixelFormat, mDataspace);
226 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
227
228 writeLayers(layers);
229 ASSERT_EQ(0, mReader->mErrors.size());
230 mWriter->validateDisplay();
231 execute();
232 // if hwc cannot handle and asks for composition change,
233 // just succeed the test
234 if (mReader->mCompositionChanges.size() != 0) {
235 clearCommandReaderState();
236 GTEST_SUCCEED();
237 return;
238 }
239 ASSERT_EQ(0, mReader->mErrors.size());
240 mWriter->presentDisplay();
241 execute();
242 ASSERT_EQ(0, mReader->mErrors.size());
243
244 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
245 mTestRenderEngine->setRenderLayers(layers);
246 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
247 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
248 }
249 }
250
TEST_P(GraphicsCompositionTest,SetLayerBuffer)251 TEST_P(GraphicsCompositionTest, SetLayerBuffer) {
252 for (ColorMode mode : mTestColorModes) {
253 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
254 << std::endl;
255 mWriter->selectDisplay(mPrimaryDisplay);
256 ASSERT_NO_FATAL_FAILURE(
257 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
258
259 mComposerClient->getRaw()->getReadbackBufferAttributes(
260 mPrimaryDisplay,
261 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
262 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
263 tmpDataspace, tmpError);
264 mPixelFormat = tmpPixelFormat;
265 mDataspace = tmpDataspace;
266 });
267
268 if (!mHasReadbackBuffer) {
269 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
270 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
271 return;
272 }
273
274 mWriter->selectDisplay(mPrimaryDisplay);
275
276 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
277 mDisplayHeight, mPixelFormat, mDataspace);
278 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
279 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
280 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
281 {0, 0, mDisplayWidth, mDisplayHeight / 4}, RED);
282 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
283 {0, mDisplayHeight / 4, mDisplayWidth, mDisplayHeight / 2},
284 GREEN);
285 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
286 {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight},
287 BLUE);
288
289 auto layer = std::make_shared<TestBufferLayer>(
290 mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
291 mDisplayHeight, PixelFormat::RGBA_8888);
292 layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
293 layer->setZOrder(10);
294 layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
295 ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors));
296
297 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
298
299 writeLayers(layers);
300 ASSERT_EQ(0, mReader->mErrors.size());
301 mWriter->validateDisplay();
302 execute();
303
304 if (mReader->mCompositionChanges.size() != 0) {
305 clearCommandReaderState();
306 GTEST_SUCCEED();
307 return;
308 }
309 ASSERT_EQ(0, mReader->mErrors.size());
310
311 mWriter->presentDisplay();
312 execute();
313
314 ASSERT_EQ(0, mReader->mErrors.size());
315
316 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
317 mTestRenderEngine->setRenderLayers(layers);
318 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
319 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
320 }
321 }
322
TEST_P(GraphicsCompositionTest,SetLayerBufferNoEffect)323 TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
324 for (ColorMode mode : mTestColorModes) {
325 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
326 << std::endl;
327 mWriter->selectDisplay(mPrimaryDisplay);
328 ASSERT_NO_FATAL_FAILURE(
329 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
330
331 mComposerClient->getRaw()->getReadbackBufferAttributes(
332 mPrimaryDisplay,
333 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
334 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
335 tmpDataspace, tmpError);
336 mPixelFormat = tmpPixelFormat;
337 mDataspace = tmpDataspace;
338 });
339
340 if (!mHasReadbackBuffer) {
341 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
342 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
343 return;
344 }
345
346 auto layer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
347 IComposerClient::Rect coloredSquare({0, 0, mDisplayWidth, mDisplayHeight});
348 layer->setColor(BLUE);
349 layer->setDisplayFrame(coloredSquare);
350 layer->setZOrder(10);
351 layer->write(mWriter);
352
353 // This following buffer call should have no effect
354 uint64_t usage =
355 static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN);
356 NativeHandleWrapper bufferHandle =
357 mGralloc->allocate(mDisplayWidth, mDisplayHeight, 1, PixelFormat::RGBA_8888, usage);
358 mWriter->setLayerBuffer(0, bufferHandle.get(), -1);
359
360 // expected color for each pixel
361 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
362 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, coloredSquare, BLUE);
363
364 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
365 mDisplayHeight, mPixelFormat, mDataspace);
366 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
367
368 mWriter->validateDisplay();
369 execute();
370
371 if (mReader->mCompositionChanges.size() != 0) {
372 clearCommandReaderState();
373 GTEST_SUCCEED();
374 return;
375 }
376 ASSERT_EQ(0, mReader->mErrors.size());
377 mWriter->presentDisplay();
378 execute();
379 ASSERT_EQ(0, mReader->mErrors.size());
380
381 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
382 }
383 }
384
TEST_P(GraphicsCompositionTest,ClientComposition)385 TEST_P(GraphicsCompositionTest, ClientComposition) {
386 ASSERT_NO_FATAL_FAILURE(
387 mComposerClient->setClientTargetSlotCount(mPrimaryDisplay, kClientTargetSlotCount));
388
389 for (ColorMode mode : mTestColorModes) {
390 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
391 << std::endl;
392 mWriter->selectDisplay(mPrimaryDisplay);
393 ASSERT_NO_FATAL_FAILURE(
394 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
395
396 mComposerClient->getRaw()->getReadbackBufferAttributes(
397 mPrimaryDisplay,
398 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
399 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
400 tmpDataspace, tmpError);
401 mPixelFormat = tmpPixelFormat;
402 mDataspace = tmpDataspace;
403 });
404
405 if (!mHasReadbackBuffer) {
406 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
407 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
408 return;
409 }
410
411 mWriter->selectDisplay(mPrimaryDisplay);
412
413 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
414 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
415 {0, 0, mDisplayWidth, mDisplayHeight / 4}, RED);
416 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
417 {0, mDisplayHeight / 4, mDisplayWidth, mDisplayHeight / 2},
418 GREEN);
419 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
420 {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight},
421 BLUE);
422
423 auto layer = std::make_shared<TestBufferLayer>(
424 mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
425 mDisplayHeight, PixelFormat::RGBA_FP16);
426 layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
427 layer->setZOrder(10);
428 layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
429
430 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
431
432 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
433 mDisplayHeight, mPixelFormat, mDataspace);
434 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
435 writeLayers(layers);
436 ASSERT_EQ(0, mReader->mErrors.size());
437 mWriter->validateDisplay();
438 execute();
439
440 if (mReader->mCompositionChanges.size() != 0) {
441 ASSERT_EQ(1, mReader->mCompositionChanges.size());
442 ASSERT_EQ(1, mReader->mCompositionChanges[0].second);
443
444 PixelFormat clientFormat = PixelFormat::RGBA_8888;
445 uint64_t clientUsage = static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN |
446 BufferUsage::CPU_WRITE_OFTEN |
447 BufferUsage::COMPOSER_CLIENT_TARGET);
448 Dataspace clientDataspace = ReadbackHelper::getDataspaceForColorMode(mode);
449 IComposerClient::Rect damage{0, 0, mDisplayWidth, mDisplayHeight};
450
451 bool clientTargetSupported = mComposerClient->getClientTargetSupport_2_2(
452 mPrimaryDisplay, layer->mWidth, layer->mHeight, clientFormat, clientDataspace);
453 // if the client target format is not supported, skip this
454 // configuration
455 if (!clientTargetSupported) {
456 std::cout << "Client target configuration width: " << layer->mWidth
457 << " height: " << layer->mHeight
458 << " pixel format: PixelFormat::RGBA_8888 dataspace: "
459 << ReadbackHelper::getDataspaceString(clientDataspace)
460 << " unsupported for display" << std::endl;
461 mReader->mCompositionChanges.clear();
462 continue;
463 }
464
465 // create client target buffer
466 uint32_t clientStride;
467 NativeHandleWrapper clientBufferHandle =
468 mGralloc->allocate(layer->mWidth, layer->mHeight, layer->mLayerCount,
469 clientFormat, clientUsage, /*import*/ true, &clientStride);
470 ASSERT_NE(nullptr, clientBufferHandle.get());
471
472 void* clientBufData =
473 mGralloc->lock(clientBufferHandle.get(), clientUsage, layer->mAccessRegion, -1);
474
475 ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(layer->mWidth, layer->mHeight,
476 clientStride, clientBufData,
477 clientFormat, expectedColors));
478 int clientFence = mGralloc->unlock(clientBufferHandle.get());
479 if (clientFence != -1) {
480 sync_wait(clientFence, -1);
481 close(clientFence);
482 }
483
484 mWriter->setClientTarget(0, clientBufferHandle.get(), clientFence, clientDataspace,
485 std::vector<IComposerClient::Rect>(1, damage));
486
487 layer->setToClientComposition(mWriter);
488 mWriter->validateDisplay();
489 execute();
490 ASSERT_EQ(0, mReader->mCompositionChanges.size());
491 }
492 ASSERT_EQ(0, mReader->mErrors.size());
493
494 mWriter->presentDisplay();
495 execute();
496
497 ASSERT_EQ(0, mReader->mErrors.size());
498
499 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
500 }
501 }
502
TEST_P(GraphicsCompositionTest,DeviceAndClientComposition)503 TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
504 ASSERT_NO_FATAL_FAILURE(
505 mComposerClient->setClientTargetSlotCount(mPrimaryDisplay, kClientTargetSlotCount));
506
507 for (ColorMode mode : mTestColorModes) {
508 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
509 << std::endl;
510 mWriter->selectDisplay(mPrimaryDisplay);
511 ASSERT_NO_FATAL_FAILURE(
512 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
513
514 mComposerClient->getRaw()->getReadbackBufferAttributes(
515 mPrimaryDisplay,
516 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
517 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
518 tmpDataspace, tmpError);
519 mPixelFormat = tmpPixelFormat;
520 mDataspace = tmpDataspace;
521 });
522
523 if (!mHasReadbackBuffer) {
524 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
525 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
526 return;
527 }
528
529 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
530 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
531 {0, 0, mDisplayWidth, mDisplayHeight / 2}, GREEN);
532 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
533 {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight}, RED);
534
535 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
536 mDisplayHeight, mPixelFormat, mDataspace);
537 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
538
539 auto deviceLayer = std::make_shared<TestBufferLayer>(
540 mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
541 mDisplayHeight / 2, PixelFormat::RGBA_8888);
542 std::vector<IComposerClient::Color> deviceColors(deviceLayer->mWidth *
543 deviceLayer->mHeight);
544 ReadbackHelper::fillColorsArea(deviceColors, deviceLayer->mWidth,
545 {0, 0, static_cast<int32_t>(deviceLayer->mWidth),
546 static_cast<int32_t>(deviceLayer->mHeight)},
547 GREEN);
548 deviceLayer->setDisplayFrame({0, 0, static_cast<int32_t>(deviceLayer->mWidth),
549 static_cast<int32_t>(deviceLayer->mHeight)});
550 deviceLayer->setZOrder(10);
551 deviceLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
552 ASSERT_NO_FATAL_FAILURE(deviceLayer->setBuffer(deviceColors));
553 deviceLayer->write(mWriter);
554
555 PixelFormat clientFormat = PixelFormat::RGBA_8888;
556 uint64_t clientUsage =
557 static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
558 BufferUsage::COMPOSER_CLIENT_TARGET);
559 Dataspace clientDataspace = ReadbackHelper::getDataspaceForColorMode(mode);
560 int32_t clientWidth = mDisplayWidth;
561 int32_t clientHeight = mDisplayHeight / 2;
562
563 bool clientTargetSupported = mComposerClient->getClientTargetSupport_2_2(
564 mPrimaryDisplay, clientWidth, clientHeight, clientFormat, clientDataspace);
565 // if the client target format is not supported, skip this
566 // configuration
567 if (!clientTargetSupported) {
568 std::cout << "Client target configuration width: " << clientWidth
569 << " height: " << clientHeight
570 << " pixel format: PixelFormat::RGBA_8888 dataspace: "
571 << ReadbackHelper::getDataspaceString(clientDataspace)
572 << " unsupported for display" << std::endl;
573 continue;
574 }
575
576 auto clientLayer = std::make_shared<TestBufferLayer>(
577 mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, clientWidth,
578 clientHeight, PixelFormat::RGBA_FP16, IComposerClient::Composition::DEVICE);
579 IComposerClient::Rect clientFrame = {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight};
580 clientLayer->setDisplayFrame(clientFrame);
581 clientLayer->setZOrder(0);
582 clientLayer->write(mWriter);
583 mWriter->validateDisplay();
584 execute();
585
586 if (mReader->mCompositionChanges.size() != 1) {
587 std::cout << "HWC asked for none or more than 1 composition change, skipping"
588 << std::endl;
589 mReader->mCompositionChanges.clear();
590 continue;
591 }
592 // create client target buffer
593 ASSERT_EQ(1, mReader->mCompositionChanges[0].second);
594 uint32_t clientStride;
595 NativeHandleWrapper clientBufferHandle =
596 mGralloc->allocate(mDisplayWidth, mDisplayHeight, clientLayer->mLayerCount,
597 clientFormat, clientUsage, /*import*/ true, &clientStride);
598 ASSERT_NE(nullptr, clientBufferHandle.get());
599
600 void* clientBufData = mGralloc->lock(clientBufferHandle.get(), clientUsage,
601 {0, 0, mDisplayWidth, mDisplayHeight}, -1);
602
603 std::vector<IComposerClient::Color> clientColors(mDisplayWidth * mDisplayHeight);
604 ReadbackHelper::fillColorsArea(clientColors, mDisplayWidth, clientFrame, RED);
605 ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(mDisplayWidth, mDisplayHeight,
606 clientStride, clientBufData,
607 clientFormat, clientColors));
608 int clientFence = mGralloc->unlock(clientBufferHandle.get());
609 if (clientFence != -1) {
610 sync_wait(clientFence, -1);
611 close(clientFence);
612 }
613
614 mWriter->setClientTarget(0, clientBufferHandle.get(), clientFence, clientDataspace,
615 std::vector<IComposerClient::Rect>(1, clientFrame));
616 clientLayer->setToClientComposition(mWriter);
617 mWriter->validateDisplay();
618 execute();
619 ASSERT_EQ(0, mReader->mCompositionChanges.size());
620 ASSERT_EQ(0, mReader->mErrors.size());
621
622 mWriter->presentDisplay();
623 execute();
624 ASSERT_EQ(0, mReader->mErrors.size());
625 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
626 }
627 }
628
TEST_P(GraphicsCompositionTest,SetLayerDamage)629 TEST_P(GraphicsCompositionTest, SetLayerDamage) {
630 for (ColorMode mode : mTestColorModes) {
631 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
632 << std::endl;
633 mWriter->selectDisplay(mPrimaryDisplay);
634 ASSERT_NO_FATAL_FAILURE(
635 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
636
637 mComposerClient->getRaw()->getReadbackBufferAttributes(
638 mPrimaryDisplay,
639 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
640 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
641 tmpDataspace, tmpError);
642 mPixelFormat = tmpPixelFormat;
643 mDataspace = tmpDataspace;
644 });
645
646 if (!mHasReadbackBuffer) {
647 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
648 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
649 return;
650 }
651
652 mWriter->selectDisplay(mPrimaryDisplay);
653
654 IComposerClient::Rect redRect = {0, 0, mDisplayWidth / 4, mDisplayHeight / 4};
655
656 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
657 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
658
659 auto layer = std::make_shared<TestBufferLayer>(
660 mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
661 mDisplayHeight, PixelFormat::RGBA_8888);
662 layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
663 layer->setZOrder(10);
664 layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
665 ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors));
666
667 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
668
669 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
670 mDisplayHeight, mPixelFormat, mDataspace);
671 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
672
673 writeLayers(layers);
674 ASSERT_EQ(0, mReader->mErrors.size());
675 mWriter->validateDisplay();
676 execute();
677 if (mReader->mCompositionChanges.size() != 0) {
678 clearCommandReaderState();
679 GTEST_SUCCEED();
680 return;
681 }
682 ASSERT_EQ(0, mReader->mErrors.size());
683 mWriter->presentDisplay();
684 execute();
685 ASSERT_EQ(0, mReader->mErrors.size());
686
687 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
688
689 // update surface damage and recheck
690 redRect = {mDisplayWidth / 4, mDisplayHeight / 4, mDisplayWidth / 2, mDisplayHeight / 2};
691 ReadbackHelper::clearColors(expectedColors, mDisplayWidth, mDisplayHeight, mDisplayWidth);
692 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
693
694 ASSERT_NO_FATAL_FAILURE(layer->fillBuffer(expectedColors));
695 layer->setSurfaceDamage(std::vector<IComposerClient::Rect>(
696 1, {0, 0, mDisplayWidth / 2, mDisplayWidth / 2}));
697
698 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
699
700 writeLayers(layers);
701 ASSERT_EQ(0, mReader->mErrors.size());
702 mWriter->validateDisplay();
703 execute();
704 ASSERT_EQ(0, mReader->mErrors.size());
705 ASSERT_EQ(0, mReader->mCompositionChanges.size());
706 mWriter->presentDisplay();
707 execute();
708 ASSERT_EQ(0, mReader->mErrors.size());
709
710 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
711 }
712 }
713
TEST_P(GraphicsCompositionTest,SetLayerPlaneAlpha)714 TEST_P(GraphicsCompositionTest, SetLayerPlaneAlpha) {
715 for (ColorMode mode : mTestColorModes) {
716 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
717 << std::endl;
718 mWriter->selectDisplay(mPrimaryDisplay);
719 ASSERT_NO_FATAL_FAILURE(
720 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
721
722 mComposerClient->getRaw()->getReadbackBufferAttributes(
723 mPrimaryDisplay,
724 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
725 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
726 tmpDataspace, tmpError);
727 mPixelFormat = tmpPixelFormat;
728 mDataspace = tmpDataspace;
729 });
730
731 if (!mHasReadbackBuffer) {
732 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
733 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
734 return;
735 }
736
737 auto layer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
738 layer->setColor(RED);
739 layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
740 layer->setZOrder(10);
741 layer->setAlpha(0);
742 layer->setBlendMode(IComposerClient::BlendMode::PREMULTIPLIED);
743
744 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
745
746 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
747 mDisplayHeight, mPixelFormat, mDataspace);
748
749 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
750
751 writeLayers(layers);
752 ASSERT_EQ(0, mReader->mErrors.size());
753 mWriter->validateDisplay();
754 execute();
755 if (mReader->mCompositionChanges.size() != 0) {
756 clearCommandReaderState();
757 GTEST_SUCCEED();
758 return;
759 }
760 ASSERT_EQ(0, mReader->mErrors.size());
761
762 mWriter->presentDisplay();
763 execute();
764 ASSERT_EQ(0, mReader->mErrors.size());
765
766 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
767
768 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
769 mTestRenderEngine->setRenderLayers(layers);
770 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
771 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
772 }
773 }
774
TEST_P(GraphicsCompositionTest,SetLayerSourceCrop)775 TEST_P(GraphicsCompositionTest, SetLayerSourceCrop) {
776 for (ColorMode mode : mTestColorModes) {
777 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
778 << std::endl;
779 mWriter->selectDisplay(mPrimaryDisplay);
780 ASSERT_NO_FATAL_FAILURE(
781 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
782
783 mComposerClient->getRaw()->getReadbackBufferAttributes(
784 mPrimaryDisplay,
785 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
786 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
787 tmpDataspace, tmpError);
788 mPixelFormat = tmpPixelFormat;
789 mDataspace = tmpDataspace;
790 });
791
792 if (!mHasReadbackBuffer) {
793 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
794 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
795 return;
796 }
797
798 mWriter->selectDisplay(mPrimaryDisplay);
799
800 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
801 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
802 {0, 0, mDisplayWidth, mDisplayHeight / 4}, RED);
803 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
804 {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight},
805 BLUE);
806
807 auto layer = std::make_shared<TestBufferLayer>(
808 mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
809 mDisplayHeight, PixelFormat::RGBA_8888);
810 layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
811 layer->setZOrder(10);
812 layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
813 layer->setSourceCrop({0, static_cast<float>(mDisplayHeight / 2),
814 static_cast<float>(mDisplayWidth),
815 static_cast<float>(mDisplayHeight)});
816 ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors));
817
818 std::vector<std::shared_ptr<TestLayer>> layers = {layer};
819
820 // update expected colors to match crop
821 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
822 {0, 0, mDisplayWidth, mDisplayHeight}, BLUE);
823 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
824 mDisplayHeight, mPixelFormat, mDataspace);
825 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
826 writeLayers(layers);
827 ASSERT_EQ(0, mReader->mErrors.size());
828 mWriter->validateDisplay();
829 execute();
830 if (mReader->mCompositionChanges.size() != 0) {
831 clearCommandReaderState();
832 GTEST_SUCCEED();
833 return;
834 }
835 ASSERT_EQ(0, mReader->mErrors.size());
836 mWriter->presentDisplay();
837 execute();
838 ASSERT_EQ(0, mReader->mErrors.size());
839 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
840 mTestRenderEngine->setRenderLayers(layers);
841 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
842 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
843 }
844 }
845
TEST_P(GraphicsCompositionTest,SetLayerZOrder)846 TEST_P(GraphicsCompositionTest, SetLayerZOrder) {
847 for (ColorMode mode : mTestColorModes) {
848 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
849 << std::endl;
850 mWriter->selectDisplay(mPrimaryDisplay);
851 ASSERT_NO_FATAL_FAILURE(
852 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
853
854 mComposerClient->getRaw()->getReadbackBufferAttributes(
855 mPrimaryDisplay,
856 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
857 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
858 tmpDataspace, tmpError);
859 mPixelFormat = tmpPixelFormat;
860 mDataspace = tmpDataspace;
861 });
862
863 if (!mHasReadbackBuffer) {
864 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
865 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
866 return;
867 }
868
869 IComposerClient::Rect redRect = {0, 0, mDisplayWidth, mDisplayHeight / 2};
870 IComposerClient::Rect blueRect = {0, mDisplayHeight / 4, mDisplayWidth, mDisplayHeight};
871 auto redLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
872 redLayer->setColor(RED);
873 redLayer->setDisplayFrame(redRect);
874
875 auto blueLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
876 blueLayer->setColor(BLUE);
877 blueLayer->setDisplayFrame(blueRect);
878 blueLayer->setZOrder(5);
879
880 std::vector<std::shared_ptr<TestLayer>> layers = {redLayer, blueLayer};
881 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
882
883 // red in front of blue
884 redLayer->setZOrder(10);
885
886 // fill blue first so that red will overwrite on overlap
887 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, blueRect, BLUE);
888 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
889
890 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
891 mDisplayHeight, mPixelFormat, mDataspace);
892 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
893
894 writeLayers(layers);
895 ASSERT_EQ(0, mReader->mErrors.size());
896 mWriter->validateDisplay();
897 execute();
898 if (mReader->mCompositionChanges.size() != 0) {
899 clearCommandReaderState();
900 GTEST_SUCCEED();
901 return;
902 }
903 mWriter->presentDisplay();
904 execute();
905 ASSERT_EQ(0, mReader->mErrors.size());
906
907 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
908
909 redLayer->setZOrder(1);
910 ReadbackHelper::clearColors(expectedColors, mDisplayWidth, mDisplayHeight, mDisplayWidth);
911 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
912 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, blueRect, BLUE);
913
914 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
915
916 writeLayers(layers);
917 ASSERT_EQ(0, mReader->mErrors.size());
918 mWriter->validateDisplay();
919 execute();
920 ASSERT_EQ(0, mReader->mCompositionChanges.size());
921 ASSERT_EQ(0, mReader->mErrors.size());
922 mWriter->presentDisplay();
923 execute();
924 ASSERT_EQ(0, mReader->mErrors.size());
925
926 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
927 mTestRenderEngine->setRenderLayers(layers);
928 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
929 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
930 }
931 }
932
933 class GraphicsBlendModeCompositionTest
934 : public GraphicsCompositionTestBase,
935 public testing::WithParamInterface<std::tuple<std::string, std::string>> {
936 public:
SetUp()937 void SetUp() override {
938 SetUpBase(std::get<0>(GetParam()));
939 mTestColorModes = {ColorMode::SRGB}; // TODO: add more color mode support
940 mBackgroundColor = BLACK;
941 mTopLayerColor = RED;
942 }
943
setBackgroundColor(IComposerClient::Color color)944 void setBackgroundColor(IComposerClient::Color color) { mBackgroundColor = color; }
945
setTopLayerColor(IComposerClient::Color color)946 void setTopLayerColor(IComposerClient::Color color) { mTopLayerColor = color; }
947
setUpLayers(IComposerClient::BlendMode blendMode)948 void setUpLayers(IComposerClient::BlendMode blendMode) {
949 mLayers.clear();
950 std::vector<IComposerClient::Color> topLayerPixelColors(mDisplayWidth * mDisplayHeight);
951 ReadbackHelper::fillColorsArea(topLayerPixelColors, mDisplayWidth,
952 {0, 0, mDisplayWidth, mDisplayHeight}, mTopLayerColor);
953
954 auto backgroundLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
955 backgroundLayer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
956 backgroundLayer->setZOrder(0);
957 backgroundLayer->setColor(mBackgroundColor);
958
959 auto layer = std::make_shared<TestBufferLayer>(
960 mComposerClient, mGralloc, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
961 mDisplayHeight, PixelFormat::RGBA_8888);
962 layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
963 layer->setZOrder(10);
964 layer->setDataspace(Dataspace::UNKNOWN, mWriter);
965 ASSERT_NO_FATAL_FAILURE(layer->setBuffer(topLayerPixelColors));
966
967 layer->setBlendMode(blendMode);
968 layer->setAlpha(std::stof(std::get<1>(GetParam())));
969
970 mLayers.push_back(backgroundLayer);
971 mLayers.push_back(layer);
972 }
973
setExpectedColors(std::vector<IComposerClient::Color> & expectedColors)974 void setExpectedColors(std::vector<IComposerClient::Color>& expectedColors) {
975 ASSERT_EQ(2, mLayers.size());
976 ReadbackHelper::clearColors(expectedColors, mDisplayWidth, mDisplayHeight, mDisplayWidth);
977
978 auto layer = mLayers[1];
979 IComposerClient::BlendMode blendMode = layer->mBlendMode;
980 float alpha = mTopLayerColor.a / 255.0 * layer->mAlpha;
981 if (blendMode == IComposerClient::BlendMode::NONE) {
982 for (int i = 0; i < expectedColors.size(); i++) {
983 expectedColors[i].r = mTopLayerColor.r * layer->mAlpha;
984 expectedColors[i].g = mTopLayerColor.g * layer->mAlpha;
985 expectedColors[i].b = mTopLayerColor.b * layer->mAlpha;
986 expectedColors[i].a = alpha * 255.0;
987 }
988 } else if (blendMode == IComposerClient::BlendMode::PREMULTIPLIED) {
989 for (int i = 0; i < expectedColors.size(); i++) {
990 expectedColors[i].r =
991 mTopLayerColor.r * layer->mAlpha + mBackgroundColor.r * (1.0 - alpha);
992 expectedColors[i].g =
993 mTopLayerColor.g * layer->mAlpha + mBackgroundColor.g * (1.0 - alpha);
994 expectedColors[i].b =
995 mTopLayerColor.b * layer->mAlpha + mBackgroundColor.b * (1.0 - alpha);
996 expectedColors[i].a = alpha + mBackgroundColor.a * (1.0 - alpha);
997 }
998 } else if (blendMode == IComposerClient::BlendMode::COVERAGE) {
999 for (int i = 0; i < expectedColors.size(); i++) {
1000 expectedColors[i].r = mTopLayerColor.r * alpha + mBackgroundColor.r * (1.0 - alpha);
1001 expectedColors[i].g = mTopLayerColor.g * alpha + mBackgroundColor.g * (1.0 - alpha);
1002 expectedColors[i].b = mTopLayerColor.b * alpha + mBackgroundColor.b * (1.0 - alpha);
1003 expectedColors[i].a = mTopLayerColor.a * alpha + mBackgroundColor.a * (1.0 - alpha);
1004 }
1005 }
1006 }
1007
1008 protected:
1009 std::vector<std::shared_ptr<TestLayer>> mLayers;
1010 IComposerClient::Color mBackgroundColor;
1011 IComposerClient::Color mTopLayerColor;
1012 };
1013
1014 // TODO(b/145557764): Re-enable after the bug is fixed.
TEST_P(GraphicsBlendModeCompositionTest,DISABLED_None)1015 TEST_P(GraphicsBlendModeCompositionTest, DISABLED_None) {
1016 for (ColorMode mode : mTestColorModes) {
1017 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
1018 << std::endl;
1019 mWriter->selectDisplay(mPrimaryDisplay);
1020 ASSERT_NO_FATAL_FAILURE(
1021 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
1022
1023 mComposerClient->getRaw()->getReadbackBufferAttributes(
1024 mPrimaryDisplay,
1025 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
1026 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
1027 tmpDataspace, tmpError);
1028 mPixelFormat = tmpPixelFormat;
1029 mDataspace = tmpDataspace;
1030 });
1031
1032 if (!mHasReadbackBuffer) {
1033 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
1034 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1035 return;
1036 }
1037
1038 mWriter->selectDisplay(mPrimaryDisplay);
1039
1040 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
1041
1042 setBackgroundColor(BLACK);
1043 setTopLayerColor(TRANSLUCENT_RED);
1044 setUpLayers(IComposerClient::BlendMode::NONE);
1045 setExpectedColors(expectedColors);
1046
1047 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
1048 mDisplayHeight, mPixelFormat, mDataspace);
1049 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1050 writeLayers(mLayers);
1051 ASSERT_EQ(0, mReader->mErrors.size());
1052 mWriter->validateDisplay();
1053 execute();
1054 if (mReader->mCompositionChanges.size() != 0) {
1055 clearCommandReaderState();
1056 GTEST_SUCCEED();
1057 return;
1058 }
1059 ASSERT_EQ(0, mReader->mErrors.size());
1060 mWriter->presentDisplay();
1061 execute();
1062 ASSERT_EQ(0, mReader->mErrors.size());
1063
1064 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1065 mTestRenderEngine->setRenderLayers(mLayers);
1066 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1067 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1068 }
1069 }
1070
1071 // TODO: bug 116865056: Readback returns (245, 0, 0) for layer plane
1072 // alpha of .2, expected 10.2
TEST_P(GraphicsBlendModeCompositionTest,DISABLED_Coverage)1073 TEST_P(GraphicsBlendModeCompositionTest, DISABLED_Coverage) {
1074 for (ColorMode mode : mTestColorModes) {
1075 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
1076 << std::endl;
1077 mWriter->selectDisplay(mPrimaryDisplay);
1078 ASSERT_NO_FATAL_FAILURE(
1079 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
1080
1081 mComposerClient->getRaw()->getReadbackBufferAttributes(
1082 mPrimaryDisplay,
1083 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
1084 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
1085 tmpDataspace, tmpError);
1086 mPixelFormat = tmpPixelFormat;
1087 mDataspace = tmpDataspace;
1088 });
1089
1090 if (!mHasReadbackBuffer) {
1091 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
1092 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1093 return;
1094 }
1095
1096 mWriter->selectDisplay(mPrimaryDisplay);
1097
1098 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
1099
1100 setBackgroundColor(BLACK);
1101 setTopLayerColor(TRANSLUCENT_RED);
1102
1103 setUpLayers(IComposerClient::BlendMode::COVERAGE);
1104 setExpectedColors(expectedColors);
1105
1106 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
1107 mDisplayHeight, mPixelFormat, mDataspace);
1108 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1109 writeLayers(mLayers);
1110 ASSERT_EQ(0, mReader->mErrors.size());
1111 mWriter->validateDisplay();
1112 execute();
1113 if (mReader->mCompositionChanges.size() != 0) {
1114 clearCommandReaderState();
1115 GTEST_SUCCEED();
1116 return;
1117 }
1118 ASSERT_EQ(0, mReader->mErrors.size());
1119 mWriter->presentDisplay();
1120 execute();
1121 ASSERT_EQ(0, mReader->mErrors.size());
1122 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1123 }
1124 }
1125
TEST_P(GraphicsBlendModeCompositionTest,Premultiplied)1126 TEST_P(GraphicsBlendModeCompositionTest, Premultiplied) {
1127 for (ColorMode mode : mTestColorModes) {
1128 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
1129 << std::endl;
1130 mWriter->selectDisplay(mPrimaryDisplay);
1131 ASSERT_NO_FATAL_FAILURE(
1132 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
1133
1134 mComposerClient->getRaw()->getReadbackBufferAttributes(
1135 mPrimaryDisplay,
1136 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
1137 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
1138 tmpDataspace, tmpError);
1139 mPixelFormat = tmpPixelFormat;
1140 mDataspace = tmpDataspace;
1141 });
1142
1143 if (!mHasReadbackBuffer) {
1144 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
1145 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1146 return;
1147 }
1148 mWriter->selectDisplay(mPrimaryDisplay);
1149
1150 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
1151
1152 setBackgroundColor(BLACK);
1153 setTopLayerColor(TRANSLUCENT_RED);
1154 setUpLayers(IComposerClient::BlendMode::PREMULTIPLIED);
1155 setExpectedColors(expectedColors);
1156
1157 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
1158 mDisplayHeight, mPixelFormat, mDataspace);
1159 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1160 writeLayers(mLayers);
1161 ASSERT_EQ(0, mReader->mErrors.size());
1162 mWriter->validateDisplay();
1163 execute();
1164 if (mReader->mCompositionChanges.size() != 0) {
1165 clearCommandReaderState();
1166 GTEST_SUCCEED();
1167 return;
1168 }
1169 ASSERT_EQ(0, mReader->mErrors.size());
1170 mWriter->presentDisplay();
1171 execute();
1172 ASSERT_EQ(0, mReader->mErrors.size());
1173 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1174 mTestRenderEngine->setRenderLayers(mLayers);
1175 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1176 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1177 }
1178 }
1179
1180 class GraphicsTransformCompositionTest : public GraphicsCompositionTest {
1181 protected:
SetUp()1182 void SetUp() override {
1183 GraphicsCompositionTest::SetUp();
1184
1185 mWriter->selectDisplay(mPrimaryDisplay);
1186
1187 auto backgroundLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
1188 backgroundLayer->setColor({0, 0, 0, 0});
1189 backgroundLayer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
1190 backgroundLayer->setZOrder(0);
1191
1192 mSideLength = mDisplayWidth < mDisplayHeight ? mDisplayWidth : mDisplayHeight;
1193 IComposerClient::Rect redRect = {0, 0, mSideLength / 2, mSideLength / 2};
1194 IComposerClient::Rect blueRect = {mSideLength / 2, mSideLength / 2, mSideLength,
1195 mSideLength};
1196
1197 mLayer = std::make_shared<TestBufferLayer>(mComposerClient, mGralloc, *mTestRenderEngine,
1198 mPrimaryDisplay, mSideLength, mSideLength,
1199 PixelFormat::RGBA_8888);
1200 mLayer->setDisplayFrame({0, 0, mSideLength, mSideLength});
1201 mLayer->setZOrder(10);
1202
1203 std::vector<IComposerClient::Color> baseColors(mSideLength * mSideLength);
1204 ReadbackHelper::fillColorsArea(baseColors, mSideLength, redRect, RED);
1205 ReadbackHelper::fillColorsArea(baseColors, mSideLength, blueRect, BLUE);
1206 ASSERT_NO_FATAL_FAILURE(mLayer->setBuffer(baseColors));
1207
1208 mLayers = {backgroundLayer, mLayer};
1209 }
1210
1211 protected:
1212 std::shared_ptr<TestBufferLayer> mLayer;
1213 std::vector<IComposerClient::Color> baseColors;
1214 std::vector<std::shared_ptr<TestLayer>> mLayers;
1215 int mSideLength;
1216 };
1217
TEST_P(GraphicsTransformCompositionTest,FLIP_H)1218 TEST_P(GraphicsTransformCompositionTest, FLIP_H) {
1219 for (ColorMode mode : mTestColorModes) {
1220 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
1221 << std::endl;
1222 mWriter->selectDisplay(mPrimaryDisplay);
1223 ASSERT_NO_FATAL_FAILURE(
1224 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
1225
1226 mComposerClient->getRaw()->getReadbackBufferAttributes(
1227 mPrimaryDisplay,
1228 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
1229 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
1230 tmpDataspace, tmpError);
1231 mPixelFormat = tmpPixelFormat;
1232 mDataspace = tmpDataspace;
1233 });
1234
1235 if (!mHasReadbackBuffer) {
1236 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
1237 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1238 return;
1239 }
1240 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
1241 mDisplayHeight, mPixelFormat, mDataspace);
1242 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1243 mLayer->setTransform(Transform::FLIP_H);
1244 mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
1245
1246 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
1247 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
1248 {mSideLength / 2, 0, mSideLength, mSideLength / 2}, RED);
1249 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
1250 {0, mSideLength / 2, mSideLength / 2, mSideLength}, BLUE);
1251
1252 writeLayers(mLayers);
1253 ASSERT_EQ(0, mReader->mErrors.size());
1254 mWriter->validateDisplay();
1255 execute();
1256 if (mReader->mCompositionChanges.size() != 0) {
1257 clearCommandReaderState();
1258 GTEST_SUCCEED();
1259 return;
1260 }
1261 ASSERT_EQ(0, mReader->mErrors.size());
1262 mWriter->presentDisplay();
1263 execute();
1264 ASSERT_EQ(0, mReader->mErrors.size());
1265
1266 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1267 mTestRenderEngine->setRenderLayers(mLayers);
1268 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1269 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1270 }
1271 }
1272
TEST_P(GraphicsTransformCompositionTest,FLIP_V)1273 TEST_P(GraphicsTransformCompositionTest, FLIP_V) {
1274 for (ColorMode mode : mTestColorModes) {
1275 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
1276 << std::endl;
1277 mWriter->selectDisplay(mPrimaryDisplay);
1278 ASSERT_NO_FATAL_FAILURE(
1279 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
1280
1281 mComposerClient->getRaw()->getReadbackBufferAttributes(
1282 mPrimaryDisplay,
1283 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
1284 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
1285 tmpDataspace, tmpError);
1286 mPixelFormat = tmpPixelFormat;
1287 mDataspace = tmpDataspace;
1288 });
1289
1290 if (!mHasReadbackBuffer) {
1291 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
1292 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1293 return;
1294 }
1295 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
1296 mDisplayHeight, mPixelFormat, mDataspace);
1297 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1298
1299 mLayer->setTransform(Transform::FLIP_V);
1300 mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
1301
1302 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
1303 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
1304 {0, mSideLength / 2, mSideLength / 2, mSideLength}, RED);
1305 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
1306 {mSideLength / 2, 0, mSideLength, mSideLength / 2}, BLUE);
1307
1308 writeLayers(mLayers);
1309 ASSERT_EQ(0, mReader->mErrors.size());
1310 mWriter->validateDisplay();
1311 execute();
1312 if (mReader->mCompositionChanges.size() != 0) {
1313 clearCommandReaderState();
1314 GTEST_SUCCEED();
1315 return;
1316 }
1317 ASSERT_EQ(0, mReader->mErrors.size());
1318 mWriter->presentDisplay();
1319 execute();
1320 ASSERT_EQ(0, mReader->mErrors.size());
1321 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1322 mTestRenderEngine->setRenderLayers(mLayers);
1323 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1324 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1325 }
1326 }
1327
TEST_P(GraphicsTransformCompositionTest,ROT_180)1328 TEST_P(GraphicsTransformCompositionTest, ROT_180) {
1329 for (ColorMode mode : mTestColorModes) {
1330 std::cout << "---Testing Color Mode " << ReadbackHelper::getColorModeString(mode) << "---"
1331 << std::endl;
1332 mWriter->selectDisplay(mPrimaryDisplay);
1333 ASSERT_NO_FATAL_FAILURE(
1334 mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
1335
1336 mComposerClient->getRaw()->getReadbackBufferAttributes(
1337 mPrimaryDisplay,
1338 [&](const auto& tmpError, const auto& tmpPixelFormat, const auto& tmpDataspace) {
1339 mHasReadbackBuffer = ReadbackHelper::readbackSupported(tmpPixelFormat,
1340 tmpDataspace, tmpError);
1341 mPixelFormat = tmpPixelFormat;
1342 mDataspace = tmpDataspace;
1343 });
1344
1345 if (!mHasReadbackBuffer) {
1346 std::cout << "Readback not supported or unsupported pixelFormat/dataspace" << std::endl;
1347 GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
1348 return;
1349 }
1350 ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGralloc, mDisplayWidth,
1351 mDisplayHeight, mPixelFormat, mDataspace);
1352 ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
1353
1354 mLayer->setTransform(Transform::ROT_180);
1355 mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
1356
1357 std::vector<IComposerClient::Color> expectedColors(mDisplayWidth * mDisplayHeight);
1358 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
1359 {mSideLength / 2, mSideLength / 2, mSideLength, mSideLength},
1360 RED);
1361 ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
1362 {0, 0, mSideLength / 2, mSideLength / 2}, BLUE);
1363
1364 writeLayers(mLayers);
1365 ASSERT_EQ(0, mReader->mErrors.size());
1366 mWriter->validateDisplay();
1367 execute();
1368 if (mReader->mCompositionChanges.size() != 0) {
1369 clearCommandReaderState();
1370 GTEST_SUCCEED();
1371 return;
1372 }
1373 ASSERT_EQ(0, mReader->mErrors.size());
1374 mWriter->presentDisplay();
1375 execute();
1376 ASSERT_EQ(0, mReader->mErrors.size());
1377 ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
1378 mTestRenderEngine->setRenderLayers(mLayers);
1379 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
1380 ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
1381 }
1382 }
1383
1384 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsCompositionTest);
1385 INSTANTIATE_TEST_SUITE_P(
1386 PerInstance, GraphicsCompositionTest,
1387 testing::ValuesIn(android::hardware::getAllHalInstanceNames(IComposer::descriptor)),
1388 android::hardware::PrintInstanceNameToString);
1389
1390 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsBlendModeCompositionTest);
1391 INSTANTIATE_TEST_CASE_P(
1392 BlendModeTest, GraphicsBlendModeCompositionTest,
1393 testing::Combine(
1394 testing::ValuesIn(android::hardware::getAllHalInstanceNames(IComposer::descriptor)),
1395 testing::Values("0.2", "1.0")),
1396 android::hardware::PrintInstanceTupleNameToString<>);
1397
1398 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsTransformCompositionTest);
1399 INSTANTIATE_TEST_SUITE_P(
1400 PerInstance, GraphicsTransformCompositionTest,
1401 testing::ValuesIn(android::hardware::getAllHalInstanceNames(IComposer::descriptor)),
1402 android::hardware::PrintInstanceNameToString);
1403
1404 } // anonymous namespace
1405 } // namespace vts
1406 } // namespace V2_2
1407 } // namespace composer
1408 } // namespace graphics
1409 } // namespace hardware
1410 } // namespace android
1411