From 81798ea6e4461f29e35afc14e322d38da5f6c851 Mon Sep 17 00:00:00 2001 From: Louis-Francis Ratté-Boulianne Date: Fri, 7 Nov 2014 17:29:44 -0500 Subject: vcl: Add GetPixmapFromScreen and RenderPixmapToScreen to X11SalGraphics Change-Id: I007408885b5752f3abf55075ef025aa6dacbabde --- vcl/unx/generic/gdi/salgdi2.cxx | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'vcl/unx/generic/gdi/salgdi2.cxx') diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx index aa2732a4ba8f..e4d5b3c349e5 100644 --- a/vcl/unx/generic/gdi/salgdi2.cxx +++ b/vcl/unx/generic/gdi/salgdi2.cxx @@ -23,6 +23,7 @@ #include "vcl/salbtype.hxx" +#include "unx/pixmap.hxx" #include "unx/salunx.h" #include "unx/saldata.hxx" #include "unx/saldisp.hxx" @@ -81,6 +82,63 @@ 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; +} + +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; +} + extern "C" { static Bool GraphicsExposePredicate( Display*, XEvent* pEvent, XPointer pFrameWindow ) -- cgit