[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/opengl vcl/source vcl/unx
Caolán McNamara
caolanm at redhat.com
Sat May 21 09:05:26 UTC 2016
include/vcl/opengl/OpenGLHelper.hxx | 11 ----
vcl/inc/unx/saldisp.hxx | 5 --
vcl/opengl/x11/gdiimpl.cxx | 64 ++++++++++++++++++++++++++-
vcl/source/opengl/OpenGLHelper.cxx | 85 ------------------------------------
vcl/unx/generic/app/saldisp.cxx | 29 +++++++++++-
5 files changed, 92 insertions(+), 102 deletions(-)
New commits:
commit 5d4e68d51eecfbe37e17f59cc7f7f042c69a65e9
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 20 14:16:09 2016 +0100
move glX stuff to X-only modules
Change-Id: I8ca818dac72f0368b6af10c838603e63c7c85b1e
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 87d3fe3..b2989b8 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -17,12 +17,6 @@
#include <rtl/ustring.hxx>
-#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
-# include <X11/Xlib.h>
-# include <X11/Xutil.h>
-# include "GL/glxew.h"
-#endif
-
/// Helper to do a SAL_INFO as well as a GL log.
#define VCL_GL_INFO(stream) \
do { \
@@ -100,11 +94,6 @@ public:
* Returns true if VCL has OpenGL rendering enabled
*/
static bool isVCLOpenGLEnabled();
-
-#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
- static bool GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rVI);
- static GLXFBConfig GetPixmapFBConfig( Display* pDisplay, bool& bInverted );
-#endif
};
#ifdef SAL_LOG_WARN
diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx
index 547fdf2..e191ebf 100644
--- a/vcl/inc/unx/saldisp.hxx
+++ b/vcl/inc/unx/saldisp.hxx
@@ -279,9 +279,8 @@ protected:
void doDestruct();
void addXineramaScreenUnique( int i, long i_nX, long i_nY, long i_nWidth, long i_nHeight );
public:
- static bool BestVisual( Display *pDisp,
- int nScreen,
- XVisualInfo &rVI );
+ static bool BestOpenGLVisual(Display* pDisplay, int nScreen, XVisualInfo& rVI);
+ static bool BestVisual(Display *pDisp, int nScreen, XVisualInfo &rVI);
SalDisplay( Display* pDisp );
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 1137a3a..105cda3 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -623,7 +623,7 @@ bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX,
SAL_INFO( "vcl.opengl", "FillPixmapFromScreen" );
- if( !OpenGLHelper::GetVisualInfo( pDisplay, nScreen.getXScreen(), aVisualInfo ) )
+ if (!SalDisplay::BestOpenGLVisual(pDisplay, nScreen.getXScreen(), aVisualInfo))
return false;
// make sure everything is synced up before reading back
@@ -655,6 +655,66 @@ typedef o3tl::lru_map<ControlCacheKey, std::unique_ptr<TextureCombo>, ControlCac
vcl::DeleteOnDeinit<ControlCacheType> gTextureCache(new ControlCacheType(200));
+namespace
+{
+ GLXFBConfig GetPixmapFBConfig( Display* pDisplay, bool& bInverted )
+ {
+ OpenGLZone aZone;
+
+ int nScreen = DefaultScreen( pDisplay );
+ GLXFBConfig *aFbConfigs;
+ int i, nFbConfigs, nValue;
+
+ aFbConfigs = glXGetFBConfigs( pDisplay, nScreen, &nFbConfigs );
+ for( i = 0; i < nFbConfigs; i++ )
+ {
+ glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_DRAWABLE_TYPE, &nValue );
+ if( !(nValue & GLX_PIXMAP_BIT) )
+ continue;
+
+ glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &nValue );
+ if( !(nValue & GLX_TEXTURE_2D_BIT_EXT) )
+ continue;
+
+ glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_DEPTH_SIZE, &nValue );
+ if( nValue != 24 )
+ continue;
+
+ glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_RED_SIZE, &nValue );
+ if( nValue != 8 )
+ continue;
+ SAL_INFO( "vcl.opengl", "Red is " << nValue );
+
+ // TODO: lfrb: Make it configurable wrt RGB/RGBA
+ glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_BIND_TO_TEXTURE_RGB_EXT, &nValue );
+ if( nValue == False )
+ {
+ glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_BIND_TO_TEXTURE_RGBA_EXT, &nValue );
+ if( nValue == False )
+ continue;
+ }
+
+ glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_Y_INVERTED_EXT, &nValue );
+
+ // Looks like that X sends GLX_DONT_CARE but this usually means "true" for most
+ // of the X implementations. Investigation on internet pointed that this could be
+ // safely "true" all the time (for example gnome-shell always assumes "true").
+ bInverted = nValue == True || nValue == int(GLX_DONT_CARE);
+
+ break;
+ }
+
+ if( i == nFbConfigs )
+ {
+ SAL_WARN( "vcl.opengl", "Unable to find FBconfig for pixmap texturing" );
+ return nullptr;
+ }
+
+ CHECK_GL_ERROR();
+ return aFbConfigs[i];
+ }
+}
+
bool X11OpenGLSalGraphicsImpl::RenderPixmap(X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY, TextureCombo& rCombo)
{
const int aAttribs[] =
@@ -675,7 +735,7 @@ bool X11OpenGLSalGraphicsImpl::RenderPixmap(X11Pixmap* pPixmap, X11Pixmap* pMask
//glClear( GL_COLOR_BUFFER_BIT );
XSync( pDisplay, 0 );
- GLXFBConfig pFbConfig = OpenGLHelper::GetPixmapFBConfig( pDisplay, bInverted );
+ GLXFBConfig pFbConfig = GetPixmapFBConfig( pDisplay, bInverted );
GLXPixmap pGlxPixmap = glXCreatePixmap( pDisplay, pFbConfig, pPixmap->GetPixmap(), aAttribs);
GLXPixmap pGlxMask;
if( pMask != nullptr )
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 47fe8fe..e6ea3a1 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -1062,91 +1062,6 @@ void OpenGLHelper::debugMsgPrint(const char *pFormat, ...)
va_end (aArgs);
}
-#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
-
-bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rVI)
-{
- OpenGLZone aZone;
-
- XVisualInfo* pVI;
- int aAttrib[] = { GLX_RGBA,
- GLX_RED_SIZE, 8,
- GLX_GREEN_SIZE, 8,
- GLX_BLUE_SIZE, 8,
- GLX_DEPTH_SIZE, 24,
- GLX_STENCIL_SIZE, 8,
- None };
-
- pVI = glXChooseVisual( pDisplay, nScreen, aAttrib );
- if( !pVI )
- return false;
-
- rVI = *pVI;
- XFree( pVI );
-
- CHECK_GL_ERROR();
- return true;
-}
-
-GLXFBConfig OpenGLHelper::GetPixmapFBConfig( Display* pDisplay, bool& bInverted )
-{
- OpenGLZone aZone;
-
- int nScreen = DefaultScreen( pDisplay );
- GLXFBConfig *aFbConfigs;
- int i, nFbConfigs, nValue;
-
- aFbConfigs = glXGetFBConfigs( pDisplay, nScreen, &nFbConfigs );
- for( i = 0; i < nFbConfigs; i++ )
- {
- glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_DRAWABLE_TYPE, &nValue );
- if( !(nValue & GLX_PIXMAP_BIT) )
- continue;
-
- glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &nValue );
- if( !(nValue & GLX_TEXTURE_2D_BIT_EXT) )
- continue;
-
- glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_DEPTH_SIZE, &nValue );
- if( nValue != 24 )
- continue;
-
- glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_RED_SIZE, &nValue );
- if( nValue != 8 )
- continue;
- SAL_INFO( "vcl.opengl", "Red is " << nValue );
-
- // TODO: lfrb: Make it configurable wrt RGB/RGBA
- glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_BIND_TO_TEXTURE_RGB_EXT, &nValue );
- if( nValue == False )
- {
- glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_BIND_TO_TEXTURE_RGBA_EXT, &nValue );
- if( nValue == False )
- continue;
- }
-
- glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_Y_INVERTED_EXT, &nValue );
-
- // Looks like that X sends GLX_DONT_CARE but this usually means "true" for most
- // of the X implementations. Investigation on internet pointed that this could be
- // safely "true" all the time (for example gnome-shell always assumes "true").
- bInverted = nValue == True || nValue == int(GLX_DONT_CARE);
-
- break;
- }
-
- if( i == nFbConfigs )
- {
- SAL_WARN( "vcl.opengl", "Unable to find FBconfig for pixmap texturing" );
- return nullptr;
- }
-
- CHECK_GL_ERROR();
- return aFbConfigs[i];
-}
-
-#endif
-
OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
: pHandle( nullptr )
{
diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index dd5ce04..ec53250 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -47,6 +47,9 @@
#include <X11/extensions/Xinerama.h>
#endif
+#include "GL/glxew.h"
+#include <opengl/zone.hxx>
+
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
@@ -183,6 +186,30 @@ sal_GetServerVendor( Display *p_display )
return vendor_unknown;
}
+bool SalDisplay::BestOpenGLVisual(Display* pDisplay, int nScreen, XVisualInfo& rVI)
+{
+ OpenGLZone aZone;
+
+ XVisualInfo* pVI;
+ int aAttrib[] = { GLX_RGBA,
+ GLX_RED_SIZE, 8,
+ GLX_GREEN_SIZE, 8,
+ GLX_BLUE_SIZE, 8,
+ GLX_DEPTH_SIZE, 24,
+ GLX_STENCIL_SIZE, 8,
+ None };
+
+ pVI = glXChooseVisual( pDisplay, nScreen, aAttrib );
+ if( !pVI )
+ return false;
+
+ rVI = *pVI;
+ XFree( pVI );
+
+ CHECK_GL_ERROR();
+ return true;
+}
+
bool SalDisplay::BestVisual( Display *pDisplay,
int nScreen,
XVisualInfo &rVI )
@@ -198,7 +225,7 @@ bool SalDisplay::BestVisual( Display *pDisplay,
try {
bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled();
- if( bUseOpenGL && OpenGLHelper::GetVisualInfo( pDisplay, nScreen, rVI ) )
+ if (bUseOpenGL && BestOpenGLVisual(pDisplay, nScreen, rVI))
return rVI.visualid == nDefVID;
}
catch (const css::uno::DeploymentException&)
More information about the Libreoffice-commits
mailing list