diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-05-20 15:20:41 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-05-21 15:43:56 +0000 |
commit | 56d2cab4704f079ca173d65619432665bc1a1c92 (patch) | |
tree | 18fc983d726c2ad5e77bceb78df4dc7abae54c8a /vcl | |
parent | 29428a5979ecf37eca7eb690a6acbc2897122753 (diff) |
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@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/headless/svpinst.cxx | 4 | ||||
-rw-r--r-- | vcl/inc/unx/saldisp.hxx | 19 | ||||
-rw-r--r-- | vcl/inc/win/salgdi.h | 5 | ||||
-rw-r--r-- | vcl/opengl/win/gdiimpl.cxx | 42 | ||||
-rw-r--r-- | vcl/opengl/x11/gdiimpl.cxx | 29 | ||||
-rw-r--r-- | vcl/osx/salobj.cxx | 3 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 28 | ||||
-rw-r--r-- | vcl/unx/generic/window/salframe.cxx | 2 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 13 |
9 files changed, 98 insertions, 47 deletions
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 2665bb509d70..c3aad0395345 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 e191ebfa3ae5..426a0d028d7d 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 182f666855f8..d2a81624cb4a 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 50fb3928600e..1f6b044d9a64 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 f3626050f888..a4b2a8c9757f 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 6bbb43aa51a8..e25c1a1d1694 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 b5e0a305d9f6..29e543611bf3 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 2197e3824e78..061abbf9dff7 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 0e39c121c1c7..d00a49e59c71 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 ); |