[Libreoffice-commits] core.git: Branch 'feature/opengl-vcl' - 3 commits - include/vcl vcl/inc vcl/opengl vcl/source vcl/unx
Louis-Francis Ratté-Boulianne
lfrb at collabora.com
Wed Nov 5 07:43:39 PST 2014
include/vcl/opengl/OpenGLHelper.hxx | 10 ++++++++++
include/vcl/outdev.hxx | 2 ++
vcl/inc/generic/genpspgraphics.h | 2 ++
vcl/inc/headless/svpgdi.hxx | 2 ++
vcl/inc/openglgdiimpl.hxx | 2 ++
vcl/inc/quartz/salgdi.h | 2 ++
vcl/inc/salgdi.hxx | 2 ++
vcl/inc/salgdiimpl.hxx | 2 ++
vcl/inc/unx/salgdi.h | 2 ++
vcl/inc/win/salgdi.h | 2 ++
vcl/opengl/gdiimpl.cxx | 6 ++++++
vcl/source/opengl/OpenGLContext.cxx | 14 +++++++++++++-
vcl/source/opengl/OpenGLHelper.cxx | 25 +++++++++++++++++++++++++
vcl/source/outdev/outdev.cxx | 7 +++++++
vcl/source/window/paint.cxx | 2 ++
vcl/unx/generic/app/saldisp.cxx | 8 ++++++++
vcl/unx/generic/gdi/gdiimpl.hxx | 2 ++
vcl/unx/generic/gdi/salgdi.cxx | 5 +++++
18 files changed, 96 insertions(+), 1 deletion(-)
New commits:
commit e5b76797370307085f97f2825ab7ff58b645a220
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Tue Nov 4 17:32:48 2014 -0500
vcl: Add list of contexts sharing the same display list
Change-Id: Ib1bca0aaaf41140d6b9a17378094b0f20e469ebd
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 5e23427..a340304 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -25,6 +25,8 @@
using namespace com::sun::star;
+static std::vector< GLXContext > vShareList;
+
GLWindow::~GLWindow()
{
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
@@ -58,6 +60,8 @@ OpenGLContext::~OpenGLContext()
#elif defined( UNX )
if(m_aGLWin.ctx)
{
+ std::remove( vShareList.begin(), vShareList.end(), m_aGLWin.ctx );
+
glXMakeCurrent(m_aGLWin.dpy, None, NULL);
if( glGetError() != GL_NO_ERROR )
{
@@ -582,13 +586,21 @@ bool OpenGLContext::ImplInit()
#endif
if (!m_aGLWin.ctx)
{
+ GLXContext pSharedCtx( NULL );
+
if (!m_aGLWin.dpy || !m_aGLWin.vi)
return false;
+ if( !vShareList.empty() )
+ pSharedCtx = vShareList.front();
+
m_aGLWin.ctx = m_aGLWin.dpy == 0 ? 0 : glXCreateContext(m_aGLWin.dpy,
m_aGLWin.vi,
- 0,
+ pSharedCtx,
GL_TRUE);
+
+ if( m_aGLWin.ctx )
+ vShareList.push_back( m_aGLWin.ctx );
}
if( m_aGLWin.ctx == NULL )
{
commit 6dca8534b70ef6062a2195d6ee897e3c22bcfd90
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Tue Nov 4 17:31:12 2014 -0500
vcl: Get visual info for window from GLX when needed
Change-Id: Id8cea87391835694e20aa703b7fdb3f13434d47b
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index be2dfda..b237fc8 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -16,6 +16,12 @@
#include <rtl/ustring.hxx>
+#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID
+# include <prex.h>
+# include "GL/glxew.h"
+# include <postx.h>
+#endif
+
class VCLOPENGL_DLLPUBLIC OpenGLHelper
{
public:
@@ -51,6 +57,10 @@ public:
* checks if the system supports all features that are necessary for the OpenGL VCL support
*/
static bool supportsVCLOpenGL();
+
+#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID
+ static bool GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rVI);
+#endif
};
#define CHECK_GL_ERROR() OpenGLHelper::checkGLError(__FILE__, __LINE__)
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 9811b99..d3da56d 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -363,4 +363,29 @@ bool OpenGLHelper::supportsVCLOpenGL()
return true;
}
+#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID
+
+bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rVI)
+{
+ XVisualInfo* pVI;
+ int aAttrib[] = { GLX_RGBA,
+ GLX_RED_SIZE, 8,
+ GLX_GREEN_SIZE, 8,
+ GLX_BLUE_SIZE, 8,
+ GLX_DEPTH_SIZE, 24,
+ GLX_DOUBLEBUFFER,
+ None };
+
+ pVI = glXChooseVisual( pDisplay, nScreen, aAttrib );
+ if( !pVI )
+ return false;
+
+ rVI = *pVI;
+ XFree( pVI );
+
+ return true;
+}
+
+#endif
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index 85d3997..159263a 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -67,10 +67,14 @@
#include <unx/sm.hxx>
#include <unx/wmadaptor.hxx>
+#include <vcl/opengl/OpenGLHelper.hxx>
+
#include <osl/socket.h>
#include <poll.h>
#include <boost/scoped_array.hpp>
+#include <officecfg/Office/Common.hxx>
+
using namespace vcl_sal;
#define SALCOLOR_WHITE MAKE_SALCOLOR( 0xFF, 0xFF, 0xFF )
@@ -187,6 +191,10 @@ bool SalDisplay::BestVisual( Display *pDisplay,
if( nVID && sal_GetVisualInfo( pDisplay, nVID, rVI ) )
return rVI.visualid == nDefVID;
+ bool bUseOpenGL = officecfg::Office::Common::VCL::UseOpenGL::get();
+ if( bUseOpenGL && OpenGLHelper::GetVisualInfo( pDisplay, nScreen, rVI ) )
+ return rVI.visualid == nDefVID;
+
XVisualInfo aVI;
aVI.screen = nScreen;
// get all visuals
commit 8fe7972707b3aef109c4a9041449a4f8d5cdf03f
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Tue Nov 4 17:29:49 2014 -0500
vcl: Add method to swap buffers after painting window
Change-Id: Icdf691e7e9e83d039e33d2095270290dc31f2efa
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 3d5dc3d..5070a5f 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -518,6 +518,8 @@ public:
const Point& rSrcPt, const Size& rSrcSize,
sal_uInt16 nFlags = 0 );
+ virtual bool SwapBuffers();
+
protected:
virtual void CopyDeviceArea( SalTwoRect& aPosAry, sal_uInt32 nFlags);
diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h
index 30c8fec..fb7169a 100644
--- a/vcl/inc/generic/genpspgraphics.h
+++ b/vcl/inc/generic/genpspgraphics.h
@@ -192,6 +192,8 @@ public:
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
+
+ virtual bool SwapBuffers() SAL_OVERRIDE { return false; };
};
#endif // INCLUDED_VCL_INC_GENERIC_GENPSPGRAPHICS_H
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index cbbac7a..cd5622f 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -243,6 +243,8 @@ public:
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
+ virtual bool SwapBuffers() SAL_OVERRIDE { return false; };
+
#ifdef IOS
void SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContext, int = 0 );
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index e8b8947..688a8d9 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -244,6 +244,8 @@ public:
sal_uInt8 nTransparency ) SAL_OVERRIDE;
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE;
+
+ virtual bool swapBuffers() SAL_OVERRIDE;
private:
};
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index eb21e09..caab577 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -394,6 +394,8 @@ public:
GetGraphicsData() const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int /* nFallbacklevel */ ) const SAL_OVERRIDE;
+ virtual bool SwapBuffers() SAL_OVERRIDE { return false; };
+
private:
// differences between VCL, Quartz and kHiThemeOrientation coordinate systems
// make some graphics seem to be vertically-mirrored from a VCL perspective
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 2266d87..a3917bb 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -412,6 +412,8 @@ public:
sal_uInt8 nTransparency,
const OutputDevice *pOutDev );
+ virtual bool SwapBuffers() = 0;
+
virtual SystemGraphicsData GetGraphicsData() const = 0;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const = 0;
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 9802a7b..ba54f9f 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -202,6 +202,8 @@ public:
sal_uInt8 nTransparency ) = 0;
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) = 0;
+
+ virtual bool swapBuffers() = 0;
};
#endif
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 1e90e98..fcb4a9d 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -296,6 +296,8 @@ public:
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
+ virtual bool SwapBuffers() SAL_OVERRIDE;
+
/* use to handle GraphicsExpose/NoExpose after XCopyArea & friends
* if pFrame is not NULL, corresponding Paint events are generated
* and dispatched to pFrame
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 9392cc5..aadd971 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -397,6 +397,8 @@ public:
virtual SystemGraphicsData GetGraphicsData() const;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const;
+ virtual bool SwapBuffers() SAL_OVERRIDE { return false; };
+
/// Update settings based on the platform values
static void updateSettingsNative( AllSettings& rSettings );
};
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index b54f7db..d2e2780 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -854,4 +854,10 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& /*rPolygon*/,
return false;
}
+bool OpenGLSalGraphicsImpl::swapBuffers()
+{
+ maContext.swapBuffers();
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index cd43b51..2ce3762 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -897,4 +897,11 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
return bDrawn;
}
+bool OutputDevice::SwapBuffers()
+{
+ if( !mpGraphics && !AcquireGraphics() )
+ return false;
+ return mpGraphics->SwapBuffers();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index ce10aba..e5cc31a 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -278,6 +278,8 @@ void Window::ImplCallOverlapPaint()
// - RTL - notify ImplCallPaint to check for re-mirroring (CHECKRTL)
// because we were called from the Sal layer
ImplCallPaint( NULL, mpWindowImpl->mnPaintFlags /*| IMPL_PAINT_CHECKRTL */);
+ OutputDevice *pOutDev = GetOutDev();
+ pOutDev->SwapBuffers();
}
}
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index e81d16e..b4fb21c 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -265,6 +265,8 @@ public:
sal_uInt8 nTransparency ) SAL_OVERRIDE;
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE;
+
+ virtual bool swapBuffers() SAL_OVERRIDE { return false; }
};
#endif
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 97e060e..50014d5 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -482,4 +482,9 @@ bool X11SalGraphics::drawGradient(const tools::PolyPolygon& rPoly, const Gradien
return mpImpl->drawGradient(rPoly, rGradient);
}
+bool X11SalGraphics::SwapBuffers()
+{
+ return mpImpl->swapBuffers();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list