vcl/inc/opengl/zone.hxx | 34 ++++++++++++++++++++++ vcl/opengl/gdiimpl.cxx | 42 ++++++++++++++++++++++++++++ vcl/opengl/salbmp.cxx | 15 ++++++++++ vcl/opengl/scale.cxx | 3 ++ vcl/source/app/svmain.cxx | 6 ++++ vcl/source/opengl/OpenGLContext.cxx | 54 ++++++++++++++++++++++++++++++++++++ vcl/source/opengl/OpenGLHelper.cxx | 48 ++++++++++++++++++++++++++++++++ 7 files changed, 202 insertions(+)
New commits: commit bf8a43a9037d65f38db6115d4d8133499f86cebe Author: Michael Meeks <michael.me...@collabora.com> Date: Thu Aug 20 17:03:30 2015 +0100 tdf#93547 - Disable OpenGL if we have a SEGV on windows in that code. Annotate when we are in an OpenGL rendering zone. Check for this in the VCL signal handler, and force OpenGL off here if exception occurred inside an OpenGL code-path. Reviewed-on: https://gerrit.libreoffice.org/17881 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Michael Meeks <michael.me...@collabora.com> Conflicts: vcl/source/opengl/OpenGLHelper.cxx Change-Id: I85a4b3d4a374593dc55d01a39ec4c7c3c262c332 Reviewed-on: https://gerrit.libreoffice.org/17883 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tor Lillqvist <t...@collabora.com> Tested-by: Tor Lillqvist <t...@collabora.com> diff --git a/vcl/inc/opengl/zone.hxx b/vcl/inc/opengl/zone.hxx new file mode 100644 index 0000000..c251c4f --- /dev/null +++ b/vcl/inc/opengl/zone.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_OPENGL_GUARD_H +#define INCLUDED_VCL_INC_OPENGL_GUARD_H + +#include <sal/config.h> + +/** + * We want to be able to detect if a given crash came + * from the OpenGL code, so use this helper to track that. + */ +class OpenGLSalGraphicsImpl; +class OpenGLZone { + static int gnInOpenGLZone; + friend class OpenGLSalGraphicsImpl; + static void enter() { gnInOpenGLZone++; } + static void leave() { gnInOpenGLZone--; } +public: + OpenGLZone() { enter(); } + ~OpenGLZone() { leave(); } + static bool isInZone() { return gnInOpenGLZone > 0; } + static void hardDisable(); +}; + +#endif // INCLUDED_VCL_INC_OPENGL_PROGRAM_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index db2ea85..e6c595b 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -32,6 +32,7 @@ #include <vcl/opengl/OpenGLHelper.hxx> #include "salgdi.hxx" #include "svdata.hxx" +#include "opengl/zone.hxx" #include "opengl/salbmp.hxx" #include <vector> @@ -150,6 +151,8 @@ void OpenGLSalGraphicsImpl::Init() void OpenGLSalGraphicsImpl::PreDraw() { + OpenGLZone::enter(); + if( !AcquireContext() ) { SAL_WARN( "vcl.opengl", "Couldn't acquire context" ); @@ -189,6 +192,7 @@ void OpenGLSalGraphicsImpl::PostDraw() } CHECK_GL_ERROR(); + OpenGLZone::leave(); } void OpenGLSalGraphicsImpl::ApplyProgramMatrices(float fPixelOffset) @@ -445,6 +449,8 @@ bool OpenGLSalGraphicsImpl::UseSolidAA( SalColor nColor ) bool OpenGLSalGraphicsImpl::UseInvert() { + OpenGLZone aZone; + if( !UseSolid( MAKE_SALCOLOR( 255, 255, 255 ) ) ) return false; mpProgram->SetBlendMode( GL_ONE_MINUS_DST_COLOR, GL_ZERO ); @@ -453,6 +459,8 @@ bool OpenGLSalGraphicsImpl::UseInvert() void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY ) { + OpenGLZone aZone; + GLfloat pPoint[2]; pPoint[0] = GLfloat(nX); @@ -467,6 +475,8 @@ void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY ) void OpenGLSalGraphicsImpl::DrawLine( double nX1, double nY1, double nX2, double nY2 ) { + OpenGLZone aZone; + GLfloat pPoints[4]; pPoints[0] = GLfloat(nX1); @@ -483,6 +493,8 @@ void OpenGLSalGraphicsImpl::DrawLine( double nX1, double nY1, double nX2, double void OpenGLSalGraphicsImpl::DrawLineAA( double nX1, double nY1, double nX2, double nY2 ) { + OpenGLZone aZone; + if( !mrParent.getAntiAliasB2DDraw()) return DrawLine( nX1, nY1, nX2, nY2 ); @@ -665,6 +677,8 @@ void OpenGLSalGraphicsImpl::DrawEdgeAA( double nX1, double nY1, double nX2, doub void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry, bool blockAA ) { + OpenGLZone aZone; + std::vector<GLfloat> aVertices(nPoints * 2); sal_uInt32 i, j; @@ -706,6 +720,8 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin void OpenGLSalGraphicsImpl::DrawConvexPolygon( const Polygon& rPolygon, bool blockAA ) { + OpenGLZone aZone; + sal_uInt16 nPoints = rPolygon.GetSize() - 1; std::vector<GLfloat> aVertices(nPoints * 2); sal_uInt32 i, j; @@ -749,6 +765,8 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const Polygon& rPolygon, bool blo void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoid, bool blockAA ) { + OpenGLZone aZone; + const basegfx::B2DPolygon& rPolygon = trapezoid.getB2DPolygon(); sal_uInt16 nPoints = rPolygon.count(); std::vector<GLfloat> aVertices(nPoints * 2); @@ -850,6 +868,8 @@ void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPol void OpenGLSalGraphicsImpl::DrawRegionBand( const RegionBand& rRegion ) { + OpenGLZone aZone; + RectangleVector aRects; std::vector<GLfloat> aVertices; rRegion.GetRegionRectangles( aRects ); @@ -883,6 +903,8 @@ void OpenGLSalGraphicsImpl::DrawRegionBand( const RegionBand& rRegion ) void OpenGLSalGraphicsImpl::DrawTextureRect( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted ) { + OpenGLZone aZone; + GLfloat aTexCoord[8]; rTexture.GetCoord( aTexCoord, rPosAry, bInverted ); mpProgram->SetTextureCoord( aTexCoord ); @@ -891,6 +913,8 @@ void OpenGLSalGraphicsImpl::DrawTextureRect( OpenGLTexture& rTexture, const SalT void OpenGLSalGraphicsImpl::DrawTexture( OpenGLTexture& rTexture, const SalTwoRect& pPosAry, bool bInverted ) { + OpenGLZone aZone; + if( !UseProgram( "textureVertexShader", "textureFragmentShader" ) ) return; mpProgram->SetTexture( "sampler", rTexture ); @@ -905,6 +929,8 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture( const basegfx::B2DPoint& rX, const basegfx::B2DPoint& rY ) { + OpenGLZone aZone; + GLfloat aVertices[8] = { 0, (float) rTexture.GetHeight(), 0, 0, (float) rTexture.GetWidth(), 0, (float) rTexture.GetWidth(), (float) rTexture.GetHeight() }; @@ -993,6 +1019,8 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture( void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted, bool bPremultiplied ) { + OpenGLZone aZone; + if( !UseProgram( "textureVertexShader", "textureFragmentShader" ) ) return; mpProgram->SetTexture( "sampler", rTexture ); @@ -1004,6 +1032,8 @@ void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const Sal void OpenGLSalGraphicsImpl::DrawTextureDiff( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& rPosAry, bool bInverted ) { + OpenGLZone aZone; + if( !UseProgram( "textureVertexShader", "diffTextureFragmentShader" ) ) return; mpProgram->SetTexture( "texture", rTexture ); @@ -1015,6 +1045,8 @@ void OpenGLSalGraphicsImpl::DrawTextureDiff( OpenGLTexture& rTexture, OpenGLText void OpenGLSalGraphicsImpl::DrawTextureWithMask( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& pPosAry ) { + OpenGLZone aZone; + if( !UseProgram( "textureVertexShader", "maskedTextureFragmentShader" ) ) return; mpProgram->SetTexture( "sampler", rTexture ); @@ -1026,6 +1058,8 @@ void OpenGLSalGraphicsImpl::DrawTextureWithMask( OpenGLTexture& rTexture, OpenGL void OpenGLSalGraphicsImpl::DrawBlendedTexture( OpenGLTexture& rTexture, OpenGLTexture& rMask, OpenGLTexture& rAlpha, const SalTwoRect& rPosAry ) { + OpenGLZone aZone; + GLfloat aTexCoord[8]; if( !UseProgram( "blendedTextureVertexShader", "blendedTextureFragmentShader" ) ) return; @@ -1041,6 +1075,8 @@ void OpenGLSalGraphicsImpl::DrawBlendedTexture( OpenGLTexture& rTexture, OpenGLT void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor, const SalTwoRect& pPosAry ) { + OpenGLZone aZone; + if( !UseProgram( "textureVertexShader", "maskFragmentShader" ) ) return; mpProgram->SetColor( "color", nMaskColor, 0 ); @@ -1052,6 +1088,8 @@ void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor, void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect ) { + OpenGLZone aZone; + if( !UseProgram( "textureVertexShader", "linearGradientFragmentShader" ) ) return; Color aStartCol = rGradient.GetStartColor(); @@ -1076,6 +1114,8 @@ void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const void OpenGLSalGraphicsImpl::DrawAxialGradient( const Gradient& rGradient, const Rectangle& rRect ) { + OpenGLZone aZone; + if( !UseProgram( "textureVertexShader", "linearGradientFragmentShader" ) ) return; Color aStartCol = rGradient.GetStartColor(); @@ -1126,6 +1166,8 @@ void OpenGLSalGraphicsImpl::DrawAxialGradient( const Gradient& rGradient, const void OpenGLSalGraphicsImpl::DrawRadialGradient( const Gradient& rGradient, const Rectangle& rRect ) { + OpenGLZone aZone; + if( !UseProgram( "textureVertexShader", "radialGradientFragmentShader" ) ) return; Color aStartCol = rGradient.GetStartColor(); diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx index 7b7f674..30bbdb2 100644 --- a/vcl/opengl/salbmp.cxx +++ b/vcl/opengl/salbmp.cxx @@ -27,6 +27,7 @@ #include "svdata.hxx" #include "salgdi.hxx" +#include "opengl/zone.hxx" #include "opengl/program.hxx" #include "opengl/salbmp.hxx" @@ -56,6 +57,7 @@ OpenGLSalBitmap::~OpenGLSalBitmap() bool OpenGLSalBitmap::Create( const OpenGLTexture& rTex, long nX, long nY, long nWidth, long nHeight ) { static const BitmapPalette aEmptyPalette; + OpenGLZone aZone; Destroy(); SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO: [" << nX << ", " << nY << "] " << nWidth << "x" << nHeight ); @@ -81,6 +83,8 @@ bool OpenGLSalBitmap::Create( const OpenGLTexture& rTex, long nX, long nY, long bool OpenGLSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapPalette& rBitmapPalette ) { + OpenGLZone aZone; + Destroy(); SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create with size: " << rSize ); @@ -105,6 +109,8 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ) { + OpenGLZone aZone; + // check that carefully only in the debug mode assert(dynamic_cast<const OpenGLSalBitmap*>(&rSalBmp)); @@ -152,6 +158,8 @@ OpenGLTexture& OpenGLSalBitmap::GetTexture() const void OpenGLSalBitmap::Destroy() { + OpenGLZone aZone; + SAL_INFO( "vcl.opengl", "Destroy OpenGLSalBitmap" ); maPendingOps.clear(); maTexture = OpenGLTexture(); @@ -310,6 +318,8 @@ ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalet Size OpenGLSalBitmap::GetSize() const { + OpenGLZone aZone; + std::deque< OpenGLSalBitmapOp* >::const_iterator it = maPendingOps.begin(); Size aSize( mnWidth, mnHeight ); @@ -484,6 +494,7 @@ void OpenGLSalBitmap::makeCurrent() BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode ) { + OpenGLZone aZone; if( nMode != BITMAP_INFO_ACCESS ) { @@ -529,6 +540,8 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode ) void OpenGLSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) { + OpenGLZone aZone; + if( nMode == BITMAP_WRITE_ACCESS ) { maTexture = OpenGLTexture(); @@ -591,6 +604,8 @@ bool OpenGLSalBitmap::Erase( const ::Color& /*rFillColor*/ ) bool OpenGLSalBitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) { + OpenGLZone aZone; + OpenGLFramebuffer* pFramebuffer; OpenGLProgram* pProgram; diff --git a/vcl/opengl/scale.cxx b/vcl/opengl/scale.cxx index fcb4273..6d9a4d1 100644 --- a/vcl/opengl/scale.cxx +++ b/vcl/opengl/scale.cxx @@ -23,6 +23,7 @@ #include "vcl/bitmap.hxx" +#include "opengl/zone.hxx" #include "opengl/bmpop.hxx" #include "opengl/salbmp.hxx" #include "opengl/program.hxx" @@ -365,6 +366,8 @@ void ScaleOp::GetSize( Size& rSize ) const bool OpenGLSalBitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) { + OpenGLZone aZone; + SAL_INFO("vcl.opengl", "::Scale " << int(nScaleFlag) << " from " << mnWidth << "x" << mnHeight << " to " << (mnWidth * rScaleX) << "x" << (mnHeight * rScaleY) ); diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx index fce2961..4c3ef9a 100644 --- a/vcl/source/app/svmain.cxx +++ b/vcl/source/app/svmain.cxx @@ -81,6 +81,8 @@ #include "cppuhelper/implbase1.hxx" #include "uno/current_context.hxx" +#include "opengl/zone.hxx" + #if OSL_DEBUG_LEVEL > 0 #include <typeinfo> #include "rtl/strbuf.hxx" @@ -102,7 +104,11 @@ oslSignalAction SAL_CALL VCLExceptionSignal_impl( void* /*pData*/, oslSignalInfo (pInfo->Signal == osl_Signal_IntegerDivideByZero) || (pInfo->Signal == osl_Signal_FloatDivideByZero) || (pInfo->Signal == osl_Signal_DebugBreak) ) + { nVCLException = EXC_SYSTEM; + if (OpenGLZone::isInZone()) + OpenGLZone::hardDisable(); + } // RC if ((pInfo->Signal == osl_Signal_User) && diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 9beed93..e76002c 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -33,6 +33,7 @@ #include <opengl/framebuffer.hxx> #include <opengl/program.hxx> #include <opengl/texture.hxx> +#include <opengl/zone.hxx> using namespace com::sun::star; @@ -70,6 +71,7 @@ OpenGLContext::OpenGLContext(): mpNextContext(NULL) { SAL_INFO("vcl.opengl", "new context: " << this); + #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS) mbPixmap = false; #endif @@ -185,6 +187,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l int InitTempWindow(HWND *hwnd, int width, int height, const PIXELFORMATDESCRIPTOR& inPfd, GLWindow& glWin) { + OpenGLZone aZone; + PIXELFORMATDESCRIPTOR pfd = inPfd; int pfmt; int ret; @@ -228,6 +232,8 @@ int InitTempWindow(HWND *hwnd, int width, int height, const PIXELFORMATDESCRIPTO bool WGLisExtensionSupported(const char *extension) { + OpenGLZone aZone; + const size_t extlen = strlen(extension); const char *supported = NULL; @@ -266,6 +272,8 @@ bool WGLisExtensionSupported(const char *extension) bool InitMultisample(const PIXELFORMATDESCRIPTOR& pfd, int& rPixelFormat, bool bUseDoubleBufferedRendering, bool bRequestVirtualDevice) { + OpenGLZone aZone; + HWND hWnd = NULL; GLWindow glWin; //create a temp windwo to check whether support multi-sample, if support, get the format @@ -558,6 +566,8 @@ GLXFBConfig* getFBConfigForPixmap(Display* dpy, int& nBestFBC, bool bUseDoubleBu GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC, bool bUseDoubleBufferedRendering, bool bWithSameVisualID) { + OpenGLZone aZone; + if( dpy == 0 || !glXQueryExtension( dpy, NULL, NULL ) ) return NULL; @@ -638,6 +648,8 @@ void initOpenGLFunctionPointers() Visual* getVisual(Display* dpy, Window win) { + OpenGLZone aZone; + initOpenGLFunctionPointers(); XWindowAttributes xattr; @@ -659,6 +671,8 @@ bool OpenGLContext::init( vcl::Window* pParent ) if(mbInitialized) return true; + OpenGLZone aZone; + m_xWindow.reset(pParent ? nullptr : VclPtr<vcl::Window>::Create(nullptr, WB_NOBORDER|WB_NODIALOGCONTROL)); mpWindow = pParent ? pParent : m_xWindow.get(); if(m_xWindow) @@ -676,6 +690,8 @@ bool OpenGLContext::init(SystemChildWindow* pChildWindow) if( !pChildWindow ) return false; + OpenGLZone aZone; + mpWindow = pChildWindow->GetParent(); m_pChildWindow = pChildWindow; initWindow(); @@ -691,6 +707,8 @@ bool OpenGLContext::init(Display* dpy, Window win, int screen) if (!dpy) return false; + OpenGLZone aZone; + m_aGLWin.dpy = dpy; m_aGLWin.win = win; m_aGLWin.screen = screen; @@ -740,6 +758,8 @@ bool OpenGLContext::ImplInit() return false; } + OpenGLZone aZone; + GLXContext pSharedCtx( NULL ); #ifdef DBG_UTIL TempErrorHandler aErrorHandler(m_aGLWin.dpy, unxErrorHandler); @@ -866,6 +886,8 @@ bool OpenGLContext::init(HDC hDC, HWND hWnd) bool OpenGLContext::ImplInit() { + OpenGLZone aZone; + SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start"); // PixelFormat tells Windows how we want things to be PIXELFORMATDESCRIPTOR PixelFormatFront = @@ -988,6 +1010,8 @@ bool OpenGLContext::ImplInit() bool OpenGLContext::ImplInit() { + OpenGLZone aZone; + SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start"); NSOpenGLView* pView = getOpenGLView(); OpenGLWrapper::makeCurrent(pView); @@ -1010,6 +1034,8 @@ bool OpenGLContext::InitGLEW() static bool bGlewInit = false; if(!bGlewInit) { + OpenGLZone aZone; + glewExperimental = GL_TRUE; GLenum err = glewInit(); if (err != GLEW_OK) @@ -1025,6 +1051,8 @@ bool OpenGLContext::InitGLEW() // only enable debug output in dbgutil build if( GLEW_ARB_debug_output) { + OpenGLZone aZone; + if (glDebugMessageCallbackARB) { glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); @@ -1169,6 +1197,8 @@ bool OpenGLContext::initWindow() void OpenGLContext::initGLWindow(Visual* pVisual) { + OpenGLZone aZone; + // Get visual info { XVisualInfo aTemplate; @@ -1199,6 +1229,8 @@ void OpenGLContext::reset() if( !mbInitialized ) return; + OpenGLZone aZone; + // reset the clip region maClipRegion.SetEmpty(); @@ -1285,6 +1317,8 @@ SystemWindowData OpenGLContext::generateWinData(vcl::Window* /*pParent*/, bool b SystemWindowData OpenGLContext::generateWinData(vcl::Window* pParent, bool) { + OpenGLZone aZone; + SystemWindowData aWinData; aWinData.nSize = sizeof(aWinData); aWinData.pVisual = NULL; @@ -1326,6 +1360,8 @@ SystemWindowData OpenGLContext::generateWinData(vcl::Window* pParent, bool) bool OpenGLContext::isCurrent() { + OpenGLZone aZone; + #if defined( WNT ) return (wglGetCurrentContext() == m_aGLWin.hRC && wglGetCurrentDC() == m_aGLWin.hDC); @@ -1359,6 +1395,8 @@ void OpenGLContext::makeCurrent() if (isCurrent()) return; + OpenGLZone aZone; + clearCurrent(); #if defined( WNT ) @@ -1407,6 +1445,8 @@ void OpenGLContext::resetCurrent() { clearCurrent(); + OpenGLZone aZone; + #if defined( WNT ) wglMakeCurrent( m_aGLWin.hDC, 0 ); #elif defined( MACOSX ) @@ -1421,6 +1461,8 @@ void OpenGLContext::resetCurrent() void OpenGLContext::swapBuffers() { + OpenGLZone aZone; + #if defined( WNT ) SwapBuffers(m_aGLWin.hDC); #elif defined( MACOSX ) @@ -1435,6 +1477,8 @@ void OpenGLContext::swapBuffers() void OpenGLContext::sync() { + OpenGLZone aZone; + #if defined( WNT ) // nothing #elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID ) || defined(LIBO_HEADLESS) @@ -1478,6 +1522,8 @@ NSOpenGLView* OpenGLContext::getOpenGLView() bool OpenGLContext::BindFramebuffer( OpenGLFramebuffer* pFramebuffer ) { + OpenGLZone aZone; + if( pFramebuffer != mpCurrentFramebuffer ) { if( pFramebuffer ) @@ -1497,6 +1543,8 @@ bool OpenGLContext::AcquireDefaultFramebuffer() OpenGLFramebuffer* OpenGLContext::AcquireFramebuffer( const OpenGLTexture& rTexture ) { + OpenGLZone aZone; + OpenGLFramebuffer* pFramebuffer = NULL; OpenGLFramebuffer* pFreeFbo = NULL; OpenGLFramebuffer* pSameSizeFbo = NULL; @@ -1563,6 +1611,7 @@ void OpenGLContext::ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer ) void OpenGLContext::ReleaseFramebuffer( const OpenGLTexture& rTexture ) { + OpenGLZone aZone; OpenGLFramebuffer* pFramebuffer = mpLastFramebuffer; while( pFramebuffer ) @@ -1578,6 +1627,7 @@ void OpenGLContext::ReleaseFramebuffer( const OpenGLTexture& rTexture ) void OpenGLContext::ReleaseFramebuffers() { + OpenGLZone aZone; OpenGLFramebuffer* pFramebuffer = mpLastFramebuffer; while( pFramebuffer ) { @@ -1589,6 +1639,8 @@ void OpenGLContext::ReleaseFramebuffers() OpenGLProgram* OpenGLContext::GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble ) { + OpenGLZone aZone; + ProgramKey aKey( rVertexShader, rFragmentShader, preamble ); std::map< ProgramKey, boost::shared_ptr<OpenGLProgram> >::iterator @@ -1606,6 +1658,8 @@ OpenGLProgram* OpenGLContext::GetProgram( const OUString& rVertexShader, const O OpenGLProgram* OpenGLContext::UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble ) { + OpenGLZone aZone; + OpenGLProgram* pProgram = GetProgram( rVertexShader, rFragmentShader, preamble ); if( pProgram == mpCurrentProgram ) diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index 41881da..967d4c5 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -20,9 +20,13 @@ #include <vcl/graph.hxx> #include <vcl/svapp.hxx> #include <officecfg/Office/Common.hxx> +#include <com/sun/star/util/XFlushable.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <vector> +#include "opengl/zone.hxx" + #if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID #include "opengl/x11/X11DeviceInfo.hxx" #elif defined (_WIN32) @@ -68,6 +72,8 @@ namespace { int LogCompilerError(GLuint nId, const rtl::OUString &rDetail, const rtl::OUString &rName, bool bShaderNotProgram) { + OpenGLZone aZone; + int InfoLogLength = 0; CHECK_GL_ERROR(); @@ -127,6 +133,8 @@ static void addPreamble(OString& rShaderSource, const OString& rPreamble) GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString& rFragmentShaderName, const OString& preamble) { + OpenGLZone aZone; + // Create the shaders GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER); GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER); @@ -205,6 +213,8 @@ void OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, void OpenGLHelper::renderToFile(long nWidth, long nHeight, const OUString& rFileName) { + OpenGLZone aZone; + boost::scoped_array<sal_uInt8> pBuffer(new sal_uInt8[nWidth*nHeight*4]); glReadPixels(0, 0, nWidth, nHeight, GL_BGRA, GL_UNSIGNED_BYTE, pBuffer.get()); BitmapEx aBitmap = ConvertBGRABufferToBitmapEx(pBuffer.get(), nWidth, nHeight); @@ -312,6 +322,8 @@ std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix) void OpenGLHelper::createFramebuffer(long nWidth, long nHeight, GLuint& nFramebufferId, GLuint& nRenderbufferDepthId, GLuint& nRenderbufferColorId, bool bRenderbuffer) { + OpenGLZone aZone; + // create a renderbuffer for depth attachment glGenRenderbuffers(1, &nRenderbufferDepthId); glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferDepthId); @@ -383,6 +395,8 @@ float OpenGLHelper::getGLVersion() void OpenGLHelper::checkGLError(const char* pFile, size_t nLine) { + OpenGLZone aZone; + GLenum glErr = glGetError(); if (glErr != GL_NO_ERROR) { @@ -403,6 +417,8 @@ bool OpenGLHelper::isDeviceBlacklisted() static bool bBlacklisted = true; // assume the worst if (!bSet) { + OpenGLZone aZone; + #if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID X11OpenGLDeviceInfo aInfo; bBlacklisted = aInfo.isDeviceBlocked(); @@ -430,6 +446,34 @@ bool OpenGLHelper::supportsVCLOpenGL() return true; } +/// How many nested OpenGL code-paths are we inside ? +int OpenGLZone::gnInOpenGLZone = 0; + +/** + * Called from a signal handler if we get a crash in some GL code + */ +void OpenGLZone::hardDisable() +{ + // protect ourselves from double calling etc. + static bool bDisabled = false; + if (!bDisabled) + { + bDisabled = true; + + // Disable the OpenGL support + std::shared_ptr<comphelper::ConfigurationChanges> xChanges( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::VCL::UseOpenGL::set(false, xChanges); + xChanges->commit(); + + // Force synchronous config write + css::uno::Reference< css::util::XFlushable >( + css::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext()), + css::uno::UNO_QUERY_THROW)->flush(); + } +} + bool OpenGLHelper::isVCLOpenGLEnabled() { /** @@ -483,6 +527,8 @@ bool OpenGLHelper::isVCLOpenGLEnabled() bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rVI) { + OpenGLZone aZone; + XVisualInfo* pVI; int aAttrib[] = { GLX_RGBA, GLX_RED_SIZE, 8, @@ -505,6 +551,8 @@ bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rV GLXFBConfig OpenGLHelper::GetPixmapFBConfig( Display* pDisplay, bool& bInverted ) { + OpenGLZone aZone; + int nScreen = DefaultScreen( pDisplay ); GLXFBConfig *aFbConfigs; int i, nFbConfigs, nValue; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits