summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaglcontext.h
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-07-31 14:59:37 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-08-07 21:25:12 +0000
commit823acb069d92b68b36f1b2bb59575bb0595275b4 (patch)
tree15249a5b2aab861b347338c52ab006709044eaf2 /src/plugins/platforms/cocoa/qcocoaglcontext.h
parentee2e38490d51667e878ed1732df387a6d9f2a5fe (diff)
macOS: Don't call [NSOpenGLContext update] for every frame
Calling update has a cost, and should only be done when the drawable object changes size or location. Instead of calling update each time makeCurrent is called, we listen for the appropriate notifications, limiting the number of update calls significantly. The code has also been refactored to get rid of the m_activeWindow member, as the active window can be tracked through the context's drawable object property. There is also no need to clear the drawable when a window is hidden, so the hook into QCocoaWindow can be removed. The QPlatformNativeInterface hook is internal and can safely be removed. Task-number: QTBUG-63572 Change-Id: I70e3267f47882e151144bd36a50abe906164429a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaglcontext.h')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h
index 0e5934bc23..3f7966b247 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.h
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h
@@ -41,6 +41,9 @@
#define QCOCOAGLCONTEXT_H
#include <QtCore/QPointer>
+#include <QtCore/qvector.h>
+#include <QtCore/private/qcore_mac_p.h>
+
#include <qpa/qplatformopenglcontext.h>
#include <QtGui/QOpenGLContext>
#include <QtGui/QWindow>
@@ -65,8 +68,6 @@ public:
bool isSharing() const override;
bool isValid() const override;
- void windowWasHidden();
-
NSOpenGLContext *nativeContext() const;
QFunctionPointer getProcAddress(const char *procName) override;
@@ -74,14 +75,14 @@ public:
private:
static NSOpenGLPixelFormat *pixelFormatForSurfaceFormat(const QSurfaceFormat &format);
- bool setActiveWindow(QWindow *window);
+ bool setDrawable(QPlatformSurface *surface);
void updateSurfaceFormat();
NSOpenGLContext *m_context = nil;
NSOpenGLContext *m_shareContext = nil;
QSurfaceFormat m_format;
- QPointer<QWindow> m_currentWindow;
bool m_didCheckForSoftwareContext = false;
+ QVarLengthArray<QMacScopedObserver, 3> m_observers;
};
QT_END_NAMESPACE