void QQuickItemRenderer::handleWindowChange(QQuickWindow *win) { if (!win) return; connect(win, SIGNAL(beforeRendering()), this, SLOT(beforeRendering()), Qt::DirectConnection); connect(win, SIGNAL(afterRendering()), this, SLOT(afterRendering()), Qt::DirectConnection); }
void OpenGLVideo::render(const QRectF &target, const QRectF& roi, const QMatrix4x4& transform) { DPTR_D(OpenGLVideo); Q_ASSERT(d.manager); Q_EMIT beforeRendering(); DYGL(glViewport(d.rect.x(), d.rect.y(), d.rect.width(), d.rect.height())); // viewport was used in gpu filters is wrong, qt quick fbo item's is right(so must ensure setProjectionMatrixToRect was called correctly) const qint64 mt = d.material->type(); if (d.material_type != mt) { qDebug() << "material changed: " << VideoMaterial::typeName(d.material_type) << " => " << VideoMaterial::typeName(mt); d.material_type = mt; } VideoShader *shader = d.user_shader; if (!shader) shader = d.manager->prepareMaterial(d.material, mt); //TODO: print shader type name if changed. prepareMaterial(,sample_code, pp_code) shader->update(d.material); d.material->setDirty(false); // shader->program()->setUniformValue(shader->matrixLocation(), transform*d.matrix); d.gr.setShaderProgram(shader->program()); // uniform end. attribute begin d.bindAttributes(shader, target, roi); // normalize? const bool blending = d.material->hasAlpha(); if (blending) { DYGL(glEnable(GL_BLEND)); DYGL(glBlendFunc(GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA)); } d.gr.render(&d.geometry); if (blending) DYGL(glDisable(GL_BLEND)); // d.shader->program()->release(); //glUseProgram(0) d.unbindAttributes(shader); d.material->unbind(); Q_EMIT afterRendering(); }
LipstickCompositor::LipstickCompositor() : QWaylandCompositor(this), m_totalWindowCount(0), m_nextWindowId(1), m_homeActive(true), m_shaderEffect(0), m_fullscreenSurface(0), m_directRenderingActive(false), m_topmostWindowId(0), m_screenOrientation(Qt::PrimaryOrientation), m_sensorOrientation(Qt::PrimaryOrientation), m_displayState(new MeeGo::QmDisplayState(this)), m_retainedSelection(0), m_compositorSettings("nemomobile", "lipstick") { setColor(Qt::black); setRetainedSelectionEnabled(true); if (m_instance) qFatal("LipstickCompositor: Only one compositor instance per process is supported"); m_instance = this; QObject::connect(this, SIGNAL(afterRendering()), this, SLOT(windowSwapped())); connect(m_displayState, SIGNAL(displayStateChanged(MeeGo::QmDisplayState::DisplayState)), this, SLOT(reactOnDisplayStateChanges(MeeGo::QmDisplayState::DisplayState))); QObject::connect(HomeApplication::instance(), SIGNAL(aboutToDestroy()), this, SLOT(homeApplicationAboutToDestroy())); m_orientationSensor = new QOrientationSensor(this); QObject::connect(m_orientationSensor, SIGNAL(readingChanged()), this, SLOT(setScreenOrientationFromSensor())); if (!m_orientationSensor->connectToBackend()) { qWarning() << "Could not connect to the orientation sensor backend"; } else { if (!m_orientationSensor->start()) qWarning() << "Could not start the orientation sensor"; } emit HomeApplication::instance()->homeActiveChanged(); QDesktopServices::setUrlHandler("http", this, "openUrl"); QDesktopServices::setUrlHandler("https", this, "openUrl"); QDesktopServices::setUrlHandler("mailto", this, "openUrl"); connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()), SLOT(clipboardDataChanged())); }
HsQMLCanvasBackEnd::HsQMLCanvasBackEnd( QQuickWindow* win, const HsQMLGLDelegate::CallbacksRef& cbs, HsQMLCanvas::DisplayMode mode) : mWindow(win) , mWinInfo(HsQMLWindowInfo::getWindowInfo(win)) , mGLCallbacks(cbs) , mGL(NULL) , mStatus(HsQMLCanvas::Okay) , mDisplayMode(mode) , mItemWidth(0) , mItemHeight(0) , mTransformNode(NULL) , mCanvasWidth(0) , mCanvasHeight(0) { if (HsQMLCanvas::Above == mDisplayMode) { QObject::connect( win, SIGNAL(afterRendering()), this, SLOT(doRendering())); } else { QObject::connect( win, SIGNAL(beforeRendering()), this, SLOT(doRendering())); if (HsQMLCanvas::Below == mDisplayMode) { mWinInfo.addBelow(); QObject::connect( win, SIGNAL(frameSwapped()), this, SLOT(doEndFrame())); } } }
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 ); }
/*------------------------------------------------------------------------------ | 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(); }
int main(int argc, char *argv[]) { qmlRegisterType<GridEqualizer>("mbrdna.qml.components", 1, 0, "GridEqualizer"); qmlRegisterType<BeforeRenderItem>("mbrdna.qml.components", 1, 0, "BeforeRenderItem"); QGuiApplication app(argc, argv); QtQuick2ApplicationViewer viewer; viewer.setSurfaceType(QWindow::OpenGLSurface); QSurfaceFormat format; format.setSamples(8); viewer.setFormat(format); viewer.setMainQmlFile(QStringLiteral("qml/GridVisualization/main.qml")); viewer.showExpanded(); //Connect Before RenderItem QObject::connect(&viewer, SIGNAL(beforeRendering()), BeforeRenderGlobal::Instance(), SLOT(handlerBefore()), Qt::DirectConnection); QObject::connect(&viewer, SIGNAL(afterRendering()), BeforeRenderGlobal::Instance(), SLOT(handlerAfter()), Qt::DirectConnection); return app.exec(); }
LipstickCompositor::LipstickCompositor() : QWaylandQuickCompositor(this, 0, (QWaylandCompositor::ExtensionFlags)QWaylandCompositor::DefaultExtensions & ~QWaylandCompositor::QtKeyExtension) , m_totalWindowCount(0) , m_nextWindowId(1) , m_homeActive(true) , m_shaderEffect(0) , m_fullscreenSurface(0) , m_directRenderingActive(false) , m_topmostWindowId(0) , m_topmostWindowProcessId(0) , m_screenOrientation(Qt::PrimaryOrientation) , m_sensorOrientation(Qt::PrimaryOrientation) , m_displayState(0) , m_retainedSelection(0) , m_currentDisplayState(MeeGo::QmDisplayState::Unknown) , m_updatesEnabled(true) , m_completed(false) , m_onUpdatesDisabledUnfocusedWindowId(0) , m_keymap(0) , m_fakeRepaintTriggered(false) { setColor(Qt::black); setRetainedSelectionEnabled(true); addDefaultShell(); if (m_instance) qFatal("LipstickCompositor: Only one compositor instance per process is supported"); m_instance = this; m_orientationLock = new MGConfItem("/lipstick/orientationLock", this); connect(m_orientationLock, SIGNAL(valueChanged()), SIGNAL(orientationLockChanged())); // Load legacy settings from the config file and delete it from there QSettings legacySettings("nemomobile", "lipstick"); QString legacyOrientationKey("Compositor/orientationLock"); if (legacySettings.contains(legacyOrientationKey)) { m_orientationLock->set(legacySettings.value(legacyOrientationKey)); legacySettings.remove(legacyOrientationKey); } connect(this, SIGNAL(visibleChanged(bool)), this, SLOT(onVisibleChanged(bool))); QObject::connect(this, SIGNAL(afterRendering()), this, SLOT(windowSwapped())); QObject::connect(HomeApplication::instance(), SIGNAL(aboutToDestroy()), this, SLOT(homeApplicationAboutToDestroy())); connect(this, &QQuickWindow::afterRendering, this, &LipstickCompositor::readContent, Qt::DirectConnection); m_orientationSensor = new QOrientationSensor(this); QObject::connect(m_orientationSensor, SIGNAL(readingChanged()), this, SLOT(setScreenOrientationFromSensor())); if (!m_orientationSensor->connectToBackend()) { qWarning() << "Could not connect to the orientation sensor backend"; } else { if (!m_orientationSensor->start()) qWarning() << "Could not start the orientation sensor"; } emit HomeApplication::instance()->homeActiveChanged(); QDesktopServices::setUrlHandler("http", this, "openUrl"); QDesktopServices::setUrlHandler("https", this, "openUrl"); QDesktopServices::setUrlHandler("mailto", this, "openUrl"); connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()), SLOT(clipboardDataChanged())); m_recorder = new LipstickRecorderManager; addGlobalInterface(m_recorder); addGlobalInterface(new AlienManagerGlobal); HwcRenderStage::initialize(this); setUpdatesEnabled(false); QTimer::singleShot(0, this, SLOT(initialize())); }
int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); #ifdef PERFORMANCEMONITOR_SUPPORT PerformanceMonitor::qmlRegisterTypes(); #endif QUrl fileName; qreal volume = 0.5; QStringList args = app.arguments(); #ifdef PERFORMANCEMONITOR_SUPPORT PerformanceMonitor::State performanceMonitorState; #endif for (int i = 1; i < args.size(); ++i) { const QByteArray arg = args.at(i).toUtf8(); if (arg.startsWith('-')) { if ("-volume" == arg) { if (i + 1 < args.size()) volume = 0.01 * args.at(++i).toInt(); else qtTrace() << "Option \"-volume\" takes a value"; } #ifdef PERFORMANCEMONITOR_SUPPORT else if (performanceMonitorState.parseArgument(arg)) { // Do nothing } #endif else { qtTrace() << "Option" << arg << "ignored"; } } else { if (fileName.isEmpty()) fileName = QUrl::fromLocalFile(arg); else qtTrace() << "Argument" << arg << "ignored"; } } QQuickView viewer; viewer.setSource(QUrl(QLatin1String("qrc:///qml/qmlvideofx/Main.qml"))); QQuickItem *rootObject = viewer.rootObject(); rootObject->setProperty("fileName", fileName); viewer.rootObject()->setProperty("volume", volume); #ifdef PERFORMANCEMONITOR_SUPPORT if (performanceMonitorState.valid) { rootObject->setProperty("perfMonitorsLogging", performanceMonitorState.logging); rootObject->setProperty("perfMonitorsVisible", performanceMonitorState.visible); } QObject::connect(&viewer, SIGNAL(afterRendering()), rootObject, SLOT(qmlFramePainted())); #endif FileReader fileReader; viewer.rootContext()->setContextProperty("fileReader", &fileReader); const QUrl appPath(QUrl::fromLocalFile(app.applicationDirPath())); const QStringList picturesLocation = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); const QUrl imagePath = picturesLocation.isEmpty() ? appPath : QUrl::fromLocalFile(picturesLocation.first()); viewer.rootContext()->setContextProperty("imagePath", imagePath); const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation); const QUrl videoPath = moviesLocation.isEmpty() ? appPath : QUrl::fromLocalFile(moviesLocation.first()); viewer.rootContext()->setContextProperty("videoPath", videoPath); viewer.setTitle("qmlvideofx"); viewer.setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); viewer.setMinimumSize(QSize(1280, 720)); viewer.setResizeMode(QQuickView::SizeRootObjectToView); viewer.show(); // Delay invocation of init until the event loop has started, to work around // a GL context issue on Harmattan: without this, we get the following error // when the first ShaderEffectItem is created: // "QGLShaderProgram::addShader: Program and shader are not associated with same context" QMetaObject::invokeMethod(viewer.rootObject(), "init", Qt::QueuedConnection); return app.exec(); }
int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); #ifdef PERFORMANCEMONITOR_SUPPORT PerformanceMonitor::qmlRegisterTypes(); #endif QString source1, source2; qreal volume = 0.5; QStringList args = app.arguments(); #ifdef PERFORMANCEMONITOR_SUPPORT PerformanceMonitor::State performanceMonitorState; #endif bool sourceIsUrl = false; for (int i = 1; i < args.size(); ++i) { const QByteArray arg = args.at(i).toUtf8(); if (arg.startsWith('-')) { if ("-volume" == arg) { if (i+1 < args.count()) volume = 0.01 * args.at(++i).toInt(); else qtTrace() << "Option \"-volume\" takes a value"; } #ifdef PERFORMANCEMONITOR_SUPPORT else if (performanceMonitorState.parseArgument(arg)) { // Do nothing } #endif else if ("-url" == arg) { sourceIsUrl = true; } else { qtTrace() << "Option" << arg << "ignored"; } } else { if (source1.isEmpty()) source1 = arg; else if (source2.isEmpty()) source2 = arg; else qtTrace() << "Argument" << arg << "ignored"; } } QUrl url1, url2; if (sourceIsUrl) { url1 = source1; url2 = source2; } else { if (!source1.isEmpty()) url1 = QUrl::fromLocalFile(source1); if (!source2.isEmpty()) url2 = QUrl::fromLocalFile(source2); } QQuickView viewer; viewer.setSource(QUrl("qrc:///qml/qmlvideo/main.qml")); QObject::connect(viewer.engine(), SIGNAL(quit()), &viewer, SLOT(close())); QQuickItem *rootObject = viewer.rootObject(); rootObject->setProperty("source1", url1); rootObject->setProperty("source2", url2); rootObject->setProperty("volume", volume); #ifdef PERFORMANCEMONITOR_SUPPORT if (performanceMonitorState.valid) { rootObject->setProperty("perfMonitorsLogging", performanceMonitorState.logging); rootObject->setProperty("perfMonitorsVisible", performanceMonitorState.visible); } QObject::connect(&viewer, SIGNAL(afterRendering()), rootObject, SLOT(qmlFramePainted())); #endif const QStringList moviesLocation = QStandardPaths::standardLocations(QStandardPaths::MoviesLocation); const QUrl videoPath = QUrl::fromLocalFile(moviesLocation.isEmpty() ? app.applicationDirPath() : moviesLocation.front()); viewer.rootContext()->setContextProperty("videoPath", videoPath); QMetaObject::invokeMethod(rootObject, "init"); viewer.setMinimumSize(QSize(640, 360)); viewer.show(); return app.exec(); }