Beispiel #1
0
void Colors::postConfigure()
{
    if (!Colors::noAdapt){
        QWidget w;
        if (w.depth() < 16){
            Colors::useEightBitPalette = true;
            Colors::adapted = true;
            if (Colors::verbose)
                qDebug() << "- Adapt: Color depth less than 16 bit. Using 8 bit palette";
        }

        if (!Colors::xRenderPresent){
            Colors::setLowSettings();
            Colors::adapted = true;
            if (Colors::verbose)
                qDebug() << "- Adapt: X renderer not present. Using low settings";
        }
    }

    if (!Colors::openGlRendering && !Colors::softwareRendering){
        // The user has not decided rendering system. So we do it instead:
        if (Colors::openGlAvailable)
            Colors::openGlRendering = true;
        else
            Colors::softwareRendering = true;
    }
}
Beispiel #2
0
int screenDepthPerComponent(Widget* w)
{
#if HAVE(QT5)
    int depth = QGuiApplication::primaryScreen()->depth();
    // FIXME: Use widget's screen
    Q_UNUSED(w);
#else
    int depth = QApplication::desktop()->screen(0)->depth();
    if (w) {
        QWebPageClient* client = w->root()->hostWindow()->platformPageClient();

        if (client) {
            QWidget* view = client->ownerWidget();
            if (view)
                depth = view->depth();
        }
    }
#endif
    // An interface to establish the actual number of bits per color
    // doesn't exist in Qt, or probably at all, so use common-sense
    // values for each screen depth and assume RGB/RGBA where appropriate.
    // Per http://www.w3.org/TR/css3-mediaqueries/#color, 'If different color
    // components are represented by different number of bits, the smallest
    // number is used.'
    switch (depth) {
    case 8:
        return 2;
    case 32:
        return 8;
    default:
        return depth / 3;
    }
}
Beispiel #3
0
int screenDepth(const Page* page)
{
    QWidget* qw = qwidgetForPage(page);
    if (!qw)
        return 32;

    return qw->depth();
}
int screenDepthPerComponent(Widget* w)
{
    if (w) {
        QWebPageClient* client = w->root()->hostWindow()->platformPageClient();

        if (client) {
            QWidget* view = client->ownerWidget();
            if (view)
                return view->depth();
        }
    }
    return QApplication::desktop()->screen(0)->depth();
}
Beispiel #5
0
void Colors::detectSystemResources()
{
#ifndef QT_NO_OPENGL
    if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)
        Colors::glVersion = "2.0 or higher";
    else if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_5)
        Colors::glVersion = "1.5";
    else if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_4)
        Colors::glVersion = "1.4";
    else if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_3)
        Colors::glVersion = "1.3 or lower";
    if (Colors::verbose)
        qDebug() << "- OpenGL version:" << Colors::glVersion;

    QGLWidget glw;
    if (!QGLFormat::hasOpenGL()
        || !glw.format().directRendering()
        || !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_5)
        || glw.depth() < 24
    )
#else
    if (Colors::verbose)
        qDebug() << "- OpenGL not supported by current build of Qt";
#endif
    {
        Colors::openGlAwailable = false;
        if (Colors::verbose)
            qDebug("- OpenGL not recommended on this system");
    }

#if defined(Q_WS_WIN)
    Colors::direct3dAwailable = false; // for now.
#endif

#if defined(Q_WS_X11)
    // check if X render is present:
    QPixmap tmp(1, 1);
    if (!tmp.x11PictureHandle() && tmp.paintEngine()->type() == QPaintEngine::X11){
        Colors::xRenderPresent = false;
        if (Colors::verbose)
            qDebug("- X render not present");
    }

#endif

    QWidget w;
    if (Colors::verbose)
        qDebug() << "- Color depth: " << QString::number(w.depth());
}
Beispiel #6
0
void MainWindow::keyPressEvent(QKeyEvent *event)
{
    if (event->key() == Qt::Key_Escape){
        this->loop = false;
        QApplication::quit();
    }
    else if (event->key() == Qt::Key_F1){
            QString s("");
            s += "Rendering system: ";
            if (Colors::openGlRendering)
                s += "OpenGL";
            else
                s += "software";

            s += "\nAdapt: ";
            s += Colors::noAdapt ? "off" : "on";
            s += "\nAdaption occurred: ";
            s += Colors::adapted ? "yes" : "no";
            s += "\nOpenGL version: ";
            s += Colors::glVersion;
            QWidget w;
            s += "\nColor bit depth: ";
            s += QString::number(w.depth());
            s += "\nWanted FPS: ";
            s += QString::number(Colors::fps);
            s += "\nBenchmarked FPS: ";
            s += Colors::benchmarkFps != -1 ? QString::number(Colors::benchmarkFps) : "not calculated";
            s += "\nAnimations: ";
            s += Colors::noAnimations ? "off" : "on";
            s += "\nBlending: ";
            s += Colors::useEightBitPalette ? "off" : "on";
            s += "\nTicker: ";
            s += Colors::noTicker ? "off" : "on";
            s += "\nPixmaps: ";
            s += Colors::usePixmaps ? "on" : "off";
            s += "\nRescale images on resize: ";
            s += Colors::noRescale ? "off" : "on";
            s += "\nTimer based updates: ";
            s += Colors::noTimerUpdate ? "off" : "on";
            s += "\nSeparate loop: ";
            s += Colors::useLoop ? "yes" : "no";
            s += "\nScreen sync: ";
            s += Colors::noScreenSync ? "no" : "yes";
            QMessageBox::information(0, QString("Current configuration"), s);
    }
    QGraphicsView::keyPressEvent(event);
}
Beispiel #7
0
void Colors::postConfigure()
{
    if (!Colors::noAdapt){
        QWidget w;
        if (w.depth() < 16){
            Colors::useEightBitPalette = true;
            Colors::adapted = true;
            if (Colors::verbose)
                qDebug() << "- Adapt: Color depth less than 16 bit. Using 8 bit palette";
        }

        if (!Colors::xRenderPresent){
            Colors::setLowSettings();
            Colors::adapted = true;
            if (Colors::verbose)
                qDebug() << "- Adapt: X renderer not present. Using low settings";
        }
    }

#if !defined(Q_WS_WIN)
    if (Colors::direct3dRendering){
        Colors::direct3dRendering = false;
            qDebug() << "- WARNING: Direct3D specified, but not supported on this platform";
    }
#endif

    if (!Colors::openGlRendering && !Colors::direct3dRendering && !Colors::softwareRendering){
        // The user has not decided rendering system. So we do it instead:
#if defined(Q_WS_WIN)
        if (Colors::direct3dAwailable)
            Colors::direct3dRendering = true;
        else
#endif
        if (Colors::openGlAwailable)
            Colors::openGlRendering = true;
        else
            Colors::softwareRendering = true;
    }
}