static bool q_supportsElementIndexUint(QSGRendererInterface::GraphicsApi api)
{
    static bool elementIndexUint = true;
#if QT_CONFIG(opengl)
    if (api == QSGRendererInterface::OpenGL) {
        static bool elementIndexUintChecked = false;
        if (!elementIndexUintChecked) {
            elementIndexUintChecked = true;
            QOpenGLContext *context = QOpenGLContext::currentContext();
            QScopedPointer<QOpenGLContext> dummyContext;
            QScopedPointer<QOffscreenSurface> dummySurface;
            bool ok = true;
            if (!context) {
                dummyContext.reset(new QOpenGLContext);
                dummyContext->create();
                context = dummyContext.data();
                dummySurface.reset(new QOffscreenSurface);
                dummySurface->setFormat(context->format());
                dummySurface->create();
                ok = context->makeCurrent(dummySurface.data());
            }
            if (ok) {
                elementIndexUint = static_cast<QOpenGLExtensions *>(context->functions())->hasOpenGLExtension(
                            QOpenGLExtensions::ElementIndexUint);
            }
        }
    }
#else
    Q_UNUSED(api);
#endif
    return elementIndexUint;
}
예제 #2
0
QOpenGLConfig::Gpu QOpenGLConfig::Gpu::fromContext()
{
    QOpenGLContext *ctx = QOpenGLContext::currentContext();
    QScopedPointer<QOpenGLContext> tmpContext;
    QScopedPointer<QOffscreenSurface> tmpSurface;
    if (!ctx) {
        tmpContext.reset(new QOpenGLContext);
        if (!tmpContext->create()) {
            qWarning("QOpenGLConfig::Gpu::fromContext: Failed to create temporary context");
            return QOpenGLConfig::Gpu();
        }
        tmpSurface.reset(new QOffscreenSurface);
        tmpSurface->setFormat(tmpContext->format());
        tmpSurface->create();
        tmpContext->makeCurrent(tmpSurface.data());
    }

    QOpenGLConfig::Gpu gpu;
    ctx = QOpenGLContext::currentContext();
    const GLubyte *p = ctx->functions()->glGetString(GL_VENDOR);
    if (p)
        gpu.glVendor = QByteArray(reinterpret_cast<const char *>(p));

    return gpu;
}
예제 #3
0
void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window)
{
    RLDEBUG("windowDestroyed");
    for (int i=0; i<m_windows.size(); ++i) {
        if (m_windows.at(i).window == window) {
            m_windows.removeAt(i);
            break;
        }
    }

    hide(window);

    QQuickWindowPrivate *d = QQuickWindowPrivate::get(window);

    bool current = false;
    QScopedPointer<QOffscreenSurface> offscreenSurface;
    if (m_gl) {
        QSurface *surface = window;
        // There may be no platform window if the window got closed.
        if (!window->handle()) {
            offscreenSurface.reset(new QOffscreenSurface);
            offscreenSurface->setFormat(m_gl->format());
            offscreenSurface->create();
            surface = offscreenSurface.data();
        }
        current = m_gl->makeCurrent(surface);
    }
    if (Q_UNLIKELY(!current))
        qCDebug(QSG_LOG_RENDERLOOP) << "cleanup without an OpenGL context";

    QQuickShaderEffectMaterial::cleanupMaterialCache();

    d->cleanupNodesOnShutdown();
    if (m_windows.size() == 0) {
        d->context->invalidate();
        delete m_gl;
        m_gl = 0;
    } else if (m_gl && current) {
        m_gl->doneCurrent();
    }

    delete d->animationController;
}
예제 #4
0
int main(int argc, char *argv[])
{
    QScopedPointer<QGuiApplication> app (SailfishApp::application(argc, argv));
    QScopedPointer<QQuickView> view (SailfishApp::createView());

    MGConfItem partnerSpaceQml (PARTNERSPACEMANAGER_QML_DCONF);
    QString qmlFile = partnerSpaceQml.value(QString()).toString();
    if (qmlFile.isEmpty()) {
        return 1;
    }
    qDebug() << "Running partner-space launcher with" << qmlFile;

    view->setSource(QUrl(qmlFile));

    // The view is a partner window
    view->create();
    QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
    native->setWindowProperty(view->handle(), QLatin1String("CATEGORY"), QString(QLatin1String("partner")));
    view->show();

    return app->exec();
}
예제 #5
0
파일: quickdialog.cpp 프로젝트: kuiba/qutim
	void ensureInitialized()
	{
		if (!onVisibleChanged.isValid()) {
			int index = q_ptr->metaObject()->indexOfMethod("implementationVisibileChanged()");
			Q_ASSERT(index >= 0);
			onVisibleChanged = q_ptr->metaObject()->method(index);
		}

		if (component.isNull()) {
			Config config;
			config.beginGroup(QStringLiteral("qml/themes"));
			QString themeName = config.value(dialogName, QStringLiteral("default"));
			QString themePath = ThemeManager::path(QStringLiteral("qml/") + dialogName, themeName);

			if (themePath.isEmpty()) {
				qWarning() << "Failed to find theme:" << themeName << "for dialog:" << dialogName;
				themePath = ThemeManager::path(QStringLiteral("qml/") + dialogName, QStringLiteral("default"));
				if (themePath.isEmpty()) {
					qCritical() << "Failed to find default theme for dialog:" << dialogName;
					return;
				}
			}

			QString fileName = themePath + QStringLiteral("/main.qml");

			component.reset(new QQmlComponent(DeclarativeView::globalEngine(), fileName));
		}

		if (dialog.isNull()) {
			dialog = component->create();
			visibleProperty = QMetaProperty();

			if (!dialog) {
				qCritical() << "Failed to create object for component:" << component->url() << "errors:";
				for (QQmlError error : component->errors()) {
					qCritical() << error.toString();
				}
				return;
			}

			deathConnection = QObject::connect(dialog.data(), &QObject::destroyed, q_ptr, [this] () {
				dialog.clear();
				visibleProperty = QMetaProperty();
				updateVisible();
			});

			int visibleIndex = dialog->metaObject()->indexOfProperty("visible");
			if (visibleIndex < 0) {
				qCritical() << "Failed to find \"visible\" property for component:" << component->url();
				return;
			}

			visibleProperty = dialog->metaObject()->property(visibleIndex);

			if (!visibleProperty.hasNotifySignal()) {
				qCritical() << "Property \"visible\" has no notify signal for component:" << component->url();
			} else {
				QObject::connect(dialog.data(), visibleProperty.notifySignal(), q_ptr, onVisibleChanged);
			}

			updateVisible();
		}
	}