1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cairo_xlib_cairo.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CAIROCANVAS_XLIB_CAIRO_HXX
32 #define _CAIROCANVAS_XLIB_CAIRO_HXX
34 #include "cairo_cairo.hxx"
37 struct SystemGraphicsData
;
41 /// Holds all X11-output relevant data
45 explicit X11SysData( const SystemGraphicsData
& );
46 explicit X11SysData( const SystemEnvData
& );
48 void* pDisplay
; // the relevant display connection
49 long hDrawable
; // a drawable
50 void* pVisual
; // the visual in use
51 int nScreen
; // the current screen of the drawable
52 int nDepth
; // depth of said visual
53 long aColormap
; // the colormap being used
54 void* pRenderFormat
; // render format for drawable
57 /// RAII wrapper for a pixmap
60 void* mpDisplay
; // the relevant display connection
61 long mhDrawable
; // a drawable
63 X11Pixmap( long hDrawable
, void* pDisplay
) :
70 void clear() { mpDisplay
=NULL
; mhDrawable
=0; }
73 typedef boost::shared_ptr
<X11Pixmap
> X11PixmapSharedPtr
;
75 class X11Surface
: public Surface
77 const X11SysData maSysData
;
78 X11PixmapSharedPtr mpPixmap
;
79 CairoSurfaceSharedPtr mpSurface
;
81 X11Surface( const X11SysData
& rSysData
, const X11PixmapSharedPtr
& rPixmap
, const CairoSurfaceSharedPtr
& pSurface
);
84 /// takes over ownership of passed cairo_surface
85 explicit X11Surface( const CairoSurfaceSharedPtr
& pSurface
);
86 /// create surface on subarea of given drawable
87 X11Surface( const X11SysData
& rSysData
, int x
, int y
, int width
, int height
);
88 /// create surface for given bitmap data
89 X11Surface( const X11SysData
& rSysData
, const BitmapSystemData
& rBmpData
);
92 virtual CairoSharedPtr
getCairo() const;
93 virtual CairoSurfaceSharedPtr
getCairoSurface() const { return mpSurface
; }
94 virtual SurfaceSharedPtr
getSimilar( Content aContent
, int width
, int height
) const;
96 virtual boost::shared_ptr
<VirtualDevice
> createVirtualDevice() const;
98 virtual void Resize( int width
, int height
);
100 virtual void flush() const;
102 int getDepth() const;
103 X11PixmapSharedPtr
getPixmap() const { return mpPixmap
; }
104 void* getRenderFormat() const { return maSysData
.pRenderFormat
; }
105 long getDrawable() const { return mpPixmap
? mpPixmap
->mhDrawable
: maSysData
.hDrawable
; }