SystemCompositor::SystemCompositor()
    : VCompositor(this)
    , m_currentSurface(0)
{
    // Enable the subsurface extension
    enableSubSurfaceExtension();

    // System compositor protocol
    m_protocol = new SystemCompositorServer(this, QWaylandCompositor::handle());

    // Allow QML to access this compositor
    rootContext()->setContextProperty("compositor", this);

    // All the screen is initially available
    m_availableGeometry = screen()->availableGeometry();
    connect(screen(), SIGNAL(virtualGeometryChanged(QRect)),
            this, SIGNAL(screenGeometryChanged()));

    // Load the QML code
    setSource(QUrl("qrc:///qml/Compositor.qml"));
    setResizeMode(QQuickView::SizeRootObjectToView);
    setColor(Qt::black);
    winId();

    connect(this, SIGNAL(windowAdded(QVariant)),
            rootObject(), SLOT(windowAdded(QVariant)));
    connect(this, SIGNAL(windowDestroyed(QVariant)),
            rootObject(), SLOT(windowDestroyed(QVariant)));
    connect(this, SIGNAL(windowResized(QVariant)),
            rootObject(), SLOT(windowResized(QVariant)));
    connect(this, SIGNAL(sceneGraphInitialized()),
            this, SLOT(sceneGraphInitialized()), Qt::DirectConnection);
    connect(this, SIGNAL(frameSwapped()),
            this, SLOT(frameSwapped()));
}
Beispiel #2
0
// At start up.
void Engine::init()
{
	std::cout << "INIT" << std::endl;

	{
		std::condition_variable cv;
		std::mutex m;
		std::unique_lock<std::mutex> lk(m);
		cv.wait(lk, [this]{ 
				std::cout << "Waiting on data... (might be deadlock here :) )" << std::endl;
				return _data; 
		});
		std::cout << "GOT DATA SAFELY"<< std::endl;
	}

	// Connect QT Signals inorder to be able to use OpenGL
	connect(_window, SIGNAL(sceneGraphInitialized()), this, SLOT(initialize()), Qt::DirectConnection);
	connect(_window, SIGNAL(beforeSynchronizing()), this, SLOT(sync()), Qt::DirectConnection);
	connect(_window, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection);
	
	// Make sure QML don't clear what we paint.
	_window->setClearBeforeRendering(false);

	// Displays FPS in windowtitle.
	_timer = new QTimer(this);
	connect(_timer, SIGNAL(timeout()), this, SLOT(showFPS()), Qt::DirectConnection);
	_timer->start(50);

	std::cout << "INIT DONE" << std::endl;
}
Beispiel #3
0
void tst_QQuickGraphicsInfo::testProperties()
{
    QQuickView view;
    view.setSource(QUrl("data/basic.qml"));

    view.show();
    QVERIFY(QTest::qWaitForWindowExposed(&view));

    QSignalSpy spy(&view, SIGNAL(sceneGraphInitialized()));
    spy.wait();

    QObject* obj = view.rootObject();
    QVERIFY(obj);

    QSGRendererInterface *rif = view.rendererInterface();
    const int expectedAPI = rif ? rif->graphicsApi() : QSGRendererInterface::Unknown;

    QCOMPARE(obj->property("api").toInt(), expectedAPI);

#if QT_CONFIG(opengl)
    if (expectedAPI == QSGRendererInterface::OpenGL) {
        QCOMPARE(obj->property("shaderType").toInt(), int(QSGRendererInterface::GLSL));
        QVERIFY(view.openglContext());
        QSurfaceFormat format = view.openglContext()->format();
        QCOMPARE(obj->property("majorVersion").toInt(), format.majorVersion());
        QCOMPARE(obj->property("minorVersion").toInt(), format.minorVersion());
        QCOMPARE(obj->property("profile").toInt(), static_cast<int>(format.profile()));
        QCOMPARE(obj->property("renderableType").toInt(), static_cast<int>(format.renderableType()));
    }
#endif
}
Beispiel #4
0
void HsQMLContextControl::doWindowChanged(QQuickWindow* win)
{
    if (mWindow) {
        QObject::disconnect(mWindow, 0, this, 0);
    }
    mWindow = win;
    if (mWindow) {
        QObject::connect(
            mWindow, SIGNAL(sceneGraphInitialized()),
            this, SLOT(doSceneGraphInit()));
        mOriginal = mWindow->requestedFormat();
        mCurrent = mWindow->openglContext() ?
            mWindow->openglContext()->format() : mWindow->format();
    }
    else {
        mOriginal = QSurfaceFormat();
        mCurrent = QSurfaceFormat();
    }
    contextChanged();

    if ((mMajorVersion >=0) || (mMinorVersion >= 0) ||
        (mContextType != TypeUnset) || (mContextProfile != ProfileUnset) ||
        !mDeprecatedFunctionsSet) {
        controlContext();
    }
}
Beispiel #5
0
void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window)
{
    if (!window) {
        // Stop will trigger syncBackCurrentValues so best to do it before
        // we delete m_job.
        stop();
        deleteJob();
        return;

    } else if (!m_controller && m_job) {
        m_controller = QQuickWindowPrivate::get(window)->animationController;
        if (window->openglContext())
            readyToAnimate();
        else
            connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitialized()));
    }
}
Beispiel #6
0
void ModelRenderer::windowChanged(QQuickWindow *window)
{
    LOG_ENTER();
    if( window != nullptr && window != m_window ){
        window->setClearBeforeRendering(false);

        connect( window, SIGNAL(afterAnimating()), this, SLOT(afterAnimating()), Qt::DirectConnection );
        connect( window, SIGNAL(afterRendering()), this, SLOT(afterRendering()), Qt::DirectConnection );
        connect( window, SIGNAL(afterSynchronizing()), this, SLOT(afterSynchronizing()), Qt::DirectConnection );
        connect( window, SIGNAL(beforeRendering()), this, SLOT(beforeRendering()), Qt::DirectConnection );
        connect( window, SIGNAL(beforeSynchronizing()), this, SLOT(beforeSynchronizing()), Qt::DirectConnection );
        connect( window, SIGNAL(frameSwapped()), this, SLOT(frameSwapped()), Qt::DirectConnection );
        connect( window, SIGNAL(openglContextCreated(QOpenGLContext*)), this, SLOT(openglContextCreated(QOpenGLContext*)), Qt::DirectConnection );
        connect( window, SIGNAL(sceneGraphError(QQuickWindow::SceneGraphError,QString)), this, SLOT(sceneGraphError(QQuickWindow::SceneGraphError,QString)), Qt::DirectConnection );
        connect( window, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitialized()), Qt::DirectConnection );
        connect( window, SIGNAL(sceneGraphInvalidated()), this, SLOT(sceneGraphInvalidated()),Qt::DirectConnection );
    }
void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window)
{
    if (!window) {
        stop();
        deleteJob();

        // Upon leaving a window, we reset the controller. This means that
        // animators will only enter the Starting phase and won't be making
        // calls to QQuickAnimatorController::startjob().
        m_controller = 0;

    } else if (!m_controller && m_job) {
        m_controller = QQuickWindowPrivate::get(window)->animationController;
        if (window->openglContext())
            readyToAnimate();
        else
            connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitialized()));
    }
}
/*------------------------------------------------------------------------------
|    OpenMAXILPlayerControl::onItemSceneChanged
+-----------------------------------------------------------------------------*/
void OpenMAXILPlayerControl::onItemSceneChanged()
{
   QQuickWindow* window = m_quickItem->window();
   if (!window)
      return;

   connect(window, SIGNAL(sceneGraphInitialized()),
           this, SLOT(onSceneGraphInitialized()), Qt::DirectConnection);
   connect(window, SIGNAL(afterRendering()),
           this, SLOT(onAfterRendering()), Qt::DirectConnection);

   window->update();
}
/*------------------------------------------------------------------------------
|    OpenMAXILPlayerControl::onItemSceneChanged
+-----------------------------------------------------------------------------*/
void OpenMAXILPlayerControl::onItemSceneChanged()
{
   LOG_DEBUG(LOG_TAG, "Getting window...");
   QQuickWindow* window = m_quickItem->window();
   if (!window) {
      LOG_ERROR(LOG_TAG, "Failed to get QQuickWindow.");
      return;
   }

   connect(window, SIGNAL(sceneGraphInitialized()),
           this, SLOT(onSceneGraphInitialized()), Qt::DirectConnection);
   connect(window, SIGNAL(afterRendering()),
           this, SLOT(onAfterRendering()), Qt::DirectConnection);
   window->update();
}
Beispiel #10
0
void VideoItem::handleWindowChanged(QQuickWindow *win)
{
    if (win) {
        // Connect the beforeRendering signal to our paint function.
        // Since this call is executed on the rendering thread it must be
        // a Qt::DirectConnection
    setFlag(QQuickItem::ItemHasContents, true);
        connect(win, SIGNAL(frameSwapped()), this, SLOT(update()));
        connect(win, SIGNAL(widthChanged(int)), this, SLOT(handleGeometryChanged(int)));
        connect(win, SIGNAL(heightChanged(int)), this, SLOT(handleGeometryChanged(int)));
        connect(win, SIGNAL(sceneGraphInitialized()), this, SLOT(handleSceneGraphInitialized()));

        // If we allow QML to do the clearing, they would clear what we paint
        // and nothing would show.
        //win->setClearBeforeRendering(false);

    }
}
void tst_QQuickOpenGLInfo::testProperties()
{
    QQuickView view;
    view.setSource(testFileUrl("basic.qml"));

    view.show();
    QVERIFY(QTest::qWaitForWindowExposed(&view));

    QSignalSpy spy(&view, SIGNAL(sceneGraphInitialized()));
    spy.wait();

    QVERIFY(view.openglContext());
    QSurfaceFormat format = view.openglContext()->format();

    QObject* obj = view.rootObject();
    QVERIFY(obj);
    QCOMPARE(obj->property("majorVersion").toInt(), format.majorVersion());
    QCOMPARE(obj->property("minorVersion").toInt(), format.minorVersion());
    QCOMPARE(obj->property("profile").toInt(), static_cast<int>(format.profile()));
    QCOMPARE(obj->property("renderableType").toInt(), static_cast<int>(format.renderableType()));
}
Beispiel #12
0
FiltersDock::FiltersDock(MetadataModel* metadataModel, AttachedFiltersModel* attachedModel, QWidget *parent) :
    QDockWidget(tr("Filters"), parent),
    m_qview(QmlUtilities::sharedEngine(), this)
{
    LOG_DEBUG() << "begin";
    setObjectName("FiltersDock");
    QIcon filterIcon = QIcon::fromTheme("view-filter", QIcon(":/icons/oxygen/32x32/actions/view-filter.png"));
    setWindowIcon(filterIcon);
    toggleViewAction()->setIcon(windowIcon());
    setMinimumWidth(300);
    m_qview.setFocusPolicy(Qt::StrongFocus);
    setWidget(&m_qview);

    QmlUtilities::setCommonProperties(m_qview.rootContext());
    m_qview.rootContext()->setContextProperty("view", new QmlView(m_qview.quickWindow()));
    m_qview.rootContext()->setContextProperty("metadatamodel", metadataModel);
    m_qview.rootContext()->setContextProperty("attachedfiltersmodel", attachedModel);
    setCurrentFilter(0, 0, -1);
    connect(m_qview.quickWindow(), SIGNAL(sceneGraphInitialized()), SLOT(resetQview()));

    LOG_DEBUG() << "end";
}
Beispiel #13
0
void GLC_QuickView::sceneGraphInitializedDone()
{
    disconnect(this, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitializedDone()));

    QOpenGLContext* pContext= openglContext();
    Q_ASSERT(pContext);

    m_pQOpenGLContext= new QOpenGLContext();
    m_pQOpenGLContext->setShareContext(pContext);
    m_pQOpenGLContext->setFormat(pContext->format());
    m_pQOpenGLContext->create();
    Q_ASSERT(m_pQOpenGLContext->isValid());

    QOffscreenSurface* pFakeSurface = new QOffscreenSurface();
    pFakeSurface->setFormat(pContext->format());
    pFakeSurface->create();

    m_pContext= GLC_ContextManager::instance()->createContext(m_pQOpenGLContext, pFakeSurface);
    m_pContext->makeCurrent();
    qDebug() << m_pContext;
    initializeGL();
}
void QQuickAnimatorProxyJob::sceneGraphInitialized()
{
    readyToAnimate();
    disconnect(this, SLOT(sceneGraphInitialized()));
}
Beispiel #15
0
void GLC_QuickView::initConnection()
{
    connect(this, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitializedDone()));
}