[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - avmedia/source include/vcl vcl/source
Zolnai Tamás
tamas.zolnai at collabora.com
Mon Jul 21 12:22:16 PDT 2014
avmedia/source/opengl/oglplayer.cxx | 31 +++++++++++++++++++++++++++++++
include/vcl/opengl/OpenGLHelper.hxx | 3 +++
vcl/source/opengl/OpenGLHelper.cxx | 15 +++++++++++++++
3 files changed, 49 insertions(+)
New commits:
commit 3c2ce3618f586d932b516c15167a79f2b882fbf5
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Mon Jul 21 14:21:25 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...
(cherry picked from commit 378b1d24a958114eb4484cb10f609f6e482772ec)
(and cherry picked some part of commit 23c876deeb357b6306712ff0586a819176151c15)
Change-Id: I3a3caeab7ef593188ee742c53e6715648bf14f50
Reviewed-on: https://gerrit.libreoffice.org/10440
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index f39f847..b827d2f 100644
--- a/avmedia/source/opengl/oglplayer.cxx
+++ b/avmedia/source/opengl/oglplayer.cxx
@@ -246,6 +246,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 )
{
@@ -271,6 +290,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;
@@ -305,6 +330,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;
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 475bd72..58c3d15 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/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index bace47b..8eb88b9 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -299,5 +299,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