[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra] krita/ui: Add options to enable/disable double buffering and vsync
From:       Boudewijn Rempt <boud () valdyas ! org>
Date:       2014-03-29 11:34:59
Message-ID: E1WTrXP-0001Rg-GQ () scm ! kde ! org
[Download RAW message or body]

Git commit a5d500549a9070a166ed2a330a48952410b853b2 by Boudewijn Rempt.
Committed on 29/03/2014 at 11:33.
Pushed by rempt into branch 'master'.

Add options to enable/disable double buffering and vsync

These options are hidden by default. Set showAdvancedOpenGLSettings to
true in the krita config file to see them. Disabling vsync and/or
double buffering causes crashes with some ATI cards, so these options
exist to experiment with those cards/driver combinations.

M  +16   -0    krita/ui/dialogs/kis_dlg_preferences.cc
M  +39   -13   krita/ui/forms/wdgdisplaysettings.ui
M  +26   -0    krita/ui/kis_config.cc
M  +8    -0    krita/ui/kis_config.h
M  +5    -1    krita/ui/opengl/kis_opengl.cpp
M  +20   -17   krita/ui/opengl/kis_opengl_canvas2.cpp

http://commits.kde.org/calligra/a5d500549a9070a166ed2a330a48952410b853b2

diff --git a/krita/ui/dialogs/kis_dlg_preferences.cc \
b/krita/ui/dialogs/kis_dlg_preferences.cc index 53a66b3..472a63c 100644
--- a/krita/ui/dialogs/kis_dlg_preferences.cc
+++ b/krita/ui/dialogs/kis_dlg_preferences.cc
@@ -425,11 +425,19 @@ DisplaySettingsTab::DisplaySettingsTab(QWidget *parent, const \
char *name)  if (!QGLFormat::hasOpenGL()) {
         cbUseOpenGL->setEnabled(false);
         chkUseTextureBuffer->setEnabled(false);
+        chkDisableDoubleBuffering->setEnabled(false);
+        chkDisableVsync->setEnabled(false);
         cmbFilterMode->setEnabled(false);
     } else {
         cbUseOpenGL->setChecked(cfg.useOpenGL());
         chkUseTextureBuffer->setEnabled(cfg.useOpenGL());
         chkUseTextureBuffer->setChecked(cfg.useOpenGLTextureBuffer());
+        chkDisableDoubleBuffering->setVisible(cfg.showAdvancedOpenGLSettings());
+        chkDisableDoubleBuffering->setEnabled(cfg.useOpenGL());
+        chkDisableDoubleBuffering->setChecked(cfg.disableDoubleBuffering());
+        chkDisableVsync->setVisible(cfg.showAdvancedOpenGLSettings());
+        chkDisableVsync->setEnabled(cfg.useOpenGL());
+        chkDisableVsync->setChecked(cfg.disableVSync());
         cmbFilterMode->setEnabled(cfg.useOpenGL());
         cmbFilterMode->setCurrentIndex(cfg.openGLFilteringMode());
         // Don't show the high quality filtering mode if it's not available
@@ -462,6 +470,10 @@ void DisplaySettingsTab::setDefault()
     cbUseOpenGL->setChecked(true);
     chkUseTextureBuffer->setChecked(false);
     chkUseTextureBuffer->setEnabled(true);
+    chkDisableDoubleBuffering->setEnabled(true);
+    chkDisableDoubleBuffering->setChecked(true);
+    chkDisableVsync->setEnabled(true);
+    chkDisableVsync->setChecked(true);
     cmbFilterMode->setEnabled(true);
     cmbFilterMode->setCurrentIndex(1);
     chkMoving->setChecked(true);
@@ -478,6 +490,8 @@ void DisplaySettingsTab::slotUseOpenGLToggled(bool isChecked)
 {
 #ifdef HAVE_OPENGL
     chkUseTextureBuffer->setEnabled(isChecked);
+    chkDisableDoubleBuffering->setEnabled(isChecked);
+    chkDisableVsync->setEnabled(isChecked);
     cmbFilterMode->setEnabled(isChecked);
 #else
     Q_UNUSED(isChecked);
@@ -800,6 +814,8 @@ bool KisDlgPreferences::editPreferences()
         cfg.setUseOpenGL(dialog->m_displaySettings->cbUseOpenGL->isChecked());
         cfg.setUseOpenGLTextureBuffer(dialog->m_displaySettings->chkUseTextureBuffer->isChecked());
                
         cfg.setOpenGLFilteringMode(dialog->m_displaySettings->cmbFilterMode->currentIndex());
 +        cfg.setDisableDoubleBuffering(dialog->m_displaySettings->chkDisableDoubleBuffering->isChecked());
 +        cfg.setDisableVSync(dialog->m_displaySettings->chkDisableVsync->isChecked());
  #endif
 
         cfg.setCheckSize(dialog->m_displaySettings->intCheckSize->value());
diff --git a/krita/ui/forms/wdgdisplaysettings.ui \
b/krita/ui/forms/wdgdisplaysettings.ui index ef2303e..e81b9b6 100644
--- a/krita/ui/forms/wdgdisplaysettings.ui
+++ b/krita/ui/forms/wdgdisplaysettings.ui
@@ -197,27 +197,20 @@
       <string>OpenGL</string>
      </property>
      <layout class="QGridLayout">
-      <item row="2" column="0">
-       <widget class="QCheckBox" name="chkUseTextureBuffer">
+      <item row="3" column="0">
+       <widget class="QCheckBox" name="chkDisableDoubleBuffering">
         <property name="toolTip">
-         <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use Texture \
Buffering. This can be faster on some GPU/Driver combinations (like Intel) or broken \
on some others (like AMD/Radeon).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> +      \
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Try to disable double \
buffering. This makes painting more responsive, but might cause crashes with some ATI \
GPU/driver combinations.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>  </property>
         <property name="text">
-         <string>Use Texture Buffer</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="0">
-       <widget class="QCheckBox" name="cbUseOpenGL">
-        <property name="text">
-         <string>Enable OpenGL</string>
+         <string>Disable double buffering (needs restart)</string>
         </property>
         <property name="checked">
          <bool>true</bool>
         </property>
        </widget>
       </item>
-      <item row="4" column="0">
+      <item row="6" column="0">
        <widget class="QComboBox" name="cmbFilterMode">
         <property name="currentIndex">
          <number>0</number>
@@ -244,13 +237,46 @@
         </item>
        </widget>
       </item>
-      <item row="3" column="0">
+      <item row="2" column="0">
+       <widget class="QCheckBox" name="chkUseTextureBuffer">
+        <property name="toolTip">
+         <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use Texture \
Buffering. This can be faster on some GPU/Driver combinations (like Intel) or broken \
on some others (like AMD/Radeon).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> +      \
</property> +        <property name="text">
+         <string>Use Texture Buffer</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0">
+       <widget class="QCheckBox" name="cbUseOpenGL">
+        <property name="text">
+         <string>Enable OpenGL</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="0">
        <widget class="QLabel" name="label">
         <property name="text">
          <string>Scaling Mode:</string>
         </property>
        </widget>
       </item>
+      <item row="4" column="0">
+       <widget class="QCheckBox" name="chkDisableVsync">
+        <property name="toolTip">
+         <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Try to disable vsync \
for Krita. This makes painting more responsive. Uncheck only when experiencing \
crashes with some GPU/driver \
combinations.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> +        </property>
+        <property name="text">
+         <string>Disable vsync (needs restart)</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
diff --git a/krita/ui/kis_config.cc b/krita/ui/kis_config.cc
index 7f86361..271a13a 100644
--- a/krita/ui/kis_config.cc
+++ b/krita/ui/kis_config.cc
@@ -408,6 +408,32 @@ int KisConfig::openGLTextureSize() const
     return m_cfg.readEntry("textureSize", 256);
 }
 
+
+bool KisConfig::disableDoubleBuffering() const
+{
+    return m_cfg.readEntry("disableDoubleBuffering", true);
+}
+
+void KisConfig::setDisableDoubleBuffering(bool disableDoubleBuffering)
+{
+    m_cfg.writeEntry("disableDoubleBuffering", disableDoubleBuffering);
+}
+
+bool KisConfig::disableVSync() const
+{
+    return m_cfg.readEntry("disableVSync", true);
+}
+
+void KisConfig::setDisableVSync(bool disableVSync)
+{
+    m_cfg.writeEntry("disableVSync", disableVSync);
+}
+
+bool KisConfig::showAdvancedOpenGLSettings() const
+{
+    return m_cfg.readEntry("showAdvancedOpenGLSettings", false);
+}
+
 int KisConfig::numMipmapLevels() const
 {
     return m_cfg.readEntry("numMipmapLevels", 4);
diff --git a/krita/ui/kis_config.h b/krita/ui/kis_config.h
index 76555c2..be6d50f 100644
--- a/krita/ui/kis_config.h
+++ b/krita/ui/kis_config.h
@@ -128,6 +128,14 @@ public:
     bool useOpenGLTextureBuffer() const;
     void setUseOpenGLTextureBuffer(bool useBuffer);
 
+    bool disableDoubleBuffering() const;
+    void setDisableDoubleBuffering(bool disableDoubleBuffering);
+
+    bool disableVSync() const;
+    void setDisableVSync(bool disableVSync);
+
+    bool showAdvancedOpenGLSettings() const;
+
     int numMipmapLevels() const;
     int openGLTextureSize() const;
     int textureOverlapBorder() const;
diff --git a/krita/ui/opengl/kis_opengl.cpp b/krita/ui/opengl/kis_opengl.cpp
index 8c14822..655a129 100644
--- a/krita/ui/opengl/kis_opengl.cpp
+++ b/krita/ui/opengl/kis_opengl.cpp
@@ -102,7 +102,11 @@ void KisOpenGL::createContext()
         qDebug() << "Using the compatibility profile";
 #endif
 */
-    format.setDoubleBuffer(false);
+
+    KisConfig cfg;
+    if (cfg.disableDoubleBuffering()) {
+        format.setDoubleBuffer(false);
+    }
 
     SharedContextWidget = new QGLWidget(format);
     SharedContextWidget->setObjectName("Krita OpenGL Shared Context Widget");
diff --git a/krita/ui/opengl/kis_opengl_canvas2.cpp \
b/krita/ui/opengl/kis_opengl_canvas2.cpp index 857ea77..14a5a10 100644
--- a/krita/ui/opengl/kis_opengl_canvas2.cpp
+++ b/krita/ui/opengl/kis_opengl_canvas2.cpp
@@ -186,23 +186,26 @@ void KisOpenGLCanvas2::setWrapAroundViewingMode(bool value)
 
 void KisOpenGLCanvas2::initializeGL()
 {
-    if (!VSyncWorkaround::tryDisableVSync(this)) {
-        qWarning();
-        qWarning() << "WARNING: We didn't manage to switch off VSync on your \
                graphics adapter.";
-        qWarning() << "WARNING: It means either your hardware or driver doesn't \
                support it,";
-        qWarning() << "WARNING: or we just don't know about this hardware. Please \
                report us a bug";
-        qWarning() << "WARNING: with the output of \'glxinfo\' for your card.";
-        qWarning();
-        qWarning() << "WARNING: Trying to workaround it by disabling Double \
                Buffering.";
-        qWarning() << "WARNING: You may see some flickering when painting with some \
                tools. It doesn't";
-        qWarning() << "WARNING: affect the quality of the final image, though.";
-        qWarning();
-
-        if (doubleBuffer()) {
-            qCritical() << "CRITICAL: Failed to disable Double Buffering. Lines may \
                look \"bended\" on your image.";
-            qCritical() << "CRITICAL: Your graphics card or driver does not fully \
                support Krita's OpenGL canvas.";
-            qCritical() << "CRITICAL: For an optimal experience, please disable \
                OpenGL";
-            qCritical();
+    KisConfig cfg;
+    if (cfg.disableVSync()) {
+        if (!VSyncWorkaround::tryDisableVSync(this)) {
+            qWarning();
+            qWarning() << "WARNING: We didn't manage to switch off VSync on your \
graphics adapter."; +            qWarning() << "WARNING: It means either your \
hardware or driver doesn't support it,"; +            qWarning() << "WARNING: or we \
just don't know about this hardware. Please report us a bug"; +            qWarning() \
<< "WARNING: with the output of \'glxinfo\' for your card."; +            qWarning();
+            qWarning() << "WARNING: Trying to workaround it by disabling Double \
Buffering."; +            qWarning() << "WARNING: You may see some flickering when \
painting with some tools. It doesn't"; +            qWarning() << "WARNING: affect \
the quality of the final image, though."; +            qWarning();
+
+            if (cfg.disableDoubleBuffering() && doubleBuffer()) {
+                qCritical() << "CRITICAL: Failed to disable Double Buffering. Lines \
may look \"bended\" on your image."; +                qCritical() << "CRITICAL: Your \
graphics card or driver does not fully support Krita's OpenGL canvas."; +             \
qCritical() << "CRITICAL: For an optimal experience, please disable OpenGL"; +        \
qCritical(); +            }
         }
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic