DSRenderEngineDaliImpl-test: Add a new testcase for compositing twe windows. 19/241819/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Thu, 13 Aug 2020 06:52:44 +0000 (15:52 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:11:40 +0000 (19:11 +0900)
 - 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 <joonbum.ko@samsung.com>
tests/DSRenderEngineDaliImpl-test.cpp

index 8fb3a41..8cc94d0 100644 (file)
@@ -212,3 +212,99 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame)
                usleep(1000000);
        }
 }
+
+TEST_F(DSRenderEngineDaliTest, RenderEngine_ComposeTwoWindow)
+{
+       std::unique_ptr<IDSDisplayDevice> displayDevice = std::make_unique<DSDisplayDeviceTDMImpl>();
+       std::list<std::shared_ptr<IDSDisplayDeviceOutput>> outputList = displayDevice->getOutputList();
+       EXPECT_TRUE(outputList.size() != 0);
+
+       IDSDisplayDeviceOutput::ConnectorType connType;
+       IDSDisplayDeviceOutput::ConnectState connState;
+       std::shared_ptr<IDSDisplayDeviceHWC> deviceHWC;
+
+       for (std::shared_ptr<IDSDisplayDeviceOutput> 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<DSRenderEngineDaliImpl>(bufferQueue);
+               EXPECT_TRUE(renderEngine != nullptr);
+
+               int imgWidth = 500;
+               int imgHeight = 500;
+
+               // for 1st window -- begin --
+               auto windowA = std::make_shared<DSWindow>();
+               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<DSBufferTBMImpl> (imgWidth, imgHeight, IDSBuffer::FORMAT_ARGB8888, tbmTextureA);
+               EXPECT_TRUE(renderViewA->setBuffer(imageSourceBufferA));
+               // -- end --
+
+               // for 2nd window -- begin --
+               auto windowB = std::make_shared<DSWindow>();
+               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<DSBufferTBMImpl> (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);
+       }
+}