From aebb5db607eddbc032cb42060aa72a96f87dffc1 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 13 Aug 2020 15:52:44 +0900 Subject: [PATCH] DSRenderEngineDaliImpl-test: Add a new testcase for compositing twe windows. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - This test shows a simple compositing of two windows. - The first added windowA was created in 500x500 size and red color. - The second added windowB was created in 250x250 size and blue color. - Since Dali's scene graph traverse method is DFS, windowA added first is rendered first, and windowB is rendered on top of it. ┌─────┬─────┐ │ B │ │ │ blue│ A │ ┣─────┘ │ │ red │ │   │ └───────────┘ Change-Id: I7b0807ebd5e9c4c41983f7830f5041dad700b3d6 Signed-off-by: Joonbum Ko --- tests/DSRenderEngineDaliImpl-test.cpp | 96 +++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index 8fb3a41..8cc94d0 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -212,3 +212,99 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) usleep(1000000); } } + +TEST_F(DSRenderEngineDaliTest, RenderEngine_ComposeTwoWindow) +{ + std::unique_ptr displayDevice = std::make_unique(); + std::list> outputList = displayDevice->getOutputList(); + EXPECT_TRUE(outputList.size() != 0); + + IDSDisplayDeviceOutput::ConnectorType connType; + IDSDisplayDeviceOutput::ConnectState connState; + std::shared_ptr deviceHWC; + + for (std::shared_ptr output : outputList) { + connType = output->getConnectType(); + EXPECT_TRUE(connType <= IDSDisplayDeviceOutput::TYPE_DSI); + connState = output->getConnectState(); + EXPECT_TRUE(connState <= IDSDisplayDeviceOutput::STATE_MODESET); + if (connState == IDSDisplayDeviceOutput::STATE_DISCONNECTED) + continue; + + auto bestMode = (output->getAvailableModes()).front(); + EXPECT_TRUE(output->setMode(bestMode) == true); + EXPECT_TRUE(output->getMode() == bestMode); + + deviceHWC = output->getHWC(); + EXPECT_TRUE(deviceHWC != nullptr); + + auto bufferQueue = deviceHWC->getTargetBufferQueue(); + EXPECT_TRUE(deviceHWC != nullptr); + + auto renderEngine = std::make_unique(bufferQueue); + EXPECT_TRUE(renderEngine != nullptr); + + int imgWidth = 500; + int imgHeight = 500; + + // for 1st window -- begin -- + auto windowA = std::make_shared(); + EXPECT_TRUE(windowA != nullptr); + auto renderViewA = renderEngine->makeRenderView(windowA); + EXPECT_TRUE(renderViewA != nullptr); + + // create RED image buffer + tbm_surface_h tbmTextureA = DSRenderEngineDaliTest::createTbmTexture( + imgWidth, imgHeight, 255, 0, 0, 255); + EXPECT_TRUE(tbmTextureA != nullptr); + + auto imageSourceBufferA = std::make_shared (imgWidth, imgHeight, IDSBuffer::FORMAT_ARGB8888, tbmTextureA); + EXPECT_TRUE(renderViewA->setBuffer(imageSourceBufferA)); + // -- end -- + + // for 2nd window -- begin -- + auto windowB = std::make_shared(); + EXPECT_TRUE(windowB != nullptr); + auto renderViewB = renderEngine->makeRenderView(windowB); + EXPECT_TRUE(renderViewB != nullptr); + + // The buffer size of the second window is half of the first. + // create BLUE image buffer + tbm_surface_h tbmTextureB = DSRenderEngineDaliTest::createTbmTexture( + imgWidth/2, imgHeight/2, 0, 0, 255, 255); + EXPECT_TRUE(tbmTextureB != nullptr); + + auto imageSourceBufferB = std::make_shared (imgWidth/2, imgHeight/2, IDSBuffer::FORMAT_ARGB8888, tbmTextureB); + EXPECT_TRUE(renderViewB->setBuffer(imageSourceBufferB)); + // -- end -- + + EXPECT_TRUE(renderEngine->renderFrame()); + + /* + * Since windowA was created and added before windowB, + * windowB should be drawn above and windowA below. + * + * ┌──────┬──────┐ + * │ B │ │ + * │ blue │ A │ + * ┣──────┘ │ + * │ red │ + * │   │ + * └─────────────┘ + */ + + usleep(1000000); + + EXPECT_TRUE(bufferQueue->canAcquireBuffer(true)); + + auto buffer = bufferQueue->acquireBuffer(); + EXPECT_TRUE(buffer != nullptr); + + EXPECT_TRUE(deviceHWC->setTargetBuffer(buffer)); + + // commit + EXPECT_TRUE(deviceHWC->commit()); + + usleep(1000000); + } +} -- 2.7.4