[Libreoffice-commits] core.git: include/vcl vcl/headless vcl/inc vcl/opengl vcl/osx vcl/source vcl/unx vcl/win
Caolán McNamara
caolanm at redhat.com
Sat May 21 15:44:19 UTC 2016
include/vcl/opengl/OpenGLContext.hxx | 82 ++---------------------------------
vcl/headless/svpinst.cxx | 4 +
vcl/inc/unx/saldisp.hxx | 19 ++++++++
vcl/inc/win/salgdi.h | 5 ++
vcl/opengl/win/gdiimpl.cxx | 42 +++++++++++++----
vcl/opengl/x11/gdiimpl.cxx | 29 +++++++++++-
vcl/osx/salobj.cxx | 3 +
vcl/source/opengl/OpenGLContext.cxx | 28 +++--------
vcl/unx/generic/window/salframe.cxx | 2
vcl/win/gdi/winlayout.cxx | 13 -----
10 files changed, 105 insertions(+), 122 deletions(-)
New commits:
commit 56d2cab4704f079ca173d65619432665bc1a1c92
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 20 15:20:41 2016 +0100
split GLWindow into platform dependent parts and move to respective backends
Change-Id: I636d9bdac907000e4089aebdc5548ea89ec58083
Reviewed-on: https://gerrit.libreoffice.org/25252
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 10024b3..7b91620 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -14,37 +14,6 @@
#include <GL/glew.h>
-#if defined( MACOSX )
-#elif defined( IOS )
-#elif defined( ANDROID )
-#elif defined( LIBO_HEADLESS )
-#elif defined( UNX )
-# include <X11/Xlib.h>
-# include <X11/Xutil.h>
-# include "GL/glxew.h"
-#elif defined( _WIN32 )
-#ifndef INCLUDED_PRE_POST_WIN_H
-#define INCLUDED_PRE_POST_WIN_H
-# include "prewin.h"
-# include "postwin.h"
-#endif
-#endif
-
-#if defined( _WIN32 )
-#include <GL/wglew.h>
-#elif defined( MACOSX )
-#include <OpenGL/OpenGL.h>
-#ifdef __OBJC__
- at class NSOpenGLView;
-#else
-class NSOpenGLView;
-#endif
-#elif defined( IOS )
-#elif defined( ANDROID )
-#elif defined( LIBO_HEADLESS )
-#elif defined( UNX )
-#endif
-
#include <vcl/dllapi.h>
#include <vcl/window.hxx>
#include <tools/gen.hxx>
@@ -67,57 +36,20 @@ class RenderState;
/// Holds the information of our new child window
struct VCL_DLLPUBLIC GLWindow
{
-#if defined( _WIN32 )
- HWND hWnd;
- HDC hDC;
- HGLRC hRC;
-#elif defined( MACOSX )
-#elif defined( IOS )
-#elif defined( ANDROID )
-#elif defined( LIBO_HEADLESS )
-#elif defined( UNX )
- Display* dpy;
- int screen;
- Window win;
- XVisualInfo* vi;
- GLXContext ctx;
-
- bool HasGLXExtension( const char* name ) const;
- const char* GLXExtensions;
-#endif
unsigned int Width;
unsigned int Height;
- const GLubyte* GLExtensions;
bool bMultiSampleSupported;
GLWindow()
- :
-#if defined( _WIN32 )
- hWnd(NULL),
- hDC(NULL),
- hRC(NULL),
-#elif defined( MACOSX )
-#elif defined( IOS )
-#elif defined( ANDROID )
-#elif defined( LIBO_HEADLESS )
-#elif defined( UNX )
- dpy(nullptr),
- screen(0),
- win(0),
- vi(nullptr),
- ctx(nullptr),
- GLXExtensions(nullptr),
-#endif
- Width(0),
- Height(0),
- GLExtensions(nullptr),
- bMultiSampleSupported(false)
+ : Width(0)
+ , Height(0)
+ , bMultiSampleSupported(false)
{
}
- bool Synchronize(bool bOnoff) const;
+ virtual bool Synchronize(bool bOnoff) const;
- ~GLWindow();
+ virtual ~GLWindow();
};
class VCL_DLLPUBLIC OpenGLContext
@@ -189,7 +121,7 @@ public:
void setWinPosAndSize(const Point &rPos, const Size& rSize);
void setWinSize(const Size& rSize);
- const GLWindow& getOpenGLWindow() const;
+ virtual const GLWindow& getOpenGLWindow() const = 0;
SystemChildWindow* getChildWindow();
const SystemChildWindow* getChildWindow() const;
@@ -212,11 +144,11 @@ private:
virtual void destroyCurrentContext();
protected:
- GLWindow m_aGLWin;
bool InitGLEW();
void InitGLEWDebugging();
void InitChildWindow(SystemChildWindow *pChildWindow);
void BuffersSwapped();
+ virtual GLWindow& getModifiableOpenGLWindow() = 0;
virtual bool ImplInit();
VclPtr<vcl::Window> m_xWindow;
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index 2665bb5..c3aad03 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -447,6 +447,10 @@ void SvpSalInstance::AddToRecentDocumentList(const OUString&, const OUString&, c
//obviously doesn't actually do anything, its just a nonfunctional stub
class SvpOpenGLContext : public OpenGLContext
{
+ GLWindow m_aGLWin;
+private:
+ virtual const GLWindow& getOpenGLWindow() const { return m_aGLWin; }
+ virtual GLWindow& getModifiableOpenGLWindow() { return m_aGLWin; }
};
OpenGLContext* SvpSalInstance::CreateOpenGLContext()
diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx
index e191ebf..426a0d0 100644
--- a/vcl/inc/unx/saldisp.hxx
+++ b/vcl/inc/unx/saldisp.hxx
@@ -28,9 +28,11 @@ class SalXLib;
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xrender.h>
+#include "GL/glxew.h"
#include <unx/salunx.h>
#include <unx/saltype.h>
+#include <vcl/opengl/OpenGLContext.hxx>
#include <vcl/salgtype.hxx>
#include <vcl/ptrstyle.hxx>
#include <sal/types.h>
@@ -184,6 +186,23 @@ extern "C" {
typedef Bool(*X_if_predicate)(Display*,XEvent*,XPointer);
}
+class VCLPLUG_GEN_PUBLIC GLX11Window : public GLWindow
+{
+public:
+ Display* dpy;
+ int screen;
+ Window win;
+ XVisualInfo* vi;
+ GLXContext ctx;
+ const char* GLXExtensions;
+
+ bool HasGLXExtension(const char* name) const;
+
+ GLX11Window();
+ virtual bool Synchronize(bool bOnoff) const override;
+ ~GLX11Window();
+};
+
class VCLPLUG_GEN_PUBLIC SalDisplay : public SalGenericDisplay
{
public:
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 182f666..d2a8162 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -38,6 +38,11 @@
# include <graphite_static.hxx>
# include <graphite2/Font.h>
#endif
+#ifndef INCLUDED_PRE_POST_WIN_H
+#define INCLUDED_PRE_POST_WIN_H
+# include "prewin.h"
+# include "postwin.h"
+#endif
class FontSelectPattern;
class WinFontInstance;
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 50fb392..1f6b044 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -13,15 +13,35 @@
#include <win/saldata.hxx>
#include <win/salframe.h>
#include <win/salinst.h>
+#include <GL/wglew.h>
static std::vector<HGLRC> g_vShareList;
+class GLWinWindow : public GLWindow
+{
+public:
+ HWND hWnd;
+ HDC hDC;
+ HGLRC hRC;
+ GLWinWindow();
+};
+
+GLWinWindow::GLWinWindow()
+ : hWnd(NULL)
+ , hDC(NULL)
+ , hRC(NULL)
+{
+}
+
class WinOpenGLContext : public OpenGLContext
{
public:
bool init( HDC hDC, HWND hWnd );
virtual bool initWindow() override;
private:
+ GLWinWindow m_aGLWin;
+ virtual const GLWindow& getOpenGLWindow() const { return m_aGLWin; }
+ virtual GLWindow& getModifiableOpenGLWindow() { return m_aGLWin; }
virtual bool ImplInit() override;
virtual void makeCurrent() override;
virtual void destroyCurrentContext() override;
@@ -150,7 +170,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
}
}
-int InitTempWindow(HWND *hwnd, int width, int height, const PIXELFORMATDESCRIPTOR& inPfd, GLWindow& glWin)
+int InitTempWindow(HWND *hwnd, int width, int height, const PIXELFORMATDESCRIPTOR& inPfd, GLWinWindow& glWin)
{
OpenGLZone aZone;
@@ -239,7 +259,7 @@ bool InitMultisample(const PIXELFORMATDESCRIPTOR& pfd, int& rPixelFormat,
OpenGLZone aZone;
HWND hWnd = NULL;
- GLWindow glWin;
+ GLWinWindow glWin;
// Create a temp window to check whether support multi-sample, if support, get the format
if (InitTempWindow(&hWnd, 1, 1, pfd, glWin) < 0)
{
@@ -507,15 +527,17 @@ rtl::Reference<OpenGLContext> WinOpenGLSalGraphicsImpl::CreateWinContext()
void WinOpenGLSalGraphicsImpl::Init()
{
- if ( !IsOffscreen() && mpContext.is() && mpContext->isInitialized() &&
- ( mpContext->getOpenGLWindow().hWnd != mrParent.mhWnd ||
- mpContext->getOpenGLWindow().hDC == mrParent.mhLocalDC ) )
+ if (!IsOffscreen() && mpContext.is() && mpContext->isInitialized())
{
- // This can legitimately happen, SalFrame keeps 2x
- // SalGraphics which share the same hWnd and hDC.
- // The shape 'Area' dialog does reparenting to trigger this.
- SAL_WARN("vcl.opengl", "Unusual: Windows handle / DC changed without DeInit");
- DeInit();
+ const GLWinWindow& rGLWindow = static_cast<const GLWinWindow&>(mpContext->getOpenGLWindow());
+ if (rGLWindow.hWnd != mrParent.mhWnd || rGLWindow.hDC == mrParent.mhLocalDC)
+ {
+ // This can legitimately happen, SalFrame keeps 2x
+ // SalGraphics which share the same hWnd and hDC.
+ // The shape 'Area' dialog does reparenting to trigger this.
+ SAL_WARN("vcl.opengl", "Unusual: Windows handle / DC changed without DeInit");
+ DeInit();
+ }
}
OpenGLSalGraphicsImpl::Init();
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index f362605..a4b2a8c 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -39,6 +39,9 @@ public:
bool init(Display* dpy, Window win, int screen);
virtual bool initWindow() override;
private:
+ GLX11Window m_aGLWin;
+ virtual const GLWindow& getOpenGLWindow() const { return m_aGLWin; }
+ virtual GLWindow& getModifiableOpenGLWindow() { return m_aGLWin; }
virtual bool ImplInit() override;
void initGLWindow(Visual* pVisual);
virtual SystemWindowData generateWinData(vcl::Window* pParent, bool bRequestLegacyContext) override;
@@ -362,8 +365,7 @@ bool X11OpenGLContext::ImplInit()
nGLXVersion = glxMajor + 0.1*glxMinor;
SAL_INFO("vcl.opengl", "available GLX version: " << nGLXVersion);
- m_aGLWin.GLExtensions = glGetString( GL_EXTENSIONS );
- SAL_INFO("vcl.opengl", "available GL extensions: " << m_aGLWin.GLExtensions);
+ SAL_INFO("vcl.opengl", "available GL extensions: " << glGetString(GL_EXTENSIONS));
XWindowAttributes aWinAttr;
if( !XGetWindowAttributes( m_aGLWin.dpy, m_aGLWin.win, &aWinAttr ) )
@@ -565,11 +567,32 @@ static GLboolean checkExtension(const GLubyte* extName, const GLubyte* extString
return flag;
}
-bool GLWindow::HasGLXExtension( const char* name ) const
+GLX11Window::GLX11Window()
+ : dpy(nullptr)
+ , screen(0)
+ , win(0)
+ , vi(nullptr)
+ , ctx(nullptr)
+ , GLXExtensions(nullptr)
+{
+}
+
+bool GLX11Window::HasGLXExtension( const char* name ) const
{
return checkExtension( reinterpret_cast<const GLubyte*>(name), reinterpret_cast<const GLubyte*>(GLXExtensions) );
}
+GLX11Window::~GLX11Window()
+{
+ XFree(vi);
+}
+
+bool GLX11Window::Synchronize(bool bOnoff) const
+{
+ XSynchronize(dpy, bOnoff);
+ return true;
+}
+
OpenGLContext* X11SalInstance::CreateOpenGLContext()
{
return new X11OpenGLContext;
diff --git a/vcl/osx/salobj.cxx b/vcl/osx/salobj.cxx
index 6bbb43a..e25c1a1 100644
--- a/vcl/osx/salobj.cxx
+++ b/vcl/osx/salobj.cxx
@@ -236,6 +236,9 @@ class AquaOpenGLContext : public OpenGLContext
public:
virtual bool initWindow() override;
private:
+ GLWindow m_aGLWin;
+ virtual const GLWindow& getOpenGLWindow() const { return m_aGLWin; }
+ virtual GLWindow& getModifiableOpenGLWindow() { return m_aGLWin; }
NSOpenGLView* getOpenGLView();
virtual bool ImplInit() override;
virtual SystemWindowData generateWinData(vcl::Window* pParent, bool bRequestLegacyContext) override;
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index b5e0a30..29e5436 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -41,20 +41,11 @@ static sal_Int64 nBufferSwapCounter = 0;
GLWindow::~GLWindow()
{
-#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
- XFree(vi);
-#endif
}
-bool GLWindow::Synchronize(bool bOnoff) const
+bool GLWindow::Synchronize(bool /*bOnoff*/) const
{
-#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
- XSynchronize(dpy, bOnoff);
- return true;
-#else
- (void)bOnoff;
return false;
-#endif
}
OpenGLContext::OpenGLContext():
@@ -335,8 +326,9 @@ void OpenGLContext::setWinPosAndSize(const Point &rPos, const Size& rSize)
if( m_pChildWindow )
m_pChildWindow->SetPosSizePixel(rPos, rSize);
- m_aGLWin.Width = rSize.Width();
- m_aGLWin.Height = rSize.Height();
+ GLWindow& rGLWin = getModifiableOpenGLWindow();
+ rGLWin.Width = rSize.Width();
+ rGLWin.Height = rSize.Height();
}
void OpenGLContext::setWinSize(const Size& rSize)
@@ -346,8 +338,9 @@ void OpenGLContext::setWinSize(const Size& rSize)
if( m_pChildWindow )
m_pChildWindow->SetSizePixel(rSize);
- m_aGLWin.Width = rSize.Width();
- m_aGLWin.Height = rSize.Height();
+ GLWindow& rGLWin = getModifiableOpenGLWindow();
+ rGLWin.Width = rSize.Width();
+ rGLWin.Height = rSize.Height();
}
void OpenGLContext::InitChildWindow(SystemChildWindow *pChildWindow)
@@ -599,7 +592,7 @@ const SystemChildWindow* OpenGLContext::getChildWindow() const
bool OpenGLContext::supportMultiSampling() const
{
- return m_aGLWin.bMultiSampleSupported;
+ return getOpenGLWindow().bMultiSampleSupported;
}
bool OpenGLContext::BindFramebuffer( OpenGLFramebuffer* pFramebuffer )
@@ -836,9 +829,4 @@ void OpenGLContext::UseNoProgram()
CHECK_GL_ERROR();
}
-const GLWindow& OpenGLContext::getOpenGLWindow() const
-{
- return m_aGLWin;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 2197e38..061abbf 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -891,7 +891,7 @@ X11SalFrame::~X11SalFrame()
rtl::Reference<OpenGLContext> pContext = ImplGetSVData()->maGDIData.mpLastContext;
while( pContext.is() )
{
- if( pContext->getOpenGLWindow().win == mhWindow )
+ if (static_cast<const GLX11Window&>(pContext->getOpenGLWindow()).win == mhWindow)
pContext->reset();
pContext = pContext->mpPrevContext;
}
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 0e39c12..d00a49e 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -2768,19 +2768,6 @@ bool UniscribeLayout::DrawCachedGlyphsUsingGLyphy(SalGraphics& rGraphics) const
rGraphics.GetOpenGLContext()->UseNoProgram();
-#if 0
- HDC hDC = rGraphics.GetOpenGLContext()->getOpenGLWindow().hDC;
- HBITMAP hbitmap = (HBITMAP)GetCurrentObject(hDC, OBJ_BITMAP);
-
- SAL_ DEBUG("hdc=" << hDC << " hbitmap=" << hbitmap);
- if (hbitmap != NULL) {
- BITMAP bm;
- GetObjectW(hbitmap, sizeof(bm), &bm);
- SAL_ DEBUG(" size=" << bm.bmWidth << "x" << bm.bmHeight <<
- " bpp=" << bm.bmBitsPixel);
- }
-#endif
-
glUseProgram( mrWinFontEntry.mnGLyphyProgram );
CHECK_GL_ERROR();
demo_atlas_set_uniforms( mrWinFontEntry.mpGLyphyAtlas );
More information about the Libreoffice-commits
mailing list