Ejemplo n.º 1
0
void QQuickTrivialWindowManager::hide(QQuickWindow *window)
{
    if (!m_windows.contains(window))
        return;

    m_windows.remove(window);
    QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
    cd->cleanupNodesOnShutdown();

    if (m_windows.size() == 0) {
        sg->invalidate();
        delete gl;
        gl = 0;
    }
}
Ejemplo n.º 2
0
void QSGSoftwareRenderLoop::windowDestroyed(QQuickWindow *window)
{
    m_windows.remove(window);
    delete m_backingStores[window];
    m_backingStores.remove(window);
    hide(window);

    QQuickWindowPrivate *d = QQuickWindowPrivate::get(window);
    d->cleanupNodesOnShutdown();

    if (m_windows.size() == 0) {
        rc->invalidate();
        QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
    }
}
Ejemplo n.º 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;
}
Ejemplo n.º 4
0
void QSGWindowsRenderLoop::hide(QQuickWindow *window)
{
    RLDEBUG("hide");

    for (int i=0; i<m_windows.size(); ++i) {
        if (m_windows.at(i).window == window) {
            m_windows.removeAt(i);
            break;
        }
    }

    // The expose event is queued while hide is sent synchronously, so
    // the value might not be updated yet. (plus that the windows plugin
    // sends exposed=true when it goes to hidden, so it is doubly broken)
    // The check is made here, after the removal from m_windows, so
    // anyoneShowing will report the right value.
    if (window->isExposed())
        handleObscurity();

    if (!m_gl)
        return;

    QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
    m_gl->makeCurrent(window);
    cd->cleanupNodesOnShutdown();

    // If this is the last tracked window, check for persistent SG and GL and
    // potentially clean up.
    if (m_windows.size() == 0) {
        if (!cd->persistentSceneGraph) {
            QQuickWindowPrivate::get(window)->context->invalidate();
            QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
            if (!cd->persistentGLContext) {
                delete m_gl;
                m_gl = 0;
            }
        }
    }
}
Ejemplo n.º 5
0
/*
 * Render the contents of this window. First polish, then sync, render
 * then finally swap.
 *
 * Note: This render function does not implement aborting
 * the render call when sync step results in no scene graph changes,
 * like the threaded renderer does.
 */
void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window)
{
    RLDEBUG("renderWindow");
    QQuickWindowPrivate *d = QQuickWindowPrivate::get(window);

    if (!d->isRenderable())
        return;

    if (!m_gl->makeCurrent(window)) {
        // Check for context loss.
        if (!m_gl->isValid()) {
            d->cleanupNodesOnShutdown();
            m_rc->invalidate();
            if (m_gl->create() && m_gl->makeCurrent(window))
                m_rc->initialize(m_gl);
            else
                return;
        }
    }

    d->flushDelayedTouchEvent();
    // Event delivery or processing has caused the window to stop rendering.
    if (!windowData(window))
        return;

    QSG_LOG_TIME_SAMPLE(time_start);
    Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphPolishFrame);

    RLDEBUG(" - polishing");
    d->polishItems();
    QSG_LOG_TIME_SAMPLE(time_polished);
    Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame,
                              QQuickProfiler::SceneGraphRenderLoopFrame);

    emit window->afterAnimating();

    RLDEBUG(" - syncing");
    d->syncSceneGraph();
    QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_synced);

    RLDEBUG(" - rendering");
    d->renderSceneGraph(window->size());
    QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_rendered);

    RLDEBUG(" - swapping");
    if (!d->customRenderStage || !d->customRenderStage->swap())
        m_gl->swapBuffers(window);
    QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_swapped);

    RLDEBUG(" - frameDone");
    d->fireFrameSwapped();

    qCDebug(QSG_LOG_TIME_RENDERLOOP()).nospace()
            << "Frame rendered with 'windows' renderloop in: " << (time_swapped - time_start) / 1000000 << "ms"
            << ", polish=" << (time_polished - time_start) / 1000000
            << ", sync=" << (time_synced - time_polished) / 1000000
            << ", render=" << (time_rendered - time_synced) / 1000000
            << ", swap=" << (time_swapped - time_rendered) / 1000000
            << " - " << window;

    Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphRenderLoopFrame);
}