From 5f27a5fff7f24d57c39e4b79feeeb4c408c89139 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Wed, 23 Jun 2021 00:01:04 +0100 Subject: GHOST/EGL: store pointer to GHOST_System for downcast tests --- intern/ghost/intern/GHOST_ContextEGL.cpp | 4 +++- intern/ghost/intern/GHOST_ContextEGL.h | 6 +++++- intern/ghost/intern/GHOST_SystemWayland.cpp | 6 ++++-- intern/ghost/intern/GHOST_SystemX11.cpp | 6 ++++-- intern/ghost/intern/GHOST_WindowWayland.cpp | 6 ++++-- intern/ghost/intern/GHOST_WindowX11.cpp | 4 +++- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp b/intern/ghost/intern/GHOST_ContextEGL.cpp index 770ead5962e..0fee200ea1a 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.cpp +++ b/intern/ghost/intern/GHOST_ContextEGL.cpp @@ -202,7 +202,8 @@ template T &choose_api(EGLenum api, T &a, T &b, T &c) } } -GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual, +GHOST_ContextEGL::GHOST_ContextEGL(const GHOST_System *const system, + bool stereoVisual, EGLNativeWindowType nativeWindow, EGLNativeDisplayType nativeDisplay, EGLint contextProfileMask, @@ -212,6 +213,7 @@ GHOST_ContextEGL::GHOST_ContextEGL(bool stereoVisual, EGLint contextResetNotificationStrategy, EGLenum api) : GHOST_Context(stereoVisual), + m_system(system), m_nativeDisplay(nativeDisplay), m_nativeWindow(nativeWindow), m_contextProfileMask(contextProfileMask), diff --git a/intern/ghost/intern/GHOST_ContextEGL.h b/intern/ghost/intern/GHOST_ContextEGL.h index 170647177c2..00c8e33ebdf 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.h +++ b/intern/ghost/intern/GHOST_ContextEGL.h @@ -24,6 +24,7 @@ #pragma once #include "GHOST_Context.h" +#include "GHOST_System.h" #include @@ -43,7 +44,8 @@ class GHOST_ContextEGL : public GHOST_Context { /** * Constructor. */ - GHOST_ContextEGL(bool stereoVisual, + GHOST_ContextEGL(const GHOST_System *const system, + bool stereoVisual, EGLNativeWindowType nativeWindow, EGLNativeDisplayType nativeDisplay, EGLint contextProfileMask, @@ -112,6 +114,8 @@ class GHOST_ContextEGL : public GHOST_Context { private: bool initContextEGLEW(); + const GHOST_System *const m_system; + EGLNativeDisplayType m_nativeDisplay; EGLNativeWindowType m_nativeWindow; diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 16a6c93417e..f54a022f249 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -1593,7 +1593,8 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*g GHOST_Context *context; for (int minor = 6; minor >= 0; --minor) { - context = new GHOST_ContextEGL(false, + context = new GHOST_ContextEGL(this, + false, EGLNativeWindowType(os_egl_window), EGLNativeDisplayType(d->display), EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, @@ -1609,7 +1610,8 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GLSettings /*g delete context; } - context = new GHOST_ContextEGL(false, + context = new GHOST_ContextEGL(this, + false, EGLNativeWindowType(os_egl_window), EGLNativeDisplayType(d->display), EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index ee312e2fc40..2a1dd890ac2 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -441,7 +441,8 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti for (int minor = 5; minor >= 0; --minor) { #if defined(WITH_GL_EGL) - context = new GHOST_ContextEGL(false, + context = new GHOST_ContextEGL(this, + false, EGLNativeWindowType(nullptr), EGLNativeDisplayType(m_display), profile_mask, @@ -471,7 +472,8 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSetti } #if defined(WITH_GL_EGL) - context = new GHOST_ContextEGL(false, + context = new GHOST_ContextEGL(this, + false, EGLNativeWindowType(nullptr), EGLNativeDisplayType(m_display), profile_mask, diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp index 1b9c29fc2c9..5be7724fd86 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cpp +++ b/intern/ghost/intern/GHOST_WindowWayland.cpp @@ -533,7 +533,8 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType break; case GHOST_kDrawingContextTypeOpenGL: for (int minor = 6; minor >= 0; --minor) { - context = new GHOST_ContextEGL(m_wantStereoVisual, + context = new GHOST_ContextEGL(this->m_system, + m_wantStereoVisual, EGLNativeWindowType(w->egl_window), EGLNativeDisplayType(m_system->display()), EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, @@ -548,7 +549,8 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType else delete context; } - context = new GHOST_ContextEGL(m_wantStereoVisual, + context = new GHOST_ContextEGL(this->m_system, + m_wantStereoVisual, EGLNativeWindowType(w->egl_window), EGLNativeDisplayType(m_system->display()), EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index fc006c62803..10ef57c3a0a 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -1325,6 +1325,7 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type for (int minor = 5; minor >= 0; --minor) { #ifdef WITH_GL_EGL context = new GHOST_ContextEGL( + this->m_system, m_wantStereoVisual, EGLNativeWindowType(m_window), EGLNativeDisplayType(m_display), @@ -1355,7 +1356,8 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type } #ifdef WITH_GL_EGL - context = new GHOST_ContextEGL(m_wantStereoVisual, + context = new GHOST_ContextEGL(this->m_system, + m_wantStereoVisual, EGLNativeWindowType(m_window), EGLNativeDisplayType(m_display), profile_mask, -- cgit v1.2.3