Commit bf4e20d4 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Make Krita not request any specific renderer, when OpenGL is disabled

Important note: now we don't have any specific option for openGL,
we just write "none" into the renderer field.

CCBUG:408872
parent 23f6603b
......@@ -230,10 +230,10 @@ KisView *KisPart::createView(KisDocument *document,
KisConfig cfg(false);
KConfigGroup grp( KSharedConfig::openConfig(), "crashprevention");
if (grp.readEntry("CreatingCanvas", false)) {
cfg.setUseOpenGL(false);
cfg.disableOpenGL();
}
if (cfg.canvasState() == "OPENGL_FAILED") {
cfg.setUseOpenGL(false);
cfg.disableOpenGL();
}
grp.writeEntry("CreatingCanvas", true);
grp.sync();
......
......@@ -1689,16 +1689,18 @@ bool KisDlgPreferences::editPreferences()
dialog->m_performanceSettings->save();
{
if (!cfg.useOpenGL() && dialog->m_displaySettings->grpOpenGL->isChecked())
cfg.setCanvasState("TRY_OPENGL");
if (dialog->m_displaySettings->grpOpenGL->isChecked()) {
KisOpenGL::OpenGLRenderer renderer = static_cast<KisOpenGL::OpenGLRenderer>(
dialog->m_displaySettings->cmbPreferredRenderer->itemData(
dialog->m_displaySettings->cmbPreferredRenderer->currentIndex()).toInt());
KisOpenGL::setUserPreferredOpenGLRendererConfig(renderer);
} else {
KisOpenGL::setUserPreferredOpenGLRendererConfig(KisOpenGL::RendererNone);
}
if (!cfg.useOpenGL() && dialog->m_displaySettings->grpOpenGL->isChecked())
cfg.setCanvasState("TRY_OPENGL");
cfg.setUseOpenGL(dialog->m_displaySettings->grpOpenGL->isChecked());
cfg.setUseOpenGLTextureBuffer(dialog->m_displaySettings->chkUseTextureBuffer->isChecked());
cfg.setOpenGLFilteringMode(dialog->m_displaySettings->cmbFilterMode->currentIndex());
cfg.setDisableVSync(dialog->m_displaySettings->chkDisableVsync->isChecked());
......
......@@ -665,22 +665,18 @@ bool KisConfig::useOpenGL(bool defaultValue) const
return true;
}
//dbgKrita << "use opengl" << m_cfg.readEntry("useOpenGL", true) << "success" << m_cfg.readEntry("canvasState", "OPENGL_SUCCESS");
QString cs = canvasState();
#ifdef Q_OS_WIN
return (m_cfg.readEntry("useOpenGLWindows", true) && (cs == "OPENGL_SUCCESS" || cs == "TRY_OPENGL"));
#else
return (m_cfg.readEntry("useOpenGL", true) && (cs == "OPENGL_SUCCESS" || cs == "TRY_OPENGL"));
#endif
const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
return kritarc.value("OpenGLRenderer", "auto").toString() != "none";
}
void KisConfig::setUseOpenGL(bool useOpenGL) const
void KisConfig::disableOpenGL() const
{
#ifdef Q_OS_WIN
m_cfg.writeEntry("useOpenGLWindows", useOpenGL);
#else
m_cfg.writeEntry("useOpenGL", useOpenGL);
#endif
const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
kritarc.setValue("OpenGLRenderer", "none");
}
int KisConfig::openGLFilteringMode(bool defaultValue) const
......
......@@ -178,7 +178,7 @@ public:
void setRenderIntent(qint32 monitorRenderIntent) const;
bool useOpenGL(bool defaultValue = false) const;
void setUseOpenGL(bool useOpenGL) const;
void disableOpenGL() const;
int openGLFilteringMode(bool defaultValue = false) const;
void setOpenGLFilteringMode(int filteringMode);
......
......@@ -353,6 +353,8 @@ void KisOpenGL::setUserPreferredOpenGLRendererConfig(KisOpenGL::OpenGLRenderer r
QString KisOpenGL::convertOpenGLRendererToConfig(KisOpenGL::OpenGLRenderer renderer)
{
switch (renderer) {
case RendererNone:
return QStringLiteral("none");
case RendererSoftware:
return QStringLiteral("software");
case RendererDesktopGL:
......@@ -372,6 +374,8 @@ KisOpenGL::OpenGLRenderer KisOpenGL::convertConfigToOpenGLRenderer(QString rende
return RendererOpenGLES;
} else if (renderer == "software") {
return RendererSoftware;
} else if (renderer == "none") {
return RendererNone;
} else {
return RendererAuto;
}
......@@ -413,6 +417,8 @@ RendererInfo getRendererInfo(KisOpenGL::OpenGLRenderer renderer)
switch (renderer) {
case KisOpenGL::RendererNone:
info = {QSurfaceFormat::DefaultRenderableType, KisOpenGL::AngleRendererDefault};
break;
case KisOpenGL::RendererAuto:
break;
case KisOpenGL::RendererDesktopGL:
......@@ -643,7 +649,8 @@ private:
KIS_SAFE_ASSERT_RECOVER_NOOP(r == KisOpenGL::RendererAuto ||
r == KisOpenGL::RendererDesktopGL ||
r == KisOpenGL::RendererOpenGLES ||
r == KisOpenGL::RendererSoftware);
r == KisOpenGL::RendererSoftware ||
r == KisOpenGL::RendererNone);
return (r == KisOpenGL::RendererDesktopGL && m_openGLBlacklisted) ||
(r == KisOpenGL::RendererOpenGLES && m_openGLESBlacklisted) ||
......@@ -718,9 +725,6 @@ KisOpenGL::RendererConfig KisOpenGL::selectSurfaceConfig(KisOpenGL::OpenGLRender
#ifdef Q_OS_WIN
if (!info) {
renderersToTest.remove(RendererDesktopGL);
renderersToTest.remove(RendererOpenGLES);
// try software rasterizer (WARP)
defaultConfig = generateSurfaceConfig(KisOpenGL::RendererSoftware,
KisConfig::BT709_G22, false);
......@@ -737,7 +741,6 @@ KisOpenGL::RendererConfig KisOpenGL::selectSurfaceConfig(KisOpenGL::OpenGLRender
const OpenGLRenderer defaultRenderer = getRendererFromProbeResult(*info);
OpenGLRenderers supportedRenderers = RendererNone;
supportedRenderers |= defaultRenderer;
FormatPositionLess compareOp;
compareOp.setPreferredRendererByQt(defaultRenderer);
......@@ -819,57 +822,62 @@ KisOpenGL::RendererConfig KisOpenGL::selectSurfaceConfig(KisOpenGL::OpenGLRender
KisOpenGL::RendererConfig resultConfig = defaultConfig;
Q_FOREACH (const KisOpenGL::RendererConfig &config, preferredConfigs) {
if (preferredRenderer != RendererNone) {
Q_FOREACH (const KisOpenGL::RendererConfig &config, preferredConfigs) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
dbgDetection() <<"Probing format..." << config.format.colorSpace() << config.rendererId();
dbgDetection() <<"Probing format..." << config.format.colorSpace() << config.rendererId();
#else
dbgDetection() <<"Probing format..." << config.rendererId();
dbgDetection() <<"Probing format..." << config.rendererId();
#endif
Info info = KisOpenGLModeProber::instance()->probeFormat(config);
Info info = KisOpenGLModeProber::instance()->probeFormat(config);
if (info && info->isSupportedVersion()) {
if (info && info->isSupportedVersion()) {
#ifdef Q_OS_WIN
// HACK: Block ANGLE with Direct3D9
// Direct3D9 does not give OpenGL ES 3.0
// Some versions of ANGLE returns OpenGL version 3.0 incorrectly
// HACK: Block ANGLE with Direct3D9
// Direct3D9 does not give OpenGL ES 3.0
// Some versions of ANGLE returns OpenGL version 3.0 incorrectly
if (info->isUsingAngle() &&
info->rendererString().contains("Direct3D9", Qt::CaseInsensitive)) {
if (info->isUsingAngle() &&
info->rendererString().contains("Direct3D9", Qt::CaseInsensitive)) {
dbgDetection() << "Skipping Direct3D 9 Angle implementation, it shouldn't have happened.";
dbgDetection() << "Skipping Direct3D 9 Angle implementation, it shouldn't have happened.";
continue;
}
continue;
}
#endif
dbgDetection() << "Found format:" << config.format;
dbgDetection() << " " << config.rendererId();
dbgDetection() << "Found format:" << config.format;
dbgDetection() << " " << config.rendererId();
resultConfig = config;
break;
resultConfig = config;
break;
}
}
}
{
const bool colorSpaceIsCorrect =
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
KisOpenGLModeProber::fuzzyCompareColorSpaces(compareOp.preferredColorSpace(),
resultConfig.format.colorSpace());
{
const bool colorSpaceIsCorrect =
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
KisOpenGLModeProber::fuzzyCompareColorSpaces(compareOp.preferredColorSpace(),
resultConfig.format.colorSpace());
#else
true;
true;
#endif
const bool rendererIsCorrect =
compareOp.preferredRendererByUser() == KisOpenGL::RendererAuto ||
compareOp.preferredRendererByUser() == resultConfig.rendererId();
const bool rendererIsCorrect =
compareOp.preferredRendererByUser() == KisOpenGL::RendererAuto ||
compareOp.preferredRendererByUser() == resultConfig.rendererId();
if (!rendererIsCorrect && colorSpaceIsCorrect) {
warningMessages << ki18n("Preferred renderer doesn't support requested surface format. Another renderer has been selected.");
} else if (!colorSpaceIsCorrect) {
warningMessages << ki18n("Preferred output format is not supported by available renderers");
}
if (!rendererIsCorrect && colorSpaceIsCorrect) {
warningMessages << ki18n("Preferred renderer doesn't support requested surface format. Another renderer has been selected.");
} else if (!colorSpaceIsCorrect) {
warningMessages << ki18n("Preferred output format is not supported by available renderers");
}
}
} else {
resultConfig.format = QSurfaceFormat();
resultConfig.angleRenderer = AngleRendererDefault;
}
overrideSupportedRenderers(supportedRenderers, preferredByQt);
......@@ -893,7 +901,7 @@ void KisOpenGL::setDefaultSurfaceConfig(const KisOpenGL::RendererConfig &config)
if (config.format.renderableType() == QSurfaceFormat::OpenGLES) {
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES, true);
} else {
} else if (config.format.renderableType() == QSurfaceFormat::OpenGL) {
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL, true);
}
}
......
......@@ -378,7 +378,7 @@ void KisOpenGLCanvas2::reportFailedShaderCompilation(const QString &context)
i18n("Krita could not initialize the OpenGL canvas:\n\n%1\n\n Krita will disable OpenGL and close now.", context),
QMessageBox::Close);
cfg.setUseOpenGL(false);
cfg.disableOpenGL();
cfg.setCanvasState("OPENGL_FAILED");
}
......
......@@ -68,7 +68,7 @@ void addResourceTypes()
KisOpenGL::testingInitializeDefaultSurfaceFormat();
KisConfig cfg(false);
cfg.setUseOpenGL(false);
cfg.disableOpenGL();
}
void KisDerivedResourcesTest::test()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment