]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - sitara-linux/video-graphics-test.git/blob - main.cpp
video graphics test : new demo application
[sitara-linux/video-graphics-test.git] / main.cpp
1 /*
2 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
3
4
5 *  Redistribution and use in source and binary forms, with or without 
6 *  modification, are permitted provided that the following conditions 
7 *  are met:
8 *
9 *    Redistributions of source code must retain the above copyright 
10 *    notice, this list of conditions and the following disclaimer.
11 *
12 *    Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the 
14 *    documentation and/or other materials provided with the   
15 *    distribution.
16 *
17 *    Neither the name of Texas Instruments Incorporated nor the names of
18 *    its contributors may be used to endorse or promote products derived
19 *    from this software without specific prior written permission.
20 *
21 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
22 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
23 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
25 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
27 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
30 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
31 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
35 #include <QGuiApplication>
36 #include <QQuickView>
37 #include <QQmlEngine>
38 #include <QQmlContext>
39 #include <QScreen>
40 #include <QDebug>
41 #include "video_graphics_test.h"
43 QGuiApplication *g_qt_app;
45 /*
46 This application demonstrates the advance processing capabilities of DSS IP when elfs QPA 
47 is used to run the QT application. eglfs QPA is used when there is a need for hardware
48 accelerated randering of the graphics content drawn by QT. eglfs QPA takes control of the 
49 display device and hence application relies on QT QPA to do the advance processing abilities of 
50 DSS IP like scaling, alpha blending and overlaying. Along with DSS advance capabilities using QT 
51 QPA for hardware accelerated rendering of the graphcis content on SGX, this application also 
52 demonstrates video rotation feature using GC320 IP, video capture using VIP interface and 
53 displaying these content on two screens. The data flow is as follows
54              ---->GC320 rotate 90 degree --> QT QPA (draws the graphics content from qml file, scale, alpha blend and overlay (on DSS) the video with SGX output)
55                         |
56 VIP Capture -
57             |
58              ----> QT QPA (draws the graphics content from qml file, scale, alpha blend and overlay (on DSS) the video with SGX output)
61 */
62 static QQuickView *addView(QScreen *screen, int screenIdx)
63 {
64     qDebug("Creating new QQuickView for screen %p", screen);
65     QQuickView *v = new QQuickView;
67     v->setScreen(screen);
68     v->setResizeMode(QQuickView::SizeViewToRootObject);//SizeRootObjectToView); //
69     v->rootContext()->setContextProperty("screenIdx", screenIdx);
70     v->rootContext()->setContextProperty("screenGeom", screen->geometry());
71     v->rootContext()->setContextProperty("screenAvailGeom", screen->availableGeometry());
72     v->rootContext()->setContextProperty("screenVirtGeom", screen->virtualGeometry());
73     v->rootContext()->setContextProperty("screenAvailVirtGeom", screen->availableVirtualGeometry());
74     v->rootContext()->setContextProperty("screenPhysSizeMm", screen->physicalSize());
75     v->rootContext()->setContextProperty("screenRefresh", screen->refreshRate());
77     if (screenIdx == 1){
78         v->setSource(QUrl("qrc:/clocks.qml"));
79     }
80     else{
81                 v->setSource(QUrl("qrc:/maroon.qml"));
82     }
84     QObject::connect(v->engine(), &QQmlEngine::quit, qGuiApp, &QCoreApplication::quit);
86     return v;
87 }
89 int main(int argc, char **argv)
90 {
91         //Enable them when need to debug the QPA
92     //qputenv("QT_LOGGING_RULES", "qt.qpa.*=true");
93     //qputenv("QSG_INFO", "1");
95     QGuiApplication app(argc, argv);
96     VideoGraphicsThread* video_graphics_test;
98     QList<QScreen *> screens = app.screens();
99     qDebug("Application sees %d screens", screens.count());
100     qDebug() << screens;
102     QVector<QQuickView *> views;
103         //Set the QML based graphics content to be rendered for each screen
104     for (int i = 0; i < screens.count(); ++i) {
105         QQuickView *v = addView(screens[i], i);
106         views.append(v);
107         v->showFullScreen();
108     }
110     g_qt_app=&app;
112         //Create and start the thread to capture, rotate and display the content 
113     video_graphics_test = new VideoGraphicsThread;
114     video_graphics_test->start();
116     int r = app.exec();
118     qDeleteAll(views);
119     return r;