summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-13 09:32:41 -0500
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-11-15 12:17:42 +0100
commitec5fa3c9073db79489d8eba1eb8a09029b699e3f (patch)
treeeb55f47971319b8f90bb86ad37430c857fc751ae /vcl/unx
parent7dc6fd3908f752c3552dfe34b1a3da6e485b5fd5 (diff)
vcl: Replace GetPixmapFromScreen by FillPixmapFromScreen
Conflicts: vcl/unx/generic/gdi/gdiimpl.cxx vcl/unx/generic/gdi/salgdi2.cxx Change-Id: I2cb960d194ee5bc38beece97e8b21cc6fa3b3fbc
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/generic/gdi/gdiimpl.cxx16
-rw-r--r--vcl/unx/generic/gdi/gdiimpl.hxx2
-rw-r--r--vcl/unx/generic/gdi/pixmap.cxx54
-rw-r--r--vcl/unx/generic/gdi/salgdi2.cxx4
-rw-r--r--vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx59
5 files changed, 33 insertions, 102 deletions
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index 0088028dfd45..ee7e596fbc95 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -159,19 +159,16 @@ void X11SalGraphicsImpl::Init()
mnBrushPixel = mrParent.GetPixel( mnBrushColor );
}
-X11Pixmap* X11SalGraphicsImpl::GetPixmapFromScreen( const Rectangle& rRect )
+bool X11SalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY )
{
//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 (!aTmpGC)
+ if( !aTmpGC )
{
- delete pPixmap;
- SAL_WARN( "vcl", "Could not get valid GC from screen" );
- return NULL;
+ SAL_WARN( "vcl", "Could not create GC from screen" );
+ return false;
}
// Copy the background of the screen into a composite pixmap
@@ -181,12 +178,11 @@ X11Pixmap* X11SalGraphicsImpl::GetPixmapFromScreen( const Rectangle& rRect )
pPixmap->GetDrawable(), pPixmap->GetScreen(),
pPixmap->GetDepth(),
aTmpGC,
- rRect.Left(), rRect.Top(),
- rRect.GetWidth(), rRect.GetHeight(),
+ nX, nY, pPixmap->GetWidth(), pPixmap->GetHeight(),
0, 0 );
XFreeGC( pDpy, aTmpGC );
- return pPixmap;
+ return true;
}
bool X11SalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY )
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index fed9bc6b9a4b..2d9294a629d9 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -274,7 +274,7 @@ public:
// implementation of X11GraphicsImpl
void Init() SAL_OVERRIDE;
- X11Pixmap* GetPixmapFromScreen( const Rectangle& rRect ) SAL_OVERRIDE;
+ bool FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE;
bool RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE;
};
diff --git a/vcl/unx/generic/gdi/pixmap.cxx b/vcl/unx/generic/gdi/pixmap.cxx
deleted file mode 100644
index 0440c463c2e5..000000000000
--- a/vcl/unx/generic/gdi/pixmap.cxx
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include "unx/pixmap.hxx"
-
-X11Pixmap::X11Pixmap()
-: mpDisplay( NULL )
-, mnScreen( 0 )
-, mpPixmap( 0 )
-, mbDeletePixmap( false )
-, mnWidth( -1 )
-, mnHeight( -1 )
-, mnDepth( 0 )
-{
-}
-
-X11Pixmap::X11Pixmap( Display* pDisplay, SalX11Screen nScreen, int nWidth, int nHeight, int nDepth )
-: mpDisplay( pDisplay )
-, mnScreen( nScreen )
-, mbDeletePixmap( true )
-, mnWidth( nWidth )
-, mnHeight( nHeight )
-, mnDepth( nDepth )
-{
- Window root = RootWindow( pDisplay, 0 );
- mpPixmap = XCreatePixmap( pDisplay, root, nWidth, nHeight, nDepth );
-}
-
-X11Pixmap::X11Pixmap( X11Pixmap& rOther )
-: mpDisplay( rOther.mpDisplay )
-, mnScreen( rOther.mnScreen )
-, mbDeletePixmap( rOther.mbDeletePixmap )
-, mnWidth( rOther.mnWidth )
-, mnHeight( rOther.mnHeight )
-, mnDepth( rOther.mnDepth )
-{
- mpPixmap = rOther.mpPixmap;
- rOther.mpPixmap = 0;
- rOther.mbDeletePixmap = false;
-}
-
-X11Pixmap::~X11Pixmap()
-{
- if (mbDeletePixmap && mpPixmap)
- XFreePixmap( mpDisplay, mpPixmap );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index 768e5967e323..9ef50b87c747 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -83,10 +83,10 @@ void X11SalGraphics::CopyScreenArea( Display* pDisplay,
}
}
-X11Pixmap* X11SalGraphics::GetPixmapFromScreen( const Rectangle& rRect )
+bool X11SalGraphics::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY )
{
X11GraphicsImpl& rImpl = dynamic_cast<X11GraphicsImpl&>(*mpImpl.get());
- return rImpl.GetPixmapFromScreen( rRect );
+ return rImpl.FillPixmapFromScreen( pPixmap, nX, nY );
}
bool X11SalGraphics::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY )
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index 9c11cd914940..10cff1043e4e 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -269,49 +269,44 @@ class GdkX11Pixmap : public X11Pixmap
{
public:
GdkX11Pixmap( int nWidth, int nHeight, int nDepth );
- GdkX11Pixmap( X11Pixmap& rOther, GdkWindow *pWindow );
virtual ~GdkX11Pixmap();
- GdkPixmap* GetGdkPixmap() const;
- GdkDrawable* GetGdkDrawable() const;
+ virtual int GetDepth() const SAL_OVERRIDE;
+ virtual SalX11Screen GetScreen() const SAL_OVERRIDE;
+ virtual Pixmap GetPixmap() const SAL_OVERRIDE;
+ GdkPixmap* GetGdkPixmap() const;
+ GdkDrawable* GetGdkDrawable() const;
protected:
GdkPixmap* mpGdkPixmap;
+ int mnDepth;
};
GdkX11Pixmap::GdkX11Pixmap( int nWidth, int nHeight, int nDepth )
+: X11Pixmap( nWidth, nHeight )
+, mnDepth( nDepth )
{
mpGdkPixmap = gdk_pixmap_new( NULL, nWidth, nHeight, nDepth );
-
- //mpDisplay = ?
- mnScreen = SalX11Screen( gdk_screen_get_number( gdk_drawable_get_screen( GDK_DRAWABLE(mpGdkPixmap) ) ) );
- mnWidth = nWidth;
- mnHeight = nHeight;
- mnDepth = nDepth;
- mpPixmap = GDK_PIXMAP_XID( mpGdkPixmap );
}
-GdkX11Pixmap::GdkX11Pixmap( X11Pixmap& rOther, GdkWindow *pWindow )
- : X11Pixmap(rOther)
+GdkX11Pixmap::~GdkX11Pixmap()
{
- GdkColormap* pColormap;
+ g_object_unref( mpGdkPixmap );
+}
-#if GTK_CHECK_VERSION(2,24,0)
- GdkScreen *pScreen = gdk_window_get_screen( pWindow );
- mpGdkPixmap = gdk_pixmap_foreign_new_for_screen( pScreen, mpPixmap,
- mnWidth, mnHeight,
- mnDepth );
-#else
- mpGdkPixmap = gdk_pixmap_foreign_new( mpPixmap );
-#endif
+int GdkX11Pixmap::GetDepth() const
+{
+ return mnDepth;
+}
- pColormap = gdk_drawable_get_colormap( pWindow );
- gdk_drawable_set_colormap( GDK_DRAWABLE (mpGdkPixmap), pColormap );
+SalX11Screen GdkX11Pixmap::GetScreen() const
+{
+ return SalX11Screen( gdk_screen_get_number( gdk_drawable_get_screen( GDK_DRAWABLE(mpGdkPixmap) ) ) );
}
-GdkX11Pixmap::~GdkX11Pixmap()
+Pixmap GdkX11Pixmap::GetPixmap() const
{
- g_object_unref( mpGdkPixmap );
+ return GDK_PIXMAP_XID( mpGdkPixmap );
}
GdkPixmap* GdkX11Pixmap::GetGdkPixmap() const
@@ -4135,17 +4130,11 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
GdkX11Pixmap* GtkSalGraphics::NWGetPixmapFromScreen( Rectangle srcRect )
{
- X11Pixmap* pPixmap;
- GdkX11Pixmap* pResult;
-
- pPixmap = GetPixmapFromScreen( srcRect );
- if( pPixmap == NULL )
- return NULL;
-
- pResult = new GdkX11Pixmap( *pPixmap, GetGdkWindow() );
- delete pPixmap;
+ GdkX11Pixmap* pPixmap;
- return pResult;
+ pPixmap = new GdkX11Pixmap( srcRect.GetWidth(), srcRect.GetHeight(), 24 );
+ FillPixmapFromScreen( pPixmap, srcRect.Left(), srcRect.Top() );
+ return pPixmap;
}
/************************************************************************