[Libreoffice-commits] core.git: 2 commits - avmedia/source include/vcl slideshow/source vcl/source
Zolnai Tamás
tamas.zolnai at collabora.com
Mon Jul 21 04:53:02 PDT 2014
avmedia/source/opengl/oglplayer.cxx | 31 ++++++++++
include/vcl/opengl/OpenGLHelper.hxx | 3
slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx | 11 ---
slideshow/source/engine/OGLTrans/mac/OGLTrans_TransitionerImpl.mm | 12 +--
slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionerImpl.cxx | 12 +--
vcl/source/opengl/OpenGLHelper.cxx | 15 ++++
6 files changed, 60 insertions(+), 24 deletions(-)
New commits:
commit 378b1d24a958114eb4484cb10f609f6e482772ec
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Sun Jul 20 17:20:01 2014 +0200
fdo#81055: Crash due to inadequate checks for GL version / capabilities
Base line is OpenGL 2.1 + extensions:
GL_ARB_framebuffer_object (part of OpenGL 3.0) for
glGenFramebuffers, glGenRenderbuffers...
GL_ARB_vertex_array_object (part of OpenGL 3.0) for
glGenVertexArrays, glBindVertexArray...
GL_ARB_sampler_objects (part of OpenGL 3.3) for
glGenSamplers, glBindSampler...
Change-Id: Ib8acf41ab85cd1677d0341719b3a5b4f743ed756
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index a602d3c..89ac3b1 100644
--- a/avmedia/source/opengl/oglplayer.cxx
+++ b/avmedia/source/opengl/oglplayer.cxx
@@ -239,6 +239,25 @@ awt::Size SAL_CALL OGLPlayer::getPreferredPlayerWindowSize() throw ( uno::Runtim
return awt::Size( 480, 360 );
}
+static bool lcl_CheckOpenGLRequirements()
+{
+ float fVersion = OpenGLHelper::getGLVersion();
+ if( fVersion >= 3.3 )
+ {
+ return true;
+ }
+ else if( fVersion >= 3.0 )
+ {
+ return glewIsSupported("GL_ARB_sampler_objects");
+ }
+ else if( fVersion >= 2.1 )
+ {
+ return glewIsSupported("GL_ARB_sampler_objects GL_ARB_framebuffer_object GL_ARB_vertex_array_object");
+ }
+
+ return false;
+}
+
uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( const uno::Sequence< uno::Any >& rArguments )
throw ( uno::RuntimeException, std::exception )
{
@@ -264,6 +283,12 @@ uno::Reference< media::XPlayerWindow > SAL_CALL OGLPlayer::createPlayerWindow( c
return uno::Reference< media::XPlayerWindow >();
}
+ if( !lcl_CheckOpenGLRequirements() )
+ {
+ SAL_WARN("avmedia.opengl", "Your platform does not have the minimal OpenGL requiremenets!");
+ return uno::Reference< media::XPlayerWindow >();
+ }
+
Size aSize = pChildWindow->GetSizePixel();
m_aContext.setWinSize(aSize);
m_pHandle->viewport.x = 0;
@@ -298,6 +323,12 @@ uno::Reference< media::XFrameGrabber > SAL_CALL OGLPlayer::createFrameGrabber()
return uno::Reference< media::XFrameGrabber >();
}
+ if( !lcl_CheckOpenGLRequirements() )
+ {
+ SAL_WARN("avmedia.opengl", "Your platform does not have the minimal OpenGL requiremenets!");
+ return uno::Reference< media::XFrameGrabber >();
+ }
+
m_pHandle->viewport.x = 0;
m_pHandle->viewport.y = 0;
m_pHandle->viewport.width = getPreferredPlayerWindowSize().Width;
commit 23c876deeb357b6306712ff0586a819176151c15
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Sun Jul 20 14:20:35 2014 +0200
Extract getGLVersion() method to OpenGLHelper
Change-Id: If3b7a6c71164f2b55defe8c28cdce69de9283175
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 9cc485b..87a71fa 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -36,6 +36,9 @@ public:
*/
static void createFramebuffer(long nWidth, long nHeight,
GLuint& nFramebufferId, GLuint& nRenderbufferTextId, GLuint& nRenderbufferColorId);
+
+ // Get OpenGL version (needs a context)
+ static float getGLVersion();
};
VCLOPENGL_DLLPUBLIC std::ostream& operator<<(std::ostream& rStrm, const glm::mat4& rMatrix);
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
index 36c1dd0..378de36 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
@@ -61,6 +61,7 @@
#include <vcl/canvastools.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
+#include <vcl/opengl/OpenGLHelper.hxx>
#include <vcl/window.hxx>
#include <boost/noncopyable.hpp>
@@ -337,14 +338,8 @@ void OGLTransitionerImpl::impl_initializeFlags( bool const bGLXPresent )
{
mbGLXPresent = bGLXPresent;
if ( bGLXPresent ) {
- const GLubyte* version = glGetString( GL_VERSION );
- if( version && version[0] ) {
- mnGLVersion = version[0] - '0';
- if( version[1] == '.' && version[2] )
- mnGLVersion += (version[2] - '0')/10.0;
- } else
- mnGLVersion = 1.0;
- SAL_INFO("slideshow.opengl", "GL version: " << version << " parsed: " << mnGLVersion << "" );
+ mnGLVersion = OpenGLHelper::getGLVersion();
+ SAL_INFO("slideshow.opengl", "GL version: " << mnGLVersion << "" );
const GLubyte* vendor = glGetString( GL_VENDOR );
mbMesa = ( vendor && strstr( (const char *) vendor, "Mesa" ) );
diff --git a/slideshow/source/engine/OGLTrans/mac/OGLTrans_TransitionerImpl.mm b/slideshow/source/engine/OGLTrans/mac/OGLTrans_TransitionerImpl.mm
index 47cdb2d..62b135a 100644
--- a/slideshow/source/engine/OGLTrans/mac/OGLTrans_TransitionerImpl.mm
+++ b/slideshow/source/engine/OGLTrans/mac/OGLTrans_TransitionerImpl.mm
@@ -56,6 +56,8 @@
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
+#include <vcl/opengl/OpenGLHelper.hxx>
+
#include <boost/noncopyable.hpp>
#include <premac.h>
@@ -311,14 +313,8 @@ bool OGLTransitionerImpl::initialize( const Reference< presentation::XSlideShowV
if( instance->initWindowFromSlideShowView( xView ) )
{
- const GLubyte* version = glGetString( GL_VERSION );
- if( version && version[0] ) {
- cnGLVersion = version[0] - '0';
- if( version[1] == '.' && version[2] )
- cnGLVersion += (version[2] - '0')/10.0;
- } else
- cnGLVersion = 1.0;
- OSL_TRACE("GL version: %s parsed: %f", version, cnGLVersion );
+ cnGLVersion = OpenGLHelper::getGLVersion();
+ OSL_TRACE("GL version: %f", cnGLVersion );
const GLubyte* vendor = glGetString( GL_VENDOR );
cbMesa = ( vendor && strstr( (const char *) vendor, "Mesa" ) );
diff --git a/slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionerImpl.cxx
index 19f22fd..2fcd3b5 100644
--- a/slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionerImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionerImpl.cxx
@@ -56,6 +56,8 @@
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
+#include <vcl/opengl/OpenGLHelper.hxx>
+
#include <boost/noncopyable.hpp>
#include <GL/gl.h>
@@ -314,14 +316,8 @@ bool OGLTransitionerImpl::initialize( const Reference< presentation::XSlideShowV
instance = new OGLTransitionerImpl( NULL );
if( instance->initWindowFromSlideShowView( xView ) ) {
- const GLubyte* version = glGetString( GL_VERSION );
- if( version && version[0] ) {
- cnGLVersion = version[0] - '0';
- if( version[1] == '.' && version[2] )
- cnGLVersion += (version[2] - '0')/10.0;
- } else
- cnGLVersion = 1.0;
- OSL_TRACE("GL version: %s parsed: %f", version, cnGLVersion );
+ cnGLVersion = OpenGLHelper::getGLVersion();
+ OSL_TRACE("GL version: %f", cnGLVersion );
const GLubyte* vendor = glGetString( GL_VENDOR );
cbMesa = ( vendor && strstr( (const char *) vendor, "Mesa" ) );
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index a2d9b83..0629d90 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -305,5 +305,20 @@ void OpenGLHelper::createFramebuffer(long nWidth, long nHeight,
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
+float OpenGLHelper::getGLVersion()
+{
+ float fVersion = 1.0;
+ const GLubyte* aVersion = glGetString( GL_VERSION );
+ if( aVersion && aVersion[0] )
+ {
+ fVersion = aVersion[0] - '0';
+ if( aVersion[1] == '.' && aVersion[2] )
+ {
+ fVersion += (aVersion[2] - '0')/10.0;
+ }
+ }
+ return fVersion;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list