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);
+ }
+}