Kaydet (Commit) bf8a43a9 authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Tor Lillqvist

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/17881Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>

Conflicts:
	vcl/source/opengl/OpenGLHelper.cxx

Change-Id: I85a4b3d4a374593dc55d01a39ec4c7c3c262c332
Reviewed-on: https://gerrit.libreoffice.org/17883Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTor Lillqvist <tml@collabora.com>
Tested-by: 's avatarTor Lillqvist <tml@collabora.com>
üst a1e77b96
/* -*- 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: */
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <vcl/opengl/OpenGLHelper.hxx> #include <vcl/opengl/OpenGLHelper.hxx>
#include "salgdi.hxx" #include "salgdi.hxx"
#include "svdata.hxx" #include "svdata.hxx"
#include "opengl/zone.hxx"
#include "opengl/salbmp.hxx" #include "opengl/salbmp.hxx"
#include <vector> #include <vector>
...@@ -150,6 +151,8 @@ void OpenGLSalGraphicsImpl::Init() ...@@ -150,6 +151,8 @@ void OpenGLSalGraphicsImpl::Init()
void OpenGLSalGraphicsImpl::PreDraw() void OpenGLSalGraphicsImpl::PreDraw()
{ {
OpenGLZone::enter();
if( !AcquireContext() ) if( !AcquireContext() )
{ {
SAL_WARN( "vcl.opengl", "Couldn't acquire context" ); SAL_WARN( "vcl.opengl", "Couldn't acquire context" );
...@@ -189,6 +192,7 @@ void OpenGLSalGraphicsImpl::PostDraw() ...@@ -189,6 +192,7 @@ void OpenGLSalGraphicsImpl::PostDraw()
} }
CHECK_GL_ERROR(); CHECK_GL_ERROR();
OpenGLZone::leave();
} }
void OpenGLSalGraphicsImpl::ApplyProgramMatrices(float fPixelOffset) void OpenGLSalGraphicsImpl::ApplyProgramMatrices(float fPixelOffset)
...@@ -445,6 +449,8 @@ bool OpenGLSalGraphicsImpl::UseSolidAA( SalColor nColor ) ...@@ -445,6 +449,8 @@ bool OpenGLSalGraphicsImpl::UseSolidAA( SalColor nColor )
bool OpenGLSalGraphicsImpl::UseInvert() bool OpenGLSalGraphicsImpl::UseInvert()
{ {
OpenGLZone aZone;
if( !UseSolid( MAKE_SALCOLOR( 255, 255, 255 ) ) ) if( !UseSolid( MAKE_SALCOLOR( 255, 255, 255 ) ) )
return false; return false;
mpProgram->SetBlendMode( GL_ONE_MINUS_DST_COLOR, GL_ZERO ); mpProgram->SetBlendMode( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
...@@ -453,6 +459,8 @@ bool OpenGLSalGraphicsImpl::UseInvert() ...@@ -453,6 +459,8 @@ bool OpenGLSalGraphicsImpl::UseInvert()
void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY ) void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY )
{ {
OpenGLZone aZone;
GLfloat pPoint[2]; GLfloat pPoint[2];
pPoint[0] = GLfloat(nX); pPoint[0] = GLfloat(nX);
...@@ -467,6 +475,8 @@ void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY ) ...@@ -467,6 +475,8 @@ void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY )
void OpenGLSalGraphicsImpl::DrawLine( double nX1, double nY1, double nX2, double nY2 ) void OpenGLSalGraphicsImpl::DrawLine( double nX1, double nY1, double nX2, double nY2 )
{ {
OpenGLZone aZone;
GLfloat pPoints[4]; GLfloat pPoints[4];
pPoints[0] = GLfloat(nX1); pPoints[0] = GLfloat(nX1);
...@@ -483,6 +493,8 @@ void OpenGLSalGraphicsImpl::DrawLine( double nX1, double nY1, double nX2, double ...@@ -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 ) void OpenGLSalGraphicsImpl::DrawLineAA( double nX1, double nY1, double nX2, double nY2 )
{ {
OpenGLZone aZone;
if( !mrParent.getAntiAliasB2DDraw()) if( !mrParent.getAntiAliasB2DDraw())
return DrawLine( nX1, nY1, nX2, nY2 ); return DrawLine( nX1, nY1, nX2, nY2 );
...@@ -665,6 +677,8 @@ void OpenGLSalGraphicsImpl::DrawEdgeAA( double nX1, double nY1, double nX2, doub ...@@ -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 ) void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry, bool blockAA )
{ {
OpenGLZone aZone;
std::vector<GLfloat> aVertices(nPoints * 2); std::vector<GLfloat> aVertices(nPoints * 2);
sal_uInt32 i, j; sal_uInt32 i, j;
...@@ -706,6 +720,8 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin ...@@ -706,6 +720,8 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin
void OpenGLSalGraphicsImpl::DrawConvexPolygon( const Polygon& rPolygon, bool blockAA ) void OpenGLSalGraphicsImpl::DrawConvexPolygon( const Polygon& rPolygon, bool blockAA )
{ {
OpenGLZone aZone;
sal_uInt16 nPoints = rPolygon.GetSize() - 1; sal_uInt16 nPoints = rPolygon.GetSize() - 1;
std::vector<GLfloat> aVertices(nPoints * 2); std::vector<GLfloat> aVertices(nPoints * 2);
sal_uInt32 i, j; sal_uInt32 i, j;
...@@ -749,6 +765,8 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const Polygon& rPolygon, bool blo ...@@ -749,6 +765,8 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const Polygon& rPolygon, bool blo
void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoid, bool blockAA ) void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoid, bool blockAA )
{ {
OpenGLZone aZone;
const basegfx::B2DPolygon& rPolygon = trapezoid.getB2DPolygon(); const basegfx::B2DPolygon& rPolygon = trapezoid.getB2DPolygon();
sal_uInt16 nPoints = rPolygon.count(); sal_uInt16 nPoints = rPolygon.count();
std::vector<GLfloat> aVertices(nPoints * 2); std::vector<GLfloat> aVertices(nPoints * 2);
...@@ -850,6 +868,8 @@ void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPol ...@@ -850,6 +868,8 @@ void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPol
void OpenGLSalGraphicsImpl::DrawRegionBand( const RegionBand& rRegion ) void OpenGLSalGraphicsImpl::DrawRegionBand( const RegionBand& rRegion )
{ {
OpenGLZone aZone;
RectangleVector aRects; RectangleVector aRects;
std::vector<GLfloat> aVertices; std::vector<GLfloat> aVertices;
rRegion.GetRegionRectangles( aRects ); rRegion.GetRegionRectangles( aRects );
...@@ -883,6 +903,8 @@ void OpenGLSalGraphicsImpl::DrawRegionBand( const RegionBand& rRegion ) ...@@ -883,6 +903,8 @@ void OpenGLSalGraphicsImpl::DrawRegionBand( const RegionBand& rRegion )
void OpenGLSalGraphicsImpl::DrawTextureRect( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted ) void OpenGLSalGraphicsImpl::DrawTextureRect( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted )
{ {
OpenGLZone aZone;
GLfloat aTexCoord[8]; GLfloat aTexCoord[8];
rTexture.GetCoord( aTexCoord, rPosAry, bInverted ); rTexture.GetCoord( aTexCoord, rPosAry, bInverted );
mpProgram->SetTextureCoord( aTexCoord ); mpProgram->SetTextureCoord( aTexCoord );
...@@ -891,6 +913,8 @@ void OpenGLSalGraphicsImpl::DrawTextureRect( OpenGLTexture& rTexture, const SalT ...@@ -891,6 +913,8 @@ void OpenGLSalGraphicsImpl::DrawTextureRect( OpenGLTexture& rTexture, const SalT
void OpenGLSalGraphicsImpl::DrawTexture( OpenGLTexture& rTexture, const SalTwoRect& pPosAry, bool bInverted ) void OpenGLSalGraphicsImpl::DrawTexture( OpenGLTexture& rTexture, const SalTwoRect& pPosAry, bool bInverted )
{ {
OpenGLZone aZone;
if( !UseProgram( "textureVertexShader", "textureFragmentShader" ) ) if( !UseProgram( "textureVertexShader", "textureFragmentShader" ) )
return; return;
mpProgram->SetTexture( "sampler", rTexture ); mpProgram->SetTexture( "sampler", rTexture );
...@@ -905,6 +929,8 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture( ...@@ -905,6 +929,8 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture(
const basegfx::B2DPoint& rX, const basegfx::B2DPoint& rX,
const basegfx::B2DPoint& rY ) const basegfx::B2DPoint& rY )
{ {
OpenGLZone aZone;
GLfloat aVertices[8] = { GLfloat aVertices[8] = {
0, (float) rTexture.GetHeight(), 0, 0, 0, (float) rTexture.GetHeight(), 0, 0,
(float) rTexture.GetWidth(), 0, (float) rTexture.GetWidth(), (float) rTexture.GetHeight() }; (float) rTexture.GetWidth(), 0, (float) rTexture.GetWidth(), (float) rTexture.GetHeight() };
...@@ -993,6 +1019,8 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture( ...@@ -993,6 +1019,8 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture(
void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted, bool bPremultiplied ) void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted, bool bPremultiplied )
{ {
OpenGLZone aZone;
if( !UseProgram( "textureVertexShader", "textureFragmentShader" ) ) if( !UseProgram( "textureVertexShader", "textureFragmentShader" ) )
return; return;
mpProgram->SetTexture( "sampler", rTexture ); mpProgram->SetTexture( "sampler", rTexture );
...@@ -1004,6 +1032,8 @@ void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const Sal ...@@ -1004,6 +1032,8 @@ void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const Sal
void OpenGLSalGraphicsImpl::DrawTextureDiff( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& rPosAry, bool bInverted ) void OpenGLSalGraphicsImpl::DrawTextureDiff( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& rPosAry, bool bInverted )
{ {
OpenGLZone aZone;
if( !UseProgram( "textureVertexShader", "diffTextureFragmentShader" ) ) if( !UseProgram( "textureVertexShader", "diffTextureFragmentShader" ) )
return; return;
mpProgram->SetTexture( "texture", rTexture ); mpProgram->SetTexture( "texture", rTexture );
...@@ -1015,6 +1045,8 @@ void OpenGLSalGraphicsImpl::DrawTextureDiff( OpenGLTexture& rTexture, OpenGLText ...@@ -1015,6 +1045,8 @@ void OpenGLSalGraphicsImpl::DrawTextureDiff( OpenGLTexture& rTexture, OpenGLText
void OpenGLSalGraphicsImpl::DrawTextureWithMask( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& pPosAry ) void OpenGLSalGraphicsImpl::DrawTextureWithMask( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& pPosAry )
{ {
OpenGLZone aZone;
if( !UseProgram( "textureVertexShader", "maskedTextureFragmentShader" ) ) if( !UseProgram( "textureVertexShader", "maskedTextureFragmentShader" ) )
return; return;
mpProgram->SetTexture( "sampler", rTexture ); mpProgram->SetTexture( "sampler", rTexture );
...@@ -1026,6 +1058,8 @@ void OpenGLSalGraphicsImpl::DrawTextureWithMask( OpenGLTexture& rTexture, OpenGL ...@@ -1026,6 +1058,8 @@ void OpenGLSalGraphicsImpl::DrawTextureWithMask( OpenGLTexture& rTexture, OpenGL
void OpenGLSalGraphicsImpl::DrawBlendedTexture( OpenGLTexture& rTexture, OpenGLTexture& rMask, OpenGLTexture& rAlpha, const SalTwoRect& rPosAry ) void OpenGLSalGraphicsImpl::DrawBlendedTexture( OpenGLTexture& rTexture, OpenGLTexture& rMask, OpenGLTexture& rAlpha, const SalTwoRect& rPosAry )
{ {
OpenGLZone aZone;
GLfloat aTexCoord[8]; GLfloat aTexCoord[8];
if( !UseProgram( "blendedTextureVertexShader", "blendedTextureFragmentShader" ) ) if( !UseProgram( "blendedTextureVertexShader", "blendedTextureFragmentShader" ) )
return; return;
...@@ -1041,6 +1075,8 @@ void OpenGLSalGraphicsImpl::DrawBlendedTexture( OpenGLTexture& rTexture, OpenGLT ...@@ -1041,6 +1075,8 @@ void OpenGLSalGraphicsImpl::DrawBlendedTexture( OpenGLTexture& rTexture, OpenGLT
void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor, const SalTwoRect& pPosAry ) void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor, const SalTwoRect& pPosAry )
{ {
OpenGLZone aZone;
if( !UseProgram( "textureVertexShader", "maskFragmentShader" ) ) if( !UseProgram( "textureVertexShader", "maskFragmentShader" ) )
return; return;
mpProgram->SetColor( "color", nMaskColor, 0 ); mpProgram->SetColor( "color", nMaskColor, 0 );
...@@ -1052,6 +1088,8 @@ void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor, ...@@ -1052,6 +1088,8 @@ void OpenGLSalGraphicsImpl::DrawMask( OpenGLTexture& rMask, SalColor nMaskColor,
void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect ) void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect )
{ {
OpenGLZone aZone;
if( !UseProgram( "textureVertexShader", "linearGradientFragmentShader" ) ) if( !UseProgram( "textureVertexShader", "linearGradientFragmentShader" ) )
return; return;
Color aStartCol = rGradient.GetStartColor(); Color aStartCol = rGradient.GetStartColor();
...@@ -1076,6 +1114,8 @@ void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const ...@@ -1076,6 +1114,8 @@ void OpenGLSalGraphicsImpl::DrawLinearGradient( const Gradient& rGradient, const
void OpenGLSalGraphicsImpl::DrawAxialGradient( const Gradient& rGradient, const Rectangle& rRect ) void OpenGLSalGraphicsImpl::DrawAxialGradient( const Gradient& rGradient, const Rectangle& rRect )
{ {
OpenGLZone aZone;
if( !UseProgram( "textureVertexShader", "linearGradientFragmentShader" ) ) if( !UseProgram( "textureVertexShader", "linearGradientFragmentShader" ) )
return; return;
Color aStartCol = rGradient.GetStartColor(); Color aStartCol = rGradient.GetStartColor();
...@@ -1126,6 +1166,8 @@ void OpenGLSalGraphicsImpl::DrawAxialGradient( const Gradient& rGradient, const ...@@ -1126,6 +1166,8 @@ void OpenGLSalGraphicsImpl::DrawAxialGradient( const Gradient& rGradient, const
void OpenGLSalGraphicsImpl::DrawRadialGradient( const Gradient& rGradient, const Rectangle& rRect ) void OpenGLSalGraphicsImpl::DrawRadialGradient( const Gradient& rGradient, const Rectangle& rRect )
{ {
OpenGLZone aZone;
if( !UseProgram( "textureVertexShader", "radialGradientFragmentShader" ) ) if( !UseProgram( "textureVertexShader", "radialGradientFragmentShader" ) )
return; return;
Color aStartCol = rGradient.GetStartColor(); Color aStartCol = rGradient.GetStartColor();
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "svdata.hxx" #include "svdata.hxx"
#include "salgdi.hxx" #include "salgdi.hxx"
#include "opengl/zone.hxx"
#include "opengl/program.hxx" #include "opengl/program.hxx"
#include "opengl/salbmp.hxx" #include "opengl/salbmp.hxx"
...@@ -56,6 +57,7 @@ OpenGLSalBitmap::~OpenGLSalBitmap() ...@@ -56,6 +57,7 @@ OpenGLSalBitmap::~OpenGLSalBitmap()
bool OpenGLSalBitmap::Create( const OpenGLTexture& rTex, long nX, long nY, long nWidth, long nHeight ) bool OpenGLSalBitmap::Create( const OpenGLTexture& rTex, long nX, long nY, long nWidth, long nHeight )
{ {
static const BitmapPalette aEmptyPalette; static const BitmapPalette aEmptyPalette;
OpenGLZone aZone;
Destroy(); Destroy();
SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO: [" << nX << ", " << nY << "] " << nWidth << "x" << nHeight ); 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 ...@@ -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 ) bool OpenGLSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapPalette& rBitmapPalette )
{ {
OpenGLZone aZone;
Destroy(); Destroy();
SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create with size: " << rSize ); SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create with size: " << rSize );
...@@ -105,6 +109,8 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) ...@@ -105,6 +109,8 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics )
bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ) bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount )
{ {
OpenGLZone aZone;
// check that carefully only in the debug mode // check that carefully only in the debug mode
assert(dynamic_cast<const OpenGLSalBitmap*>(&rSalBmp)); assert(dynamic_cast<const OpenGLSalBitmap*>(&rSalBmp));
...@@ -152,6 +158,8 @@ OpenGLTexture& OpenGLSalBitmap::GetTexture() const ...@@ -152,6 +158,8 @@ OpenGLTexture& OpenGLSalBitmap::GetTexture() const
void OpenGLSalBitmap::Destroy() void OpenGLSalBitmap::Destroy()
{ {
OpenGLZone aZone;
SAL_INFO( "vcl.opengl", "Destroy OpenGLSalBitmap" ); SAL_INFO( "vcl.opengl", "Destroy OpenGLSalBitmap" );
maPendingOps.clear(); maPendingOps.clear();
maTexture = OpenGLTexture(); maTexture = OpenGLTexture();
...@@ -310,6 +318,8 @@ ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalet ...@@ -310,6 +318,8 @@ ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalet
Size OpenGLSalBitmap::GetSize() const Size OpenGLSalBitmap::GetSize() const
{ {
OpenGLZone aZone;
std::deque< OpenGLSalBitmapOp* >::const_iterator it = maPendingOps.begin(); std::deque< OpenGLSalBitmapOp* >::const_iterator it = maPendingOps.begin();
Size aSize( mnWidth, mnHeight ); Size aSize( mnWidth, mnHeight );
...@@ -484,6 +494,7 @@ void OpenGLSalBitmap::makeCurrent() ...@@ -484,6 +494,7 @@ void OpenGLSalBitmap::makeCurrent()
BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode ) BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode )
{ {
OpenGLZone aZone;
if( nMode != BITMAP_INFO_ACCESS ) if( nMode != BITMAP_INFO_ACCESS )
{ {
...@@ -529,6 +540,8 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode ) ...@@ -529,6 +540,8 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( BitmapAccessMode nMode )
void OpenGLSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) void OpenGLSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode )
{ {
OpenGLZone aZone;
if( nMode == BITMAP_WRITE_ACCESS ) if( nMode == BITMAP_WRITE_ACCESS )
{ {
maTexture = OpenGLTexture(); maTexture = OpenGLTexture();
...@@ -591,6 +604,8 @@ bool OpenGLSalBitmap::Erase( const ::Color& /*rFillColor*/ ) ...@@ -591,6 +604,8 @@ bool OpenGLSalBitmap::Erase( const ::Color& /*rFillColor*/ )
bool OpenGLSalBitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) bool OpenGLSalBitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol )
{ {
OpenGLZone aZone;
OpenGLFramebuffer* pFramebuffer; OpenGLFramebuffer* pFramebuffer;
OpenGLProgram* pProgram; OpenGLProgram* pProgram;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "vcl/bitmap.hxx" #include "vcl/bitmap.hxx"
#include "opengl/zone.hxx"
#include "opengl/bmpop.hxx" #include "opengl/bmpop.hxx"
#include "opengl/salbmp.hxx" #include "opengl/salbmp.hxx"
#include "opengl/program.hxx" #include "opengl/program.hxx"
...@@ -365,6 +366,8 @@ void ScaleOp::GetSize( Size& rSize ) const ...@@ -365,6 +366,8 @@ void ScaleOp::GetSize( Size& rSize ) const
bool OpenGLSalBitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) bool OpenGLSalBitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag )
{ {
OpenGLZone aZone;
SAL_INFO("vcl.opengl", "::Scale " << int(nScaleFlag) SAL_INFO("vcl.opengl", "::Scale " << int(nScaleFlag)
<< " from " << mnWidth << "x" << mnHeight << " from " << mnWidth << "x" << mnHeight
<< " to " << (mnWidth * rScaleX) << "x" << (mnHeight * rScaleY) ); << " to " << (mnWidth * rScaleX) << "x" << (mnHeight * rScaleY) );
......
...@@ -81,6 +81,8 @@ ...@@ -81,6 +81,8 @@
#include "cppuhelper/implbase1.hxx" #include "cppuhelper/implbase1.hxx"
#include "uno/current_context.hxx" #include "uno/current_context.hxx"
#include "opengl/zone.hxx"
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
#include <typeinfo> #include <typeinfo>
#include "rtl/strbuf.hxx" #include "rtl/strbuf.hxx"
...@@ -102,7 +104,11 @@ oslSignalAction SAL_CALL VCLExceptionSignal_impl( void* /*pData*/, oslSignalInfo ...@@ -102,7 +104,11 @@ oslSignalAction SAL_CALL VCLExceptionSignal_impl( void* /*pData*/, oslSignalInfo
(pInfo->Signal == osl_Signal_IntegerDivideByZero) || (pInfo->Signal == osl_Signal_IntegerDivideByZero) ||
(pInfo->Signal == osl_Signal_FloatDivideByZero) || (pInfo->Signal == osl_Signal_FloatDivideByZero) ||
(pInfo->Signal == osl_Signal_DebugBreak) ) (pInfo->Signal == osl_Signal_DebugBreak) )
{
nVCLException = EXC_SYSTEM; nVCLException = EXC_SYSTEM;
if (OpenGLZone::isInZone())
OpenGLZone::hardDisable();
}
// RC // RC
if ((pInfo->Signal == osl_Signal_User) && if ((pInfo->Signal == osl_Signal_User) &&
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <opengl/framebuffer.hxx> #include <opengl/framebuffer.hxx>
#include <opengl/program.hxx> #include <opengl/program.hxx>
#include <opengl/texture.hxx> #include <opengl/texture.hxx>
#include <opengl/zone.hxx>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -70,6 +71,7 @@ OpenGLContext::OpenGLContext(): ...@@ -70,6 +71,7 @@ OpenGLContext::OpenGLContext():
mpNextContext(NULL) mpNextContext(NULL)
{ {
SAL_INFO("vcl.opengl", "new context: " << this); SAL_INFO("vcl.opengl", "new context: " << this);
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS) #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
mbPixmap = false; mbPixmap = false;
#endif #endif
...@@ -185,6 +187,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l ...@@ -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) int InitTempWindow(HWND *hwnd, int width, int height, const PIXELFORMATDESCRIPTOR& inPfd, GLWindow& glWin)
{ {
OpenGLZone aZone;
PIXELFORMATDESCRIPTOR pfd = inPfd; PIXELFORMATDESCRIPTOR pfd = inPfd;
int pfmt; int pfmt;
int ret; int ret;
...@@ -228,6 +232,8 @@ int InitTempWindow(HWND *hwnd, int width, int height, const PIXELFORMATDESCRIPTO ...@@ -228,6 +232,8 @@ int InitTempWindow(HWND *hwnd, int width, int height, const PIXELFORMATDESCRIPTO
bool WGLisExtensionSupported(const char *extension) bool WGLisExtensionSupported(const char *extension)
{ {
OpenGLZone aZone;
const size_t extlen = strlen(extension); const size_t extlen = strlen(extension);
const char *supported = NULL; const char *supported = NULL;
...@@ -266,6 +272,8 @@ bool WGLisExtensionSupported(const char *extension) ...@@ -266,6 +272,8 @@ bool WGLisExtensionSupported(const char *extension)
bool InitMultisample(const PIXELFORMATDESCRIPTOR& pfd, int& rPixelFormat, bool InitMultisample(const PIXELFORMATDESCRIPTOR& pfd, int& rPixelFormat,
bool bUseDoubleBufferedRendering, bool bRequestVirtualDevice) bool bUseDoubleBufferedRendering, bool bRequestVirtualDevice)
{ {
OpenGLZone aZone;
HWND hWnd = NULL; HWND hWnd = NULL;
GLWindow glWin; GLWindow glWin;
//create a temp windwo to check whether support multi-sample, if support, get the format //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 ...@@ -558,6 +566,8 @@ GLXFBConfig* getFBConfigForPixmap(Display* dpy, int& nBestFBC, bool bUseDoubleBu
GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC, bool bUseDoubleBufferedRendering, bool bWithSameVisualID) GLXFBConfig* getFBConfig(Display* dpy, Window win, int& nBestFBC, bool bUseDoubleBufferedRendering, bool bWithSameVisualID)
{ {
OpenGLZone aZone;
if( dpy == 0 || !glXQueryExtension( dpy, NULL, NULL ) ) if( dpy == 0 || !glXQueryExtension( dpy, NULL, NULL ) )
return NULL; return NULL;
...@@ -638,6 +648,8 @@ void initOpenGLFunctionPointers() ...@@ -638,6 +648,8 @@ void initOpenGLFunctionPointers()
Visual* getVisual(Display* dpy, Window win) Visual* getVisual(Display* dpy, Window win)
{ {
OpenGLZone aZone;
initOpenGLFunctionPointers(); initOpenGLFunctionPointers();
XWindowAttributes xattr; XWindowAttributes xattr;
...@@ -659,6 +671,8 @@ bool OpenGLContext::init( vcl::Window* pParent ) ...@@ -659,6 +671,8 @@ bool OpenGLContext::init( vcl::Window* pParent )
if(mbInitialized) if(mbInitialized)
return true; return true;
OpenGLZone aZone;
m_xWindow.reset(pParent ? nullptr : VclPtr<vcl::Window>::Create(nullptr, WB_NOBORDER|WB_NODIALOGCONTROL)); m_xWindow.reset(pParent ? nullptr : VclPtr<vcl::Window>::Create(nullptr, WB_NOBORDER|WB_NODIALOGCONTROL));
mpWindow = pParent ? pParent : m_xWindow.get(); mpWindow = pParent ? pParent : m_xWindow.get();
if(m_xWindow) if(m_xWindow)
...@@ -676,6 +690,8 @@ bool OpenGLContext::init(SystemChildWindow* pChildWindow) ...@@ -676,6 +690,8 @@ bool OpenGLContext::init(SystemChildWindow* pChildWindow)
if( !pChildWindow ) if( !pChildWindow )
return false; return false;
OpenGLZone aZone;
mpWindow = pChildWindow->GetParent(); mpWindow = pChildWindow->GetParent();
m_pChildWindow = pChildWindow; m_pChildWindow = pChildWindow;
initWindow(); initWindow();
...@@ -691,6 +707,8 @@ bool OpenGLContext::init(Display* dpy, Window win, int screen) ...@@ -691,6 +707,8 @@ bool OpenGLContext::init(Display* dpy, Window win, int screen)
if (!dpy) if (!dpy)
return false; return false;
OpenGLZone aZone;
m_aGLWin.dpy = dpy; m_aGLWin.dpy = dpy;
m_aGLWin.win = win; m_aGLWin.win = win;
m_aGLWin.screen = screen; m_aGLWin.screen = screen;
...@@ -740,6 +758,8 @@ bool OpenGLContext::ImplInit() ...@@ -740,6 +758,8 @@ bool OpenGLContext::ImplInit()
return false; return false;
} }
OpenGLZone aZone;
GLXContext pSharedCtx( NULL ); GLXContext pSharedCtx( NULL );
#ifdef DBG_UTIL #ifdef DBG_UTIL
TempErrorHandler aErrorHandler(m_aGLWin.dpy, unxErrorHandler); TempErrorHandler aErrorHandler(m_aGLWin.dpy, unxErrorHandler);
...@@ -866,6 +886,8 @@ bool OpenGLContext::init(HDC hDC, HWND hWnd) ...@@ -866,6 +886,8 @@ bool OpenGLContext::init(HDC hDC, HWND hWnd)
bool OpenGLContext::ImplInit() bool OpenGLContext::ImplInit()
{ {
OpenGLZone aZone;
SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start"); SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start");
// PixelFormat tells Windows how we want things to be // PixelFormat tells Windows how we want things to be
PIXELFORMATDESCRIPTOR PixelFormatFront = PIXELFORMATDESCRIPTOR PixelFormatFront =
...@@ -988,6 +1010,8 @@ bool OpenGLContext::ImplInit() ...@@ -988,6 +1010,8 @@ bool OpenGLContext::ImplInit()
bool OpenGLContext::ImplInit() bool OpenGLContext::ImplInit()
{ {
OpenGLZone aZone;
SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start"); SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start");
NSOpenGLView* pView = getOpenGLView(); NSOpenGLView* pView = getOpenGLView();
OpenGLWrapper::makeCurrent(pView); OpenGLWrapper::makeCurrent(pView);
...@@ -1010,6 +1034,8 @@ bool OpenGLContext::InitGLEW() ...@@ -1010,6 +1034,8 @@ bool OpenGLContext::InitGLEW()
static bool bGlewInit = false; static bool bGlewInit = false;
if(!bGlewInit) if(!bGlewInit)
{ {
OpenGLZone aZone;
glewExperimental = GL_TRUE; glewExperimental = GL_TRUE;
GLenum err = glewInit(); GLenum err = glewInit();
if (err != GLEW_OK) if (err != GLEW_OK)
...@@ -1025,6 +1051,8 @@ bool OpenGLContext::InitGLEW() ...@@ -1025,6 +1051,8 @@ bool OpenGLContext::InitGLEW()
// only enable debug output in dbgutil build // only enable debug output in dbgutil build
if( GLEW_ARB_debug_output) if( GLEW_ARB_debug_output)
{ {
OpenGLZone aZone;
if (glDebugMessageCallbackARB) if (glDebugMessageCallbackARB)
{ {
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
...@@ -1169,6 +1197,8 @@ bool OpenGLContext::initWindow() ...@@ -1169,6 +1197,8 @@ bool OpenGLContext::initWindow()
void OpenGLContext::initGLWindow(Visual* pVisual) void OpenGLContext::initGLWindow(Visual* pVisual)
{ {
OpenGLZone aZone;
// Get visual info // Get visual info
{ {
XVisualInfo aTemplate; XVisualInfo aTemplate;
...@@ -1199,6 +1229,8 @@ void OpenGLContext::reset() ...@@ -1199,6 +1229,8 @@ void OpenGLContext::reset()
if( !mbInitialized ) if( !mbInitialized )
return; return;
OpenGLZone aZone;
// reset the clip region // reset the clip region
maClipRegion.SetEmpty(); maClipRegion.SetEmpty();
...@@ -1285,6 +1317,8 @@ SystemWindowData OpenGLContext::generateWinData(vcl::Window* /*pParent*/, bool b ...@@ -1285,6 +1317,8 @@ SystemWindowData OpenGLContext::generateWinData(vcl::Window* /*pParent*/, bool b
SystemWindowData OpenGLContext::generateWinData(vcl::Window* pParent, bool) SystemWindowData OpenGLContext::generateWinData(vcl::Window* pParent, bool)
{ {
OpenGLZone aZone;
SystemWindowData aWinData; SystemWindowData aWinData;
aWinData.nSize = sizeof(aWinData); aWinData.nSize = sizeof(aWinData);
aWinData.pVisual = NULL; aWinData.pVisual = NULL;
...@@ -1326,6 +1360,8 @@ SystemWindowData OpenGLContext::generateWinData(vcl::Window* pParent, bool) ...@@ -1326,6 +1360,8 @@ SystemWindowData OpenGLContext::generateWinData(vcl::Window* pParent, bool)
bool OpenGLContext::isCurrent() bool OpenGLContext::isCurrent()
{ {
OpenGLZone aZone;
#if defined( WNT ) #if defined( WNT )
return (wglGetCurrentContext() == m_aGLWin.hRC && return (wglGetCurrentContext() == m_aGLWin.hRC &&
wglGetCurrentDC() == m_aGLWin.hDC); wglGetCurrentDC() == m_aGLWin.hDC);
...@@ -1359,6 +1395,8 @@ void OpenGLContext::makeCurrent() ...@@ -1359,6 +1395,8 @@ void OpenGLContext::makeCurrent()
if (isCurrent()) if (isCurrent())
return; return;
OpenGLZone aZone;
clearCurrent(); clearCurrent();
#if defined( WNT ) #if defined( WNT )
...@@ -1407,6 +1445,8 @@ void OpenGLContext::resetCurrent() ...@@ -1407,6 +1445,8 @@ void OpenGLContext::resetCurrent()
{ {
clearCurrent(); clearCurrent();
OpenGLZone aZone;
#if defined( WNT ) #if defined( WNT )
wglMakeCurrent( m_aGLWin.hDC, 0 ); wglMakeCurrent( m_aGLWin.hDC, 0 );
#elif defined( MACOSX ) #elif defined( MACOSX )
...@@ -1421,6 +1461,8 @@ void OpenGLContext::resetCurrent() ...@@ -1421,6 +1461,8 @@ void OpenGLContext::resetCurrent()
void OpenGLContext::swapBuffers() void OpenGLContext::swapBuffers()
{ {
OpenGLZone aZone;
#if defined( WNT ) #if defined( WNT )
SwapBuffers(m_aGLWin.hDC); SwapBuffers(m_aGLWin.hDC);
#elif defined( MACOSX ) #elif defined( MACOSX )
...@@ -1435,6 +1477,8 @@ void OpenGLContext::swapBuffers() ...@@ -1435,6 +1477,8 @@ void OpenGLContext::swapBuffers()
void OpenGLContext::sync() void OpenGLContext::sync()
{ {
OpenGLZone aZone;
#if defined( WNT ) #if defined( WNT )
// nothing // nothing
#elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID ) || defined(LIBO_HEADLESS) #elif defined( MACOSX ) || defined( IOS ) || defined( ANDROID ) || defined(LIBO_HEADLESS)
...@@ -1478,6 +1522,8 @@ NSOpenGLView* OpenGLContext::getOpenGLView() ...@@ -1478,6 +1522,8 @@ NSOpenGLView* OpenGLContext::getOpenGLView()
bool OpenGLContext::BindFramebuffer( OpenGLFramebuffer* pFramebuffer ) bool OpenGLContext::BindFramebuffer( OpenGLFramebuffer* pFramebuffer )
{ {
OpenGLZone aZone;
if( pFramebuffer != mpCurrentFramebuffer ) if( pFramebuffer != mpCurrentFramebuffer )
{ {
if( pFramebuffer ) if( pFramebuffer )
...@@ -1497,6 +1543,8 @@ bool OpenGLContext::AcquireDefaultFramebuffer() ...@@ -1497,6 +1543,8 @@ bool OpenGLContext::AcquireDefaultFramebuffer()
OpenGLFramebuffer* OpenGLContext::AcquireFramebuffer( const OpenGLTexture& rTexture ) OpenGLFramebuffer* OpenGLContext::AcquireFramebuffer( const OpenGLTexture& rTexture )
{ {
OpenGLZone aZone;
OpenGLFramebuffer* pFramebuffer = NULL; OpenGLFramebuffer* pFramebuffer = NULL;
OpenGLFramebuffer* pFreeFbo = NULL; OpenGLFramebuffer* pFreeFbo = NULL;
OpenGLFramebuffer* pSameSizeFbo = NULL; OpenGLFramebuffer* pSameSizeFbo = NULL;
...@@ -1563,6 +1611,7 @@ void OpenGLContext::ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer ) ...@@ -1563,6 +1611,7 @@ void OpenGLContext::ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer )
void OpenGLContext::ReleaseFramebuffer( const OpenGLTexture& rTexture ) void OpenGLContext::ReleaseFramebuffer( const OpenGLTexture& rTexture )
{ {
OpenGLZone aZone;
OpenGLFramebuffer* pFramebuffer = mpLastFramebuffer; OpenGLFramebuffer* pFramebuffer = mpLastFramebuffer;
while( pFramebuffer ) while( pFramebuffer )
...@@ -1578,6 +1627,7 @@ void OpenGLContext::ReleaseFramebuffer( const OpenGLTexture& rTexture ) ...@@ -1578,6 +1627,7 @@ void OpenGLContext::ReleaseFramebuffer( const OpenGLTexture& rTexture )
void OpenGLContext::ReleaseFramebuffers() void OpenGLContext::ReleaseFramebuffers()
{ {
OpenGLZone aZone;
OpenGLFramebuffer* pFramebuffer = mpLastFramebuffer; OpenGLFramebuffer* pFramebuffer = mpLastFramebuffer;
while( pFramebuffer ) while( pFramebuffer )
{ {
...@@ -1589,6 +1639,8 @@ void OpenGLContext::ReleaseFramebuffers() ...@@ -1589,6 +1639,8 @@ void OpenGLContext::ReleaseFramebuffers()
OpenGLProgram* OpenGLContext::GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble ) OpenGLProgram* OpenGLContext::GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble )
{ {
OpenGLZone aZone;
ProgramKey aKey( rVertexShader, rFragmentShader, preamble ); ProgramKey aKey( rVertexShader, rFragmentShader, preamble );
std::map< ProgramKey, boost::shared_ptr<OpenGLProgram> >::iterator std::map< ProgramKey, boost::shared_ptr<OpenGLProgram> >::iterator
...@@ -1606,6 +1658,8 @@ OpenGLProgram* OpenGLContext::GetProgram( const OUString& rVertexShader, const O ...@@ -1606,6 +1658,8 @@ OpenGLProgram* OpenGLContext::GetProgram( const OUString& rVertexShader, const O
OpenGLProgram* OpenGLContext::UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble ) OpenGLProgram* OpenGLContext::UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble )
{ {
OpenGLZone aZone;
OpenGLProgram* pProgram = GetProgram( rVertexShader, rFragmentShader, preamble ); OpenGLProgram* pProgram = GetProgram( rVertexShader, rFragmentShader, preamble );
if( pProgram == mpCurrentProgram ) if( pProgram == mpCurrentProgram )
......
...@@ -20,9 +20,13 @@ ...@@ -20,9 +20,13 @@
#include <vcl/graph.hxx> #include <vcl/graph.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <officecfg/Office/Common.hxx> #include <officecfg/Office/Common.hxx>
#include <com/sun/star/util/XFlushable.hpp>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
#include <vector> #include <vector>
#include "opengl/zone.hxx"
#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID #if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID
#include "opengl/x11/X11DeviceInfo.hxx" #include "opengl/x11/X11DeviceInfo.hxx"
#elif defined (_WIN32) #elif defined (_WIN32)
...@@ -68,6 +72,8 @@ namespace { ...@@ -68,6 +72,8 @@ namespace {
int LogCompilerError(GLuint nId, const rtl::OUString &rDetail, int LogCompilerError(GLuint nId, const rtl::OUString &rDetail,
const rtl::OUString &rName, bool bShaderNotProgram) const rtl::OUString &rName, bool bShaderNotProgram)
{ {
OpenGLZone aZone;
int InfoLogLength = 0; int InfoLogLength = 0;
CHECK_GL_ERROR(); CHECK_GL_ERROR();
...@@ -127,6 +133,8 @@ static void addPreamble(OString& rShaderSource, const OString& rPreamble) ...@@ -127,6 +133,8 @@ static void addPreamble(OString& rShaderSource, const OString& rPreamble)
GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString& rFragmentShaderName, const OString& preamble) GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString& rFragmentShaderName, const OString& preamble)
{ {
OpenGLZone aZone;
// Create the shaders // Create the shaders
GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER); GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER); GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
...@@ -205,6 +213,8 @@ void OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, ...@@ -205,6 +213,8 @@ void OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx,
void OpenGLHelper::renderToFile(long nWidth, long nHeight, const OUString& rFileName) void OpenGLHelper::renderToFile(long nWidth, long nHeight, const OUString& rFileName)
{ {
OpenGLZone aZone;
boost::scoped_array<sal_uInt8> pBuffer(new sal_uInt8[nWidth*nHeight*4]); boost::scoped_array<sal_uInt8> pBuffer(new sal_uInt8[nWidth*nHeight*4]);
glReadPixels(0, 0, nWidth, nHeight, GL_BGRA, GL_UNSIGNED_BYTE, pBuffer.get()); glReadPixels(0, 0, nWidth, nHeight, GL_BGRA, GL_UNSIGNED_BYTE, pBuffer.get());
BitmapEx aBitmap = ConvertBGRABufferToBitmapEx(pBuffer.get(), nWidth, nHeight); BitmapEx aBitmap = ConvertBGRABufferToBitmapEx(pBuffer.get(), nWidth, nHeight);
...@@ -312,6 +322,8 @@ std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix) ...@@ -312,6 +322,8 @@ std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix)
void OpenGLHelper::createFramebuffer(long nWidth, long nHeight, GLuint& nFramebufferId, void OpenGLHelper::createFramebuffer(long nWidth, long nHeight, GLuint& nFramebufferId,
GLuint& nRenderbufferDepthId, GLuint& nRenderbufferColorId, bool bRenderbuffer) GLuint& nRenderbufferDepthId, GLuint& nRenderbufferColorId, bool bRenderbuffer)
{ {
OpenGLZone aZone;
// create a renderbuffer for depth attachment // create a renderbuffer for depth attachment
glGenRenderbuffers(1, &nRenderbufferDepthId); glGenRenderbuffers(1, &nRenderbufferDepthId);
glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferDepthId); glBindRenderbuffer(GL_RENDERBUFFER, nRenderbufferDepthId);
...@@ -383,6 +395,8 @@ float OpenGLHelper::getGLVersion() ...@@ -383,6 +395,8 @@ float OpenGLHelper::getGLVersion()
void OpenGLHelper::checkGLError(const char* pFile, size_t nLine) void OpenGLHelper::checkGLError(const char* pFile, size_t nLine)
{ {
OpenGLZone aZone;
GLenum glErr = glGetError(); GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR) if (glErr != GL_NO_ERROR)
{ {
...@@ -403,6 +417,8 @@ bool OpenGLHelper::isDeviceBlacklisted() ...@@ -403,6 +417,8 @@ bool OpenGLHelper::isDeviceBlacklisted()
static bool bBlacklisted = true; // assume the worst static bool bBlacklisted = true; // assume the worst
if (!bSet) if (!bSet)
{ {
OpenGLZone aZone;
#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID #if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID
X11OpenGLDeviceInfo aInfo; X11OpenGLDeviceInfo aInfo;
bBlacklisted = aInfo.isDeviceBlocked(); bBlacklisted = aInfo.isDeviceBlocked();
...@@ -430,6 +446,34 @@ bool OpenGLHelper::supportsVCLOpenGL() ...@@ -430,6 +446,34 @@ bool OpenGLHelper::supportsVCLOpenGL()
return true; 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() bool OpenGLHelper::isVCLOpenGLEnabled()
{ {
/** /**
...@@ -483,6 +527,8 @@ bool OpenGLHelper::isVCLOpenGLEnabled() ...@@ -483,6 +527,8 @@ bool OpenGLHelper::isVCLOpenGLEnabled()
bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rVI) bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rVI)
{ {
OpenGLZone aZone;
XVisualInfo* pVI; XVisualInfo* pVI;
int aAttrib[] = { GLX_RGBA, int aAttrib[] = { GLX_RGBA,
GLX_RED_SIZE, 8, GLX_RED_SIZE, 8,
...@@ -505,6 +551,8 @@ bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rV ...@@ -505,6 +551,8 @@ bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rV
GLXFBConfig OpenGLHelper::GetPixmapFBConfig( Display* pDisplay, bool& bInverted ) GLXFBConfig OpenGLHelper::GetPixmapFBConfig( Display* pDisplay, bool& bInverted )
{ {
OpenGLZone aZone;
int nScreen = DefaultScreen( pDisplay ); int nScreen = DefaultScreen( pDisplay );
GLXFBConfig *aFbConfigs; GLXFBConfig *aFbConfigs;
int i, nFbConfigs, nValue; int i, nFbConfigs, nValue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment