diff options
author | Louis-Francis Ratté-Boulianne <lfrb@collabora.com> | 2014-11-13 09:32:41 -0500 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-11-15 12:17:42 +0100 |
commit | ec5fa3c9073db79489d8eba1eb8a09029b699e3f (patch) | |
tree | eb55f47971319b8f90bb86ad37430c857fc751ae | |
parent | some formatting improvements (diff) | |
download | core-ec5fa3c9073db79489d8eba1eb8a09029b699e3f.tar.gz core-ec5fa3c9073db79489d8eba1eb8a09029b699e3f.zip |
vcl: Replace GetPixmapFromScreen by FillPixmapFromScreen
Conflicts:
vcl/unx/generic/gdi/gdiimpl.cxx
vcl/unx/generic/gdi/salgdi2.cxx
Change-Id: I2cb960d194ee5bc38beece97e8b21cc6fa3b3fbc
-rw-r--r-- | vcl/Library_vclplug_gen.mk | 1 | ||||
-rw-r--r-- | vcl/inc/opengl/x11/gdiimpl.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/pixmap.hxx | 24 | ||||
-rw-r--r-- | vcl/inc/unx/salgdi.h | 4 | ||||
-rw-r--r-- | vcl/inc/unx/x11/x11gdiimpl.h | 2 | ||||
-rw-r--r-- | vcl/opengl/x11/gdiimpl.cxx | 19 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/gdiimpl.cxx | 16 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/gdiimpl.hxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/pixmap.cxx | 54 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salgdi2.cxx | 4 | ||||
-rw-r--r-- | vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx | 59 |
11 files changed, 56 insertions, 131 deletions
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk index 73e5d010e597..76be2c1e2cf1 100644 --- a/vcl/Library_vclplug_gen.mk +++ b/vcl/Library_vclplug_gen.mk @@ -94,7 +94,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\ vcl/unx/generic/gdi/x11cairotextrender \ vcl/unx/generic/gdi/gcach_xpeer \ vcl/unx/generic/gdi/gdiimpl \ - vcl/unx/generic/gdi/pixmap \ vcl/unx/generic/gdi/openglx11cairotextrender \ vcl/unx/generic/gdi/salbmp \ vcl/unx/generic/gdi/salgdi2 \ diff --git a/vcl/inc/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx index 878c7c2f054e..00eaf8cdf9c2 100644 --- a/vcl/inc/opengl/x11/gdiimpl.hxx +++ b/vcl/inc/opengl/x11/gdiimpl.hxx @@ -33,7 +33,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/inc/unx/pixmap.hxx b/vcl/inc/unx/pixmap.hxx index b65170fe29bc..ec3c9321a611 100644 --- a/vcl/inc/unx/pixmap.hxx +++ b/vcl/inc/unx/pixmap.hxx @@ -19,27 +19,25 @@ class VCLPLUG_GEN_PUBLIC X11Pixmap { public: - X11Pixmap(); - X11Pixmap( Display *pDisplay, SalX11Screen nScreen, int nWidth, int nHeight, int nDepth ); - X11Pixmap( X11Pixmap& rOther ); - virtual ~X11Pixmap(); + X11Pixmap( int nWidth, int nHeight ) + { + mnWidth = nWidth; + mnHeight = nHeight; + } - Pixmap GetPixmap() const { return mpPixmap; }; - Drawable GetDrawable() const { return mpPixmap; }; + virtual ~X11Pixmap() {}; + + virtual int GetDepth() const = 0; + virtual SalX11Screen GetScreen() const = 0; + virtual Pixmap GetPixmap() const = 0; + Drawable GetDrawable() const { return GetPixmap(); }; int GetWidth() const { return mnWidth; }; int GetHeight() const { return mnHeight; }; Size GetSize() const { return Size( mnWidth, mnHeight ); }; - int GetDepth() const { return mnDepth; }; - SalX11Screen GetScreen() const { return mnScreen; } protected: - Display* mpDisplay; - SalX11Screen mnScreen; - Pixmap mpPixmap; - bool mbDeletePixmap; int mnWidth; int mnHeight; - int mnDepth; }; #endif // INCLUDED_VCL_INC_UNX_PIXMAP_HXX diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index f693ed137db1..f14eab60f8ed 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -273,8 +273,8 @@ public: virtual void BeginPaint() SAL_OVERRIDE; virtual void EndPaint() SAL_OVERRIDE; - // create a pixmap from a screen region - X11Pixmap* GetPixmapFromScreen( const Rectangle& rRect ); + // fill a pixmap from a screen region + bool FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY ); // render a pixmap to the screen bool RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ); diff --git a/vcl/inc/unx/x11/x11gdiimpl.h b/vcl/inc/unx/x11/x11gdiimpl.h index 911ea71e8ed3..8cd130d583a0 100644 --- a/vcl/inc/unx/x11/x11gdiimpl.h +++ b/vcl/inc/unx/x11/x11gdiimpl.h @@ -18,7 +18,7 @@ public: virtual ~X11GraphicsImpl() {}; virtual void Init() = 0; - virtual X11Pixmap* GetPixmapFromScreen( const Rectangle& rRect ) = 0; + virtual bool FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY ) = 0; virtual bool RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) = 0; }; diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx index 6a16b9f92798..3d242ac5719e 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -80,42 +80,39 @@ void X11OpenGLSalGraphicsImpl::Init() } } -X11Pixmap* X11OpenGLSalGraphicsImpl::GetPixmapFromScreen( const Rectangle& rRect ) +bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY ) { Display* pDisplay = mrParent.GetXDisplay(); SalX11Screen nScreen = mrParent.GetScreenNumber(); XVisualInfo aVisualInfo; - X11Pixmap* pPixmap; XImage* pImage; char* pData; - SAL_INFO( "vcl.opengl", "GetPixmapFromScreen" ); - // TODO: lfrb: Use context depth - pPixmap = new X11Pixmap( pDisplay, nScreen, rRect.GetWidth(), rRect.GetHeight(), 24 ); + SAL_INFO( "vcl.opengl", "FillPixmapFromScreen" ); if( !OpenGLHelper::GetVisualInfo( pDisplay, nScreen.getXScreen(), aVisualInfo ) ) - return pPixmap; + return false; // make sure everything is synced up before reading back maContext.makeCurrent(); glXWaitX(); // TODO: lfrb: What if offscreen? - pData = (char*) malloc( rRect.GetWidth() * rRect.GetHeight() * 4 ); + pData = (char*) malloc( pPixmap->GetWidth() * pPixmap->GetHeight() * 4 ); glPixelStorei( GL_PACK_ALIGNMENT, 1 ); - glReadPixels( rRect.Left(), GetHeight() - rRect.Top(), rRect.GetWidth(), rRect.GetHeight(), + glReadPixels( nX, GetHeight() - nY, pPixmap->GetWidth(), pPixmap->GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, pData ); pImage = XCreateImage( pDisplay, aVisualInfo.visual, 24, ZPixmap, 0, pData, - rRect.GetWidth(), rRect.GetHeight(), 8, 0 ); + pPixmap->GetWidth(), pPixmap->GetHeight(), 8, 0 ); XInitImage( pImage ); GC aGC = XCreateGC( pDisplay, pPixmap->GetPixmap(), 0, NULL ); XPutImage( pDisplay, pPixmap->GetDrawable(), aGC, pImage, - 0, 0, 0, 0, rRect.GetWidth(), rRect.GetHeight() ); + 0, 0, 0, 0, pPixmap->GetWidth(), pPixmap->GetHeight() ); XFreeGC( pDisplay, aGC ); XDestroyImage( pImage ); - return pPixmap; + return true; } bool X11OpenGLSalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) 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; } /************************************************************************ |