include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx | 4 + include/vcl/OpenGLContext.hxx | 2 svx/Library_svxcore.mk | 3 + svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx | 3 + vcl/source/opengl/OpenGLContext.cxx | 37 ++++++++------- 5 files changed, 34 insertions(+), 15 deletions(-)
New commits: commit b48f11667dc28abf8fbbb0c4136909a437c0e00b Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Wed Apr 2 03:31:38 2014 +0200 fix crash when passing external Window to OpenGLContext::init The external window is not controlled by OpenGLContext so it is not allowed to delete the window Change-Id: Id2c79a3612cc875fd94b8cd1206b30af2f185875 diff --git a/include/vcl/OpenGLContext.hxx b/include/vcl/OpenGLContext.hxx index 91355bf..e84e8fc 100644 --- a/include/vcl/OpenGLContext.hxx +++ b/include/vcl/OpenGLContext.hxx @@ -108,6 +108,7 @@ private: GLWindow m_aGLWin; boost::scoped_ptr<Window> m_pWindow; + Window* mpWindow; //points to m_pWindow or the parent window, don't delete it boost::scoped_ptr<SystemChildWindow> m_pChildWindow; bool mbInitialized; }; diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 8540da3..b9b9125 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -14,6 +14,7 @@ using namespace com::sun::star; OpenGLContext::OpenGLContext(): + mpWindow(NULL), mbInitialized(false) { } @@ -319,13 +320,15 @@ int oglErrorHandler( Display* /*dpy*/, XErrorEvent* /*evnt*/ ) bool OpenGLContext::init( Window* pParent ) { - m_pWindow.reset(pParent ? pParent : new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL)); if(mbInitialized) return true; + m_pWindow.reset(pParent ? NULL : new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL)); + mpWindow = pParent ? pParent : m_pWindow.get(); SAL_INFO("vcl.opengl", "OpenGLContext::OpenGLContext----start"); initWindow(); - m_pWindow->setPosSizePixel(0,0,0,0); + if(m_pWindow) + m_pWindow->setPosSizePixel(0,0,0,0); m_aGLWin.Width = 0; m_aGLWin.Height = 0; @@ -396,10 +399,10 @@ bool OpenGLContext::init( Window* pParent ) double nGLXVersion = 0; if( glXQueryVersion( m_aGLWin.dpy, &glxMajor, &glxMinor ) ) nGLXVersion = glxMajor + 0.1*glxMinor; - SAL_INFO("vcl.opengl", "available GLX version: %f", nGLXVersion); + SAL_INFO("vcl.opengl", "available GLX version: " << nGLXVersion); m_aGLWin.GLExtensions = glGetString( GL_EXTENSIONS ); - SAL_INFO("vcl.opengl", "available GL extensions: %s", m_aGLWin.GLExtensions); + SAL_INFO("vcl.opengl", "available GL extensions: " << m_aGLWin.GLExtensions); if( m_aGLWin.HasGLXExtension("GLX_SGI_swap_control" ) ) { @@ -451,7 +454,8 @@ bool OpenGLContext::init( Window* pParent ) void OpenGLContext::setWinSize(const Size& rSize) { - m_pWindow->SetSizePixel(rSize); + if(m_pWindow) + m_pWindow->SetSizePixel(rSize); m_pChildWindow->SetSizePixel(rSize); } @@ -464,12 +468,11 @@ GLWindow& OpenGLContext::getOpenGLWindow() bool OpenGLContext::initWindow() { - const SystemEnvData* sysData(m_pWindow->GetSystemData()); + const SystemEnvData* sysData(mpWindow->GetSystemData()); m_aGLWin.hWnd = sysData->hWnd; SystemWindowData winData; winData.nSize = sizeof(winData); - m_pChildWindow.reset(new SystemChildWindow(m_pWindow.get(), 0, &winData, sal_False)); - + m_pChildWindow.reset(new SystemChildWindow(mpWindow.get(), 0, &winData, sal_False)); if( m_pChildWindow ) { @@ -503,14 +506,13 @@ void initOpenGLFunctionPointers() glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig"); glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig"); // try to find a visual for the current set of attributes glXGetFBConfigAttrib = (int(*)(Display *dpy, GLXFBConfig config, int attribute, int* value))glXGetProcAddressARB((GLubyte*)"glXGetFBConfigAttrib"); - } } bool OpenGLContext::initWindow() { - const SystemEnvData* sysData(m_pWindow->GetSystemData()); + const SystemEnvData* sysData(mpWindow->GetSystemData()); m_aGLWin.dpy = reinterpret_cast<Display*>(sysData->pDisplay); @@ -519,7 +521,7 @@ bool OpenGLContext::initWindow() m_aGLWin.win = sysData->aWindow; - SAL_INFO("vcl.opengl", "parent window: %d", m_aGLWin.win); + SAL_INFO("vcl.opengl", "parent window: " << m_aGLWin.win); XWindowAttributes xattr; XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &xattr ); @@ -582,9 +584,9 @@ bool OpenGLContext::initWindow() { SystemWindowData winData; winData.nSize = sizeof(winData); - SAL_INFO("vcl.opengl", "using VisualID %08X", vi->visualid); + SAL_INFO("vcl.opengl", "using VisualID " << vi->visualid); winData.pVisual = (void*)(vi->visual); - m_pChildWindow.reset(new SystemChildWindow(m_pWindow.get(), 0, &winData, false)); + m_pChildWindow.reset(new SystemChildWindow(mpWindow, 0, &winData, false)); pChildSysData = m_pChildWindow->GetSystemData(); } @@ -601,7 +603,7 @@ bool OpenGLContext::initWindow() m_aGLWin.win = pChildSysData->aWindow; m_aGLWin.vi = vi; m_aGLWin.GLXExtensions = glXQueryExtensionsString( m_aGLWin.dpy, m_aGLWin.screen ); - SAL_INFO("vcl.opengl", "available GLX extensions: %s", m_aGLWin.GLXExtensions); + SAL_INFO("vcl.opengl", "available GLX extensions: " << m_aGLWin.GLXExtensions); return true; } commit 7bfe7696e8f052076f91d0d14db3ba4029056281 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Wed Apr 2 03:31:01 2014 +0200 prevent initializing the OpenGL context multiple times Change-Id: I2ebdbcd51938bc1dc61693ac392eed5d5e497a8d diff --git a/include/vcl/OpenGLContext.hxx b/include/vcl/OpenGLContext.hxx index 82145b4..91355bf 100644 --- a/include/vcl/OpenGLContext.hxx +++ b/include/vcl/OpenGLContext.hxx @@ -109,6 +109,7 @@ private: GLWindow m_aGLWin; boost::scoped_ptr<Window> m_pWindow; boost::scoped_ptr<SystemChildWindow> m_pChildWindow; + bool mbInitialized; }; #endif diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 06920fa..8540da3 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -13,7 +13,8 @@ using namespace com::sun::star; -OpenGLContext::OpenGLContext() +OpenGLContext::OpenGLContext(): + mbInitialized(false) { } @@ -319,6 +320,9 @@ int oglErrorHandler( Display* /*dpy*/, XErrorEvent* /*evnt*/ ) bool OpenGLContext::init( Window* pParent ) { m_pWindow.reset(pParent ? pParent : new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL)); + if(mbInitialized) + return true; + SAL_INFO("vcl.opengl", "OpenGLContext::OpenGLContext----start"); initWindow(); m_pWindow->setPosSizePixel(0,0,0,0); @@ -441,6 +445,7 @@ bool OpenGLContext::init( Window* pParent ) #endif SAL_INFO("vcl.opengl", "OpenGLContext::init----end"); + mbInitialized = true; return true; } commit 7ba57762ea2d4e1a126343b0bd6f037bd26c071b Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Mar 31 23:09:24 2014 +0200 Revert "Remove opengl usage from svx until we can't solve building problems" This reverts commit 10be411f33c69db83cc5de410eaddf2d297608ae. diff --git a/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx b/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx index 8781aa4..00e1dff 100644 --- a/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx +++ b/include/svx/sdr/contact/viewobjectcontactofopenglobj.hxx @@ -11,6 +11,7 @@ #define INCLUDED_SVX_SDR_CONTACT_VIEWOBJECTCONTACTOFOPENGL_HXX #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx> +#include <vcl/OpenGLContext.hxx> class Window; @@ -25,6 +26,9 @@ public: protected: Window* getWindow() const; + +private: + OpenGLContext m_aOpenGLContext; }; } // namespace sdr diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index f26479c..b3c3521 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -75,6 +75,7 @@ $(eval $(call gb_Library_use_libraries,svxcore,\ utl \ vcl \ xo \ + $(if $(filter FREEBSD LINUX MACOSX WNT,$(OS)),vclopengl) \ $(gb_UWINAPI) \ )) @@ -82,6 +83,8 @@ $(eval $(call gb_Library_use_externals,svxcore,\ boost_headers \ icuuc \ icu_headers \ + mesa_headers \ + glew \ )) $(eval $(call gb_Library_add_exception_objects,svxcore,\ diff --git a/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx b/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx index 2cf0086..1689468 100644 --- a/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofopenglobj.cxx @@ -18,6 +18,9 @@ ViewObjectContactOfOpenGLObj::ViewObjectContactOfOpenGLObj( ObjectContact& rObjectContact, ViewContact& rViewContact ) : ViewObjectContactOfSdrObj( rObjectContact, rViewContact ) { + m_aOpenGLContext.init(getWindow()); + // Set a dummy size to make the window visible + m_aOpenGLContext.setWinSize(Size(200,200)); } ViewObjectContactOfOpenGLObj::~ViewObjectContactOfOpenGLObj() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits