Add glSwapStrategy support

icc-effect-5.14.5
Antonis Tsiapaliokas 2013-09-12 14:42:18 +03:00 committed by Martin Gräßlin
parent 5448c7ce36
commit 748d2d327f
3 changed files with 66 additions and 3 deletions

View File

@ -95,6 +95,24 @@ bool Compositing::unredirectFullscreen() const
return kwinConfig.readEntry("UnredirectFullscreen", false);
}
int Compositing::glSwapStrategy() const
{
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Compositing");
const QString glSwapStrategyValue = kwinConfig.readEntry("GLPreferBufferSwap", "a");
if (glSwapStrategyValue == "n") {
return 0;
} else if (glSwapStrategyValue == "a") {
return 1;
} else if (glSwapStrategyValue == "e") {
return 2;
} else if (glSwapStrategyValue == "p") {
return 3;
} else if (glSwapStrategyValue == "c") {
return 4;
}
}
CompositingType::CompositingType(QObject *parent)
: QAbstractItemModel(parent) {
@ -203,8 +221,9 @@ int CompositingType::currentOpenGLType()
}
void CompositingType::syncConfig(int openGLType, int animationSpeed, int windowThumbnail, int glSclaleFilter, bool xrSclaleFilter,
bool unredirectFullscreen)
bool unredirectFullscreen, int glSwapStrategy)
{
QString glSwapStrategyValue;
QString backend;
bool glLegacy;
bool glCore;
@ -233,6 +252,26 @@ void CompositingType::syncConfig(int openGLType, int animationSpeed, int windowT
break;
}
switch (glSwapStrategy) {
case 0:
glSwapStrategyValue = "n";
break;
case 1:
glSwapStrategyValue = "a";
break;
case 2:
glSwapStrategyValue = "e";
break;
case 3:
glSwapStrategyValue = "p";
break;
case 4:
glSwapStrategyValue = "c";
break;
default:
glSwapStrategyValue = "a";
}
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Compositing");
kwinConfig.writeEntry("Backend", backend);
kwinConfig.writeEntry("GLLegacy", glLegacy);
@ -242,6 +281,7 @@ void CompositingType::syncConfig(int openGLType, int animationSpeed, int windowT
kwinConfig.writeEntry("GLTextureFilter", glSclaleFilter);
kwinConfig.writeEntry("XRenderSmoothScale", xrSclaleFilter);
kwinConfig.writeEntry("UnredirectFullscreen", unredirectFullscreen);
kwinConfig.writeEntry("GLPreferBufferSwap", glSwapStrategyValue);
kwinConfig.sync();
}

View File

@ -37,6 +37,7 @@ class Compositing : public QObject
Q_PROPERTY(int glSclaleFilter READ glSclaleFilter CONSTANT);
Q_PROPERTY(bool xrSclaleFilter READ xrSclaleFilter CONSTANT);
Q_PROPERTY(bool unredirectFullscreen READ unredirectFullscreen CONSTANT);
Q_PROPERTY(int glSwapStrategy READ glSwapStrategy CONSTANT);
public:
explicit Compositing(QObject *parent = 0);
@ -47,6 +48,7 @@ public:
int glSclaleFilter() const;
bool xrSclaleFilter() const;
bool unredirectFullscreen() const;
int glSwapStrategy() const;
private:
@ -91,7 +93,7 @@ public:
Q_INVOKABLE int currentOpenGLType();
Q_INVOKABLE void syncConfig(int openGLType, int animationSpeed, int windowThumbnail, int glSclaleFilter, bool xrSclaleFilter,
bool unredirectFullscreen);
bool unredirectFullscreen, int glSwapStrategy);
private:
void generateCompositing();

View File

@ -166,6 +166,27 @@ Item {
onClicked: apply.enabled = true
}
Label {
id: glSwapStrategyText
text: i18n("Tearing Prevention (VSync):")
anchors {
top: unredirectFullScreen.bottom
horizontalCenter: windowManagement.horizontalCenter
topMargin: 20
}
}
ComboBox {
id: glSwapStrategy
model: [i18n("Never"), i18n("Automatic"), i18n("Only when cheap"), i18n("Full screen repaints"), i18n("Re-use screen content")]
currentIndex: compositing.glSwapStrategy
anchors {
top: glSwapStrategyText.bottom
left: col.right
right: parent.right
}
onCurrentIndexChanged: apply.enabled = true;
}
ColumnLayout {
id: col
@ -246,7 +267,7 @@ Item {
onClicked: {
searchModel.syncConfig();
apply.enabled = false;
compositingType.syncConfig(openGLType.currentIndex, animationSpeed.value, windowThumbnail.currentIndex, glScaleFilter.currentIndex, xrScaleFilter.currentIndex == 1, unredirectFullScreen.checked);
compositingType.syncConfig(openGLType.currentIndex, animationSpeed.value, windowThumbnail.currentIndex, glScaleFilter.currentIndex, xrScaleFilter.currentIndex == 1, unredirectFullScreen.checked, glSwapStrategy.currentIndex);
}
}