summaryrefslogtreecommitdiff
path: root/vcl/unx/generic/gdi/salgdi2.cxx
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-07 17:29:44 -0500
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-11-10 07:59:39 +0100
commit81798ea6e4461f29e35afc14e322d38da5f6c851 (patch)
tree50e8e148f4241da276b2e0bb95d7575e3211a463 /vcl/unx/generic/gdi/salgdi2.cxx
parent1ef180146bf6ed390fb3e6c65da121756a0345d4 (diff)
vcl: Add GetPixmapFromScreen and RenderPixmapToScreen to X11SalGraphics
Change-Id: I007408885b5752f3abf55075ef025aa6dacbabde
Diffstat (limited to 'vcl/unx/generic/gdi/salgdi2.cxx')
-rw-r--r--vcl/unx/generic/gdi/salgdi2.cxx58
1 files changed, 58 insertions, 0 deletions
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 )