19#include <osl/thread.hxx>
28#include <config_features.h>
45 m_pChildWindow(nullptr),
48 mbRequestLegacyContext(false),
49 mpPrevContext(nullptr),
50 mpNextContext(nullptr)
108const char* getSeverityString(GLenum severity)
112 case GL_DEBUG_SEVERITY_LOW:
114 case GL_DEBUG_SEVERITY_MEDIUM:
116 case GL_DEBUG_SEVERITY_HIGH:
125const char* getSourceString(GLenum source)
129 case GL_DEBUG_SOURCE_API:
131 case GL_DEBUG_SOURCE_SHADER_COMPILER:
132 return "shader compiler";
133 case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
134 return "window system";
135 case GL_DEBUG_SOURCE_THIRD_PARTY:
136 return "third party";
137 case GL_DEBUG_SOURCE_APPLICATION:
138 return "Libreoffice";
139 case GL_DEBUG_SOURCE_OTHER:
148const char* getTypeString(GLenum type)
152 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
153 return "deprecated behavior";
154 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
155 return "undefined behavior";
156 case GL_DEBUG_TYPE_PERFORMANCE:
157 return "performance";
158 case GL_DEBUG_TYPE_PORTABILITY:
159 return "portability";
160 case GL_DEBUG_TYPE_MARKER:
162 case GL_DEBUG_TYPE_PUSH_GROUP:
164 case GL_DEBUG_TYPE_POP_GROUP:
166 case GL_DEBUG_TYPE_OTHER:
168 case GL_DEBUG_TYPE_ERROR:
181debug_callback(GLenum source, GLenum type, GLuint
id,
182 GLenum severity, GLsizei ,
const GLchar* message,
190 if (
id == 131218 ||
id == 131185)
193 SAL_WARN(
"vcl.opengl",
"OpenGL debug message: source: " << getSourceString(source) <<
", type: "
194 << getTypeString(type) <<
", id: " <<
id <<
", severity: " << getSeverityString(severity) <<
", with message: " << message);
220 VCL_GL_INFO(
"OpenGLContext not implemented for this platform");
227 const GLubyte* pString = glGetString(eGlEnum);
230 sString = OUString::createFromAscii(
reinterpret_cast<const char*
>(pString));
244 if (epoxy_gl_version() < 30)
246 SAL_WARN(
"vcl.opengl",
"We don't have at least OpenGL 3.0");
251 if (!glBindFramebuffer)
253 SAL_WARN(
"vcl.opengl",
"We don't have glBindFramebuffer");
264 if (epoxy_has_gl_extension(
"GL_ARB_debug_output"))
268 if (glDebugMessageCallbackARB)
270 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
271 glDebugMessageCallbackARB(&debug_callback,
nullptr);
273#ifdef GL_DEBUG_SEVERITY_NOTIFICATION_ARB
275 glDebugMessageControlARB(GL_DEBUG_SOURCE_SHADER_COMPILER_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DEBUG_SEVERITY_NOTIFICATION_ARB, 0,
nullptr,
true);
278 else if ( glDebugMessageCallback )
280 glEnable(GL_DEBUG_OUTPUT);
281 glDebugMessageCallback(&debug_callback,
nullptr);
284 glDebugMessageControl(GL_DEBUG_SOURCE_SHADER_COMPILER, GL_DEBUG_TYPE_OTHER, GL_DEBUG_SEVERITY_NOTIFICATION, 0,
nullptr,
true);
295 glBindFramebuffer(GL_FRAMEBUFFER, 0);
385 return pCurrentCtx.is() && pCurrentCtx->isAnyCurrent();
400 if ( !pCurrentCtx.is() )
403 SAL_INFO(
"vcl.opengl",
"Unbinding contexts in preparation for yield");
408 while (pCurrentCtx.is())
410 if (pCurrentCtx->isCurrent())
412 pCurrentCtx->resetCurrent();
416 pCurrentCtx = pCurrentCtx->mpPrevContext;
427 static int nSwitch = 0;
428 VCL_GL_INFO(
"******* CONTEXT SWITCH " << ++nSwitch <<
" *********");
458 static bool bSleep = getenv(
"SAL_GL_SLEEP_ON_SWAP");
462 std::this_thread::sleep_for(std::chrono::milliseconds(500) );
467sal_Int64 OpenGLWrapper::getBufferSwapCounter()
static OUString getGLString(GLenum eGlEnum)
static sal_Int64 nBufferSwapCounter
#define VCL_GL_INFO(stream)
Helper to do a SAL_INFO as well as a GL log.
virtual const GLWindow & getOpenGLWindow() const =0
virtual void makeCurrent()
make this GL context current - so it is implicit in subsequent GL calls
VclPtr< SystemChildWindow > m_pChildWindow
virtual void destroyCurrentContext()
OpenGLContext * mpPrevContext
virtual void adjustToNewSize()
static void BuffersSwapped()
virtual void restoreDefaultFramebuffer()
unbind the GL_FRAMEBUFFER to its default state, needed for gtk3
bool init(vcl::Window *pParent)
VclPtr< vcl::Window > m_xWindow
virtual SystemWindowData generateWinData(vcl::Window *pParent, bool bRequestLegacyContext)
bool mbRequestLegacyContext
virtual void initWindow()
virtual bool isAnyCurrent()
Is any GL context the current context ?
VclPtr< vcl::Window > mpWindow
virtual void swapBuffers()
static rtl::Reference< OpenGLContext > Create()
static void InitChildWindow(SystemChildWindow *pChildWindow)
virtual void resetCurrent()
reset the GL context so this context is not implicit in subsequent GL calls.
static void InitGLDebugging()
static void prepareForYield()
release contexts etc. before (potentially) allowing another thread run.
void requestLegacyContext()
virtual GLWindow & getModifiableOpenGLWindow()=0
void setWinPosAndSize(const Point &rPos, const Size &rSize)
static bool hasCurrent()
Is there a current GL context ?
virtual bool isCurrent()
Is this GL context the current context ?
void registerAsCurrent()
Put this GL context to the end of the context list.
SystemChildWindow * getChildWindow()
OpenGLContext * mpNextContext
static void clearCurrent()
release bound resources from the current context
We want to be able to detect if a given crash came from the OpenGL code, so use this helper to track ...
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void EnableEraseBackground(bool bEnable)
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
void reset(reference_type *pBody)
reference_type * get() const
Get the body.
void SetControlForeground()
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
void SetControlBackground()
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
void SetMouseTransparent(bool bTransparent)
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
Holds the information of our new child window.
virtual bool Synchronize(bool bOnoff) const
OpenGLContext * mpLastContext
static float getGLVersion()
Get OpenGL version (needs a context)
ImplSVData * ImplGetSVData()
WinBits const WB_NODIALOGCONTROL
WinBits const WB_NOBORDER
VclPtr< vcl::Window > mpWindow