diff options
author | Louis-Francis Ratté-Boulianne <lfrb@collabora.com> | 2014-11-08 13:14:14 -0500 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-11-10 07:59:40 +0100 |
commit | 4007df6cc8fc3f2a3a634d9530b6652381d5ba53 (patch) | |
tree | 3b20e2e46996c215a0b03de08687711faf542693 /vcl/unx/generic/gdi | |
parent | 81798ea6e4461f29e35afc14e322d38da5f6c851 (diff) |
vcl: Initial work to have native widgets rendered with OpenGL
Change-Id: I8b244a5bdd12a64a65ca1bab14dfe6917a175ccf
Diffstat (limited to 'vcl/unx/generic/gdi')
-rw-r--r-- | vcl/unx/generic/gdi/gdiimpl.cxx | 61 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/gdiimpl.hxx | 16 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salgdi.cxx | 26 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salgdi2.cxx | 53 |
4 files changed, 75 insertions, 81 deletions
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx index f2ccf9080251..172ebd6314fb 100644 --- a/vcl/unx/generic/gdi/gdiimpl.cxx +++ b/vcl/unx/generic/gdi/gdiimpl.cxx @@ -153,16 +153,69 @@ X11SalGraphicsImpl::~X11SalGraphicsImpl() { } -void X11SalGraphicsImpl::Init( SalFrame* /*pFrame*/ ) +void X11SalGraphicsImpl::Init() { mnPenPixel = mrParent.GetPixel( mnPenColor ); mnBrushPixel = mrParent.GetPixel( mnBrushColor ); } -void X11SalGraphicsImpl::Init( SalVirtualDevice* /*pVDev*/ ) +X11Pixmap* X11SalGraphicsImpl::GetPixmapFromScreen( const Rectangle& rRect ) { - mnPenPixel = mrParent.GetPixel( mnPenColor ); - mnBrushPixel = mrParent.GetPixel( mnBrushColor ); + //TODO lfrb: don't hardcode the depth + Display* pDpy = mrParent.GetXDisplay(); + X11Pixmap* pPixmap = new X11Pixmap( pDpy, mrParent.GetScreenNumber(), + rRect.GetWidth(), rRect.GetHeight(), 24 ); + GC aTmpGC = XCreateGC( pDpy, pPixmap->GetPixmap(), 0, NULL ); + + if( !pPixmap || !aTmpGC ) + { + if ( pPixmap ) + delete pPixmap; + if ( aTmpGC ) + XFreeGC( pDpy, aTmpGC ); + SAL_WARN( "vcl", "Could not get valid pixmap from screen" ); + return NULL; + } + + // Copy the background of the screen into a composite pixmap + mrParent.CopyScreenArea( mrParent.GetXDisplay(), + mrParent.GetDrawable(), mrParent.GetScreenNumber(), + mrParent.GetVisual().GetDepth(), + pPixmap->GetDrawable(), pPixmap->GetScreen(), + pPixmap->GetDepth(), + aTmpGC, + rRect.Left(), rRect.Top(), + rRect.GetWidth(), rRect.GetHeight(), + 0, 0 ); + + XFreeGC( pDpy, aTmpGC ); + return pPixmap; +} + +bool X11SalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) +{ + GC aFontGC = mrParent.GetFontGC(); + + // The GC can't be null, otherwise we'd have no clip region + if( aFontGC == NULL ) + { + SAL_WARN( "vcl", "no valid GC to render pixmap" ); + return false; + } + + if( !pPixmap ) + return false; + + mrParent.CopyScreenArea( mrParent.GetXDisplay(), + pPixmap->GetDrawable(), pPixmap->GetScreen(), + pPixmap->GetDepth(), + mrParent.GetDrawable(), mrParent.m_nXScreen, + mrParent.GetVisual().GetDepth(), + aFontGC, + 0, 0, + pPixmap->GetWidth(), pPixmap->GetHeight(), + nX, nY ); + return true; } XID X11SalGraphicsImpl::GetXRenderPicture() diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx index 799e05c9c607..252fe358f505 100644 --- a/vcl/unx/generic/gdi/gdiimpl.hxx +++ b/vcl/unx/generic/gdi/gdiimpl.hxx @@ -24,6 +24,7 @@ #include <postx.h> #include "unx/saltype.h" +#include "unx/x11/x11gdiimpl.h" #include "salgdiimpl.hxx" @@ -35,10 +36,8 @@ class SalPolyLine; class X11SalGraphics; class Gradient; -class X11SalGraphicsImpl : public SalGraphicsImpl +class X11SalGraphicsImpl : public SalGraphicsImpl, public X11GraphicsImpl { - friend X11SalGraphics; - private: X11SalGraphics& mrParent; @@ -108,10 +107,6 @@ public: virtual ~X11SalGraphicsImpl(); - virtual void Init( SalFrame* pFrame ) SAL_OVERRIDE; - - virtual void Init( SalVirtualDevice* pVDev ) SAL_OVERRIDE; - virtual bool setClipRegion( const vcl::Region& ) SAL_OVERRIDE; // // get the depth of the device @@ -269,6 +264,13 @@ public: virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE; virtual bool swapBuffers() SAL_OVERRIDE { return false; } + +public: + // implementation of X11GraphicsImpl + + void Init() SAL_OVERRIDE; + X11Pixmap* GetPixmapFromScreen( const Rectangle& rRect ) SAL_OVERRIDE; + bool RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE; }; #endif diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx index 0607cac223af..b4df486b78f4 100644 --- a/vcl/unx/generic/gdi/salgdi.cxx +++ b/vcl/unx/generic/gdi/salgdi.cxx @@ -48,13 +48,14 @@ #include "unx/salgdi.h" #include "unx/salframe.h" #include "unx/salvd.h" +#include "unx/x11/x11gdiimpl.h" #include <unx/x11/xlimits.hxx> #include "salgdiimpl.hxx" #include "unx/x11windowprovider.hxx" #include "textrender.hxx" #include "gdiimpl.hxx" -#include "openglgdiimpl.hxx" +#include "opengl/x11/gdiimpl.hxx" #include "x11cairotextrender.hxx" #include "generic/printergfx.hxx" @@ -86,7 +87,7 @@ X11SalGraphics::X11SalGraphics(): static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL(); bool bUseOpenGL = bOpenGLPossible ? officecfg::Office::Common::VCL::UseOpenGL::get() : false; if (bUseOpenGL) - mpImpl.reset(new OpenGLSalGraphicsImpl()); + mpImpl.reset(new X11OpenGLSalGraphicsImpl(*this)); else mpImpl.reset(new X11SalGraphicsImpl(*this)); @@ -142,26 +143,7 @@ void X11SalGraphics::SetDrawable( Drawable aDrawable, SalX11Screen nXScreen ) if( hDrawable_ ) { - OpenGLSalGraphicsImpl* pOpenGLImpl = dynamic_cast<OpenGLSalGraphicsImpl*>(mpImpl.get()); - if (pOpenGLImpl) - { - if (m_pFrame && dynamic_cast<X11WindowProvider*>(m_pFrame)) - { - Window aWin = dynamic_cast<X11WindowProvider*>(m_pFrame)->GetX11Window(); - pOpenGLImpl->GetOpenGLContext().init(GetXDisplay(), - aWin, m_nXScreen.getXScreen()); - mpImpl->Init( m_pFrame ); - } - else if (m_pVDev) - { - pOpenGLImpl->GetOpenGLContext().init(GetXDisplay(), - m_pVDev->GetDrawable(), m_pVDev->GetWidth(), m_pVDev->GetHeight(), m_nXScreen.getXScreen()); - mpImpl->Init(m_pVDev); - } - else - SAL_WARN("vcl.opengl", "what happened here?"); - } - + dynamic_cast<X11GraphicsImpl*>(mpImpl.get())->Init(); // TODO: moggi: FIXME nTextPixel_ = GetPixel( nTextColor_ ); } } diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx index e4d5b3c349e5..63ab32b8981d 100644 --- a/vcl/unx/generic/gdi/salgdi2.cxx +++ b/vcl/unx/generic/gdi/salgdi2.cxx @@ -31,6 +31,7 @@ #include "unx/salgdi.h" #include "unx/salframe.h" #include "unx/salvd.h" +#include "unx/x11/x11gdiimpl.h" #include <unx/x11/xlimits.hxx> #include "xrender_peer.hxx" @@ -84,59 +85,15 @@ void X11SalGraphics::CopyScreenArea( Display* pDisplay, X11Pixmap* X11SalGraphics::GetPixmapFromScreen( const Rectangle& rRect ) { - Display* pDpy = GetXDisplay(); - X11Pixmap* pPixmap = new X11Pixmap( pDpy, GetScreenNumber(), rRect.GetWidth(), rRect.GetHeight(), 24 ); - GC aTmpGC = XCreateGC( pDpy, pPixmap->GetPixmap(), 0, NULL ); - - if( !pPixmap || !aTmpGC ) - { - if ( pPixmap ) - delete pPixmap; - if ( aTmpGC ) - XFreeGC( pDpy, aTmpGC ); - SAL_WARN( "vcl", "Could not get valid pixmap from screen" ); - return NULL; - } - - // Copy the background of the screen into a composite pixmap - CopyScreenArea( GetXDisplay(), - GetDrawable(), GetScreenNumber(), GetVisual().GetDepth(), - pPixmap->GetDrawable(), pPixmap->GetScreen(), pPixmap->GetDepth(), - aTmpGC, - rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight(), 0, 0 ); - - XFreeGC( pDpy, aTmpGC ); - return pPixmap; + X11GraphicsImpl* pImpl = dynamic_cast<X11GraphicsImpl*>(mpImpl.get()); + return pImpl->GetPixmapFromScreen( rRect ); } bool X11SalGraphics::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) { SAL_INFO( "vcl", "RenderPixmapToScreen" ); - /*if( UseOpenGL() ) - { - X11OpenGLTexture pTexture( pPixmap ); - pTexture.Draw( nX, nY ); - return true; - }*/ - - GC aFontGC = GetFontGC(); - - // The GC can't be null, otherwise we'd have no clip region - if( aFontGC == NULL ) - { - SAL_WARN( "vcl", "no valid GC to render pixmap" ); - return false; - } - - if( !pPixmap ) - return false; - - CopyScreenArea( GetXDisplay(), - pPixmap->GetDrawable(), pPixmap->GetScreen(), pPixmap->GetDepth(), - GetDrawable(), m_nXScreen, GetVisual().GetDepth(), - aFontGC, - 0, 0, pPixmap->GetWidth(), pPixmap->GetHeight(), nX, nY ); - return true; + X11GraphicsImpl* pImpl = dynamic_cast<X11GraphicsImpl*>(mpImpl.get()); + return pImpl->RenderPixmapToScreen( pPixmap, nX, nY ); } extern "C" |