18 #include <osl/thread.hxx>
27 #include <config_features.h>
44 m_pChildWindow(nullptr),
47 mbRequestLegacyContext(
false),
48 mpPrevContext(nullptr),
49 mpNextContext(nullptr)
107 const char* getSeverityString(GLenum severity)
111 case GL_DEBUG_SEVERITY_LOW:
113 case GL_DEBUG_SEVERITY_MEDIUM:
115 case GL_DEBUG_SEVERITY_HIGH:
124 const char* getSourceString(GLenum source)
128 case GL_DEBUG_SOURCE_API:
130 case GL_DEBUG_SOURCE_SHADER_COMPILER:
131 return "shader compiler";
132 case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
133 return "window system";
134 case GL_DEBUG_SOURCE_THIRD_PARTY:
135 return "third party";
136 case GL_DEBUG_SOURCE_APPLICATION:
137 return "Libreoffice";
138 case GL_DEBUG_SOURCE_OTHER:
147 const char* getTypeString(GLenum type)
151 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
152 return "deprecated behavior";
153 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
154 return "undefined behavior";
155 case GL_DEBUG_TYPE_PERFORMANCE:
156 return "performance";
157 case GL_DEBUG_TYPE_PORTABILITY:
158 return "portability";
159 case GL_DEBUG_TYPE_MARKER:
161 case GL_DEBUG_TYPE_PUSH_GROUP:
163 case GL_DEBUG_TYPE_POP_GROUP:
165 case GL_DEBUG_TYPE_OTHER:
167 case GL_DEBUG_TYPE_ERROR:
180 debug_callback(GLenum source, GLenum type, GLuint
id,
181 GLenum severity, GLsizei ,
const GLchar* message,
189 if (
id == 131218 ||
id == 131185)
192 SAL_WARN(
"vcl.opengl",
"OpenGL debug message: source: " << getSourceString(source) <<
", type: "
193 << getTypeString(type) <<
", id: " <<
id <<
", severity: " << getSeverityString(severity) <<
", with message: " << message);
219 VCL_GL_INFO(
"OpenGLContext not implemented for this platform");
226 const GLubyte* pString = glGetString(eGlEnum);
229 sString = OUString::createFromAscii(reinterpret_cast<const char*>(pString));
243 if (epoxy_gl_version() < 30)
245 SAL_WARN(
"vcl.opengl",
"We don't have at least OpenGL 3.0");
250 if (!glBindFramebuffer)
252 SAL_WARN(
"vcl.opengl",
"We don't have glBindFramebuffer");
263 if (epoxy_has_gl_extension(
"GL_ARB_debug_output"))
267 if (glDebugMessageCallbackARB)
269 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
270 glDebugMessageCallbackARB(&debug_callback,
nullptr);
272 #ifdef GL_DEBUG_SEVERITY_NOTIFICATION_ARB
274 glDebugMessageControlARB(GL_DEBUG_SOURCE_SHADER_COMPILER_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DEBUG_SEVERITY_NOTIFICATION_ARB, 0,
nullptr,
true);
277 else if ( glDebugMessageCallback )
279 glEnable(GL_DEBUG_OUTPUT);
280 glDebugMessageCallback(&debug_callback,
nullptr);
283 glDebugMessageControl(GL_DEBUG_SOURCE_SHADER_COMPILER, GL_DEBUG_TYPE_OTHER, GL_DEBUG_SEVERITY_NOTIFICATION, 0,
nullptr,
true);
294 glBindFramebuffer(GL_FRAMEBUFFER, 0);
384 return pCurrentCtx.is() && pCurrentCtx->isAnyCurrent();
399 if ( !pCurrentCtx.is() )
402 SAL_INFO(
"vcl.opengl",
"Unbinding contexts in preparation for yield");
407 while (pCurrentCtx.is())
409 if (pCurrentCtx->isCurrent())
411 pCurrentCtx->resetCurrent();
415 pCurrentCtx = pCurrentCtx->mpPrevContext;
426 static int nSwitch = 0;
427 VCL_GL_INFO(
"******* CONTEXT SWITCH " << ++nSwitch <<
" *********");
457 static bool bSleep = getenv(
"SAL_GL_SLEEP_ON_SWAP");
461 osl::Thread::wait( std::chrono::milliseconds(500) );
466 sal_Int64 OpenGLWrapper::getBufferSwapCounter()
static rtl::Reference< OpenGLContext > Create()
static void clearCurrent()
release bound resources from the current context
virtual void restoreDefaultFramebuffer()
unbind the GL_FRAMEBUFFER to its default state, needed for gtk3
void setWinPosAndSize(const Point &rPos, const Size &rSize)
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
WinBits const WB_NODIALOGCONTROL
OpenGLContext * mpNextContext
static void BuffersSwapped()
void registerAsCurrent()
Put this GL context to the end of the context list.
static void InitChildWindow(SystemChildWindow *pChildWindow)
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
static float getGLVersion()
Get OpenGL version (needs a context)
virtual void initWindow()
virtual bool isAnyCurrent()
Is any GL context the current context ?
constexpr tools::Long Width() const
void requestLegacyContext()
static OUString getGLString(GLenum eGlEnum)
virtual OpenGLContext * CreateOpenGLContext()
bool mbRequestLegacyContext
void EnableEraseBackground(bool bEnable)
virtual GLWindow & getModifiableOpenGLWindow()=0
static sal_Int64 nBufferSwapCounter
virtual bool Synchronize(bool bOnoff) const
ImplSVData * ImplGetSVData()
virtual void resetCurrent()
reset the GL context so this context is not implicit in subsequent GL calls.
VclPtr< vcl::Window > mpWindow
Holds the information of our new child window.
#define VCL_GL_INFO(stream)
Helper to do a SAL_INFO as well as a GL log.
static void InitGLDebugging()
void SetControlBackground()
static bool hasCurrent()
Is there a current GL context ?
void SetControlForeground()
virtual void adjustToNewSize()
virtual void swapBuffers()
virtual const GLWindow & getOpenGLWindow() const =0
WinBits const WB_NOBORDER
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
void reset(reference_type *pBody)
We want to be able to detect if a given crash came from the OpenGL code, so use this helper to track ...
virtual void makeCurrent()
make this GL context current - so it is implicit in subsequent GL calls
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
OpenGLContext * mpPrevContext
void SetMouseTransparent(bool bTransparent)
virtual void destroyCurrentContext()
constexpr tools::Long Height() const
#define SAL_INFO(area, stream)
VclPtr< vcl::Window > m_xWindow
SystemChildWindow * getChildWindow()
static void prepareForYield()
release contexts etc. before (potentially) allowing another thread run.
reference_type * get() const
Get the body.
#define SAL_WARN(area, stream)
virtual SystemWindowData generateWinData(vcl::Window *pParent, bool bRequestLegacyContext)
VclPtr< SystemChildWindow > m_pChildWindow
bool init(vcl::Window *pParent)
OpenGLContext * mpLastContext
bool m_bDetectedRangeSegmentation false
virtual bool isCurrent()
Is this GL context the current context ?
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
VclPtr< vcl::Window > mpWindow