Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix interface of KisOpenGLContextSwitchLock
Dmitry Kazakove1319488dfb9
diff --git a/libs/ui/opengl/KisOpenGLContextSwitchLock.cpp b/libs/ui/opengl/KisOpenGLContextSwitchLock.cppindex a423a4ebcf..e9ecdb2e0c 100644--- a/libs/ui/opengl/KisOpenGLContextSwitchLock.cpp+++ b/libs/ui/opengl/KisOpenGLContextSwitchLock.cpp@@ -12,9 +12,10 @@namespace {+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)inline bool shouldUseLock(){-#if defined(Q_OS_MACOS) || defined(Q_OS_ANDROID) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)+# if defined(Q_OS_MACOS) || defined(Q_OS_ANDROID)/*** On OSX openGL different (shared) contexts have different execution queues.* It means that the textures uploading and their painting can be easily reordered.@@ -22,12 +23,12 @@ inline bool shouldUseLock()* same openGL context as the painting is done.*/return true;-#else+# elsestatic const bool s_shouldUseLock = qEnvironmentVariableIsSet("KRITA_USE_STRICT_OPENGL_CONTEXT_SWITCH");return s_shouldUseLock;-#endif+# endif}-+#endif}KisOpenGLContextSwitchLockAdapter::KisOpenGLContextSwitchLockAdapter(QOpenGLWidget *targetWidget)@@ -36,14 +37,12 @@ KisOpenGLContextSwitchLockAdapter::KisOpenGLContextSwitchLockAdapter(QOpenGLWidg}void KisOpenGLContextSwitchLockAdapter::lock() {- if (!shouldUseLock()) return;m_oldContext = QOpenGLContext::currentContext();m_oldSurface = m_oldContext ? m_oldContext->surface() : nullptr;m_targetWidget->makeCurrent();}void KisOpenGLContextSwitchLockAdapter::unlock() {- if (!shouldUseLock()) return;if (m_oldContext) {m_oldContext->makeCurrent(m_oldSurface);} else {@@ -51,3 +50,18 @@ void KisOpenGLContextSwitchLockAdapter::unlock() {}}+void KisOpenGLContextSwitchLockAdapterSkipOnQt5::lock()+{+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)+ if (!shouldUseLock()) return;+#endif+ KisOpenGLContextSwitchLockAdapter::lock();+}++void KisOpenGLContextSwitchLockAdapterSkipOnQt5::unlock()+{+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)+ if (!shouldUseLock()) return;+#endif+ KisOpenGLContextSwitchLockAdapter::unlock();+}\ No newline at end of filediff --git a/libs/ui/opengl/KisOpenGLContextSwitchLock.h b/libs/ui/opengl/KisOpenGLContextSwitchLock.hindex feb722c3b2..fdd2ac2371 100644--- a/libs/ui/opengl/KisOpenGLContextSwitchLock.h+++ b/libs/ui/opengl/KisOpenGLContextSwitchLock.h@@ -25,9 +25,19 @@ public:private:QOpenGLWidget *m_targetWidget {nullptr};QOpenGLContext *m_oldContext {nullptr};- QSurface *m_oldSurface = {nullptr};+ QSurface *m_oldSurface {nullptr};+};++class KRITAUI_EXPORT KisOpenGLContextSwitchLockAdapterSkipOnQt5 : public KisOpenGLContextSwitchLockAdapter+{+public:+ using KisOpenGLContextSwitchLockAdapter::KisOpenGLContextSwitchLockAdapter;++ void lock();+ void unlock();};KIS_DECLARE_ADAPTED_LOCK(KisOpenGLContextSwitchLock, KisOpenGLContextSwitchLockAdapter)+KIS_DECLARE_ADAPTED_LOCK(KisOpenGLContextSwitchLockSkipOnQt5, KisOpenGLContextSwitchLockAdapterSkipOnQt5)#endif // KISOPENGLCONTEXTSWITCHLOCK_Hdiff --git a/libs/ui/opengl/kis_opengl_canvas2.cpp b/libs/ui/opengl/kis_opengl_canvas2.cppindex 4587004200..a8490354ea 100644--- a/libs/ui/opengl/kis_opengl_canvas2.cpp+++ b/libs/ui/opengl/kis_opengl_canvas2.cpp@@ -152,13 +152,13 @@ KisOpenGLCanvas2::~KisOpenGLCanvas2()void KisOpenGLCanvas2::setDisplayFilter(QSharedPointer<KisDisplayFilter> displayFilter){- KisOpenGLContextSwitchLock contextLock(this);+ KisOpenGLContextSwitchLockSkipOnQt5 contextLock(this);d->renderer->setDisplayFilter(displayFilter);}void KisOpenGLCanvas2::notifyImageColorSpaceChanged(const KoColorSpace *cs){- KisOpenGLContextSwitchLock contextLock(this);+ KisOpenGLContextSwitchLockSkipOnQt5 contextLock(this);d->renderer->notifyImageColorSpaceChanged(cs);}@@ -346,7 +346,7 @@ void KisOpenGLCanvas2::showEvent(QShowEvent *e)void KisOpenGLCanvas2::setDisplayColorConverter(KisDisplayColorConverter *colorConverter){- KisOpenGLContextSwitchLock contextLock(this);+ KisOpenGLContextSwitchLockSkipOnQt5 contextLock(this);d->renderer->setDisplayColorConverter(colorConverter);}@@ -358,7 +358,7 @@ void KisOpenGLCanvas2::channelSelectionChanged(const QBitArray &channelFlags)void KisOpenGLCanvas2::finishResizingImage(qint32 w, qint32 h){- KisOpenGLContextSwitchLock contextLock(this);+ KisOpenGLContextSwitchLockSkipOnQt5 contextLock(this);d->renderer->finishResizingImage(w, h);}@@ -375,7 +375,7 @@ QRect KisOpenGLCanvas2::updateCanvasProjection(KisUpdateInfoSP info)QVector<QRect> KisOpenGLCanvas2::updateCanvasProjection(const QVector<KisUpdateInfoSP> &infoObjects){- KisOpenGLContextSwitchLock contextLock(this);+ KisOpenGLContextSwitchLockSkipOnQt5 contextLock(this);return KisCanvasWidgetBase::updateCanvasProjection(infoObjects);}