28 public QNativeInterface::QEGLContext
34 Q_DECLARE_FLAGS(Flags, Flag)
36 QEGLPlatformContext(
const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
37 EGLConfig *config =
nullptr, Flags flags = { });
40 static QOpenGLContext *createFrom(EGLContext context, EGLDisplay contextDisplay,
41 EGLDisplay platformDisplay, QOpenGLContext *shareContext)
47 if (contextDisplay != platformDisplay) {
48 qWarning(
"QEGLPlatformContext: Cannot adopt context from different display");
52 QPlatformOpenGLContext *shareHandle = shareContext ? shareContext->handle() :
nullptr;
54 auto *resultingContext =
new QOpenGLContext;
55 auto *contextPrivate = QOpenGLContextPrivate::get(resultingContext);
56 auto *platformContext =
new T;
57 platformContext->adopt(context, contextDisplay, shareHandle);
58 contextPrivate->adopt(platformContext);
59 return resultingContext;
62 ~QEGLPlatformContext();
64 void initialize() override;
65 bool makeCurrent(QPlatformSurface *surface) override;
66 void doneCurrent() override;
67 void swapBuffers(QPlatformSurface *surface) override;
68 QFunctionPointer getProcAddress(
const char *procName) override;
70 QSurfaceFormat format()
const override;
71 bool isSharing()
const override {
return m_shareContext != EGL_NO_CONTEXT; }
72 bool isValid()
const override {
return m_eglContext != EGL_NO_CONTEXT && !m_markedInvalid; }
74 EGLContext nativeContext()
const override {
return eglContext(); }
75 EGLConfig config()
const override {
return eglConfig(); }
76 EGLDisplay display()
const override {
return eglDisplay(); }
78 virtual void invalidateContext() override { m_markedInvalid =
true; }
80 EGLContext eglContext()
const;
81 EGLDisplay eglDisplay()
const;
82 EGLConfig eglConfig()
const;
85 QEGLPlatformContext() {}
86 virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0;
87 virtual EGLSurface createTemporaryOffscreenSurface();
88 virtual void destroyTemporaryOffscreenSurface(EGLSurface surface);
89 virtual void runGLChecks();
92 void adopt(EGLContext context, EGLDisplay display, QPlatformOpenGLContext *shareContext);
93 void updateFormatFromGL();
95 EGLContext m_eglContext;
96 EGLContext m_shareContext;
97 EGLDisplay m_eglDisplay;
98 EGLConfig m_eglConfig;
99 QSurfaceFormat m_format;
101 int m_swapInterval = -1;
102 bool m_swapIntervalEnvChecked =
false;
103 int m_swapIntervalFromEnv = -1;
105 bool m_ownsContext =
false;
106 QList<EGLint> m_contextAttrs;
108 bool m_markedInvalid =
false;