1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _CAIROCANVAS_XLIB_CAIRO_HXX
21 #define _CAIROCANVAS_XLIB_CAIRO_HXX
23 #include "cairo_cairo.hxx"
26 struct SystemGraphicsData
;
30 /// Holds all X11-output relevant data
34 explicit X11SysData( const SystemGraphicsData
& );
35 explicit X11SysData( const SystemEnvData
& );
37 void* pDisplay
; // the relevant display connection
38 long hDrawable
; // a drawable
39 void* pVisual
; // the visual in use
40 int nScreen
; // the current screen of the drawable
41 int nDepth
; // depth of said visual
42 long aColormap
; // the colormap being used
43 void* pRenderFormat
; // render format for drawable
46 /// RAII wrapper for a pixmap
49 void* mpDisplay
; // the relevant display connection
50 long mhDrawable
; // a drawable
52 X11Pixmap( long hDrawable
, void* pDisplay
) :
59 void clear() { mpDisplay
=NULL
; mhDrawable
=0; }
62 typedef boost::shared_ptr
<X11Pixmap
> X11PixmapSharedPtr
;
64 class X11Surface
: public Surface
66 const X11SysData maSysData
;
67 X11PixmapSharedPtr mpPixmap
;
68 CairoSurfaceSharedPtr mpSurface
;
70 X11Surface( const X11SysData
& rSysData
, const X11PixmapSharedPtr
& rPixmap
, const CairoSurfaceSharedPtr
& pSurface
);
73 /// takes over ownership of passed cairo_surface
74 explicit X11Surface( const CairoSurfaceSharedPtr
& pSurface
);
75 /// create surface on subarea of given drawable
76 X11Surface( const X11SysData
& rSysData
, int x
, int y
, int width
, int height
);
77 /// create surface for given bitmap data
78 X11Surface( const X11SysData
& rSysData
, const BitmapSystemData
& rBmpData
);
81 virtual CairoSharedPtr
getCairo() const;
82 virtual CairoSurfaceSharedPtr
getCairoSurface() const { return mpSurface
; }
83 virtual SurfaceSharedPtr
getSimilar( Content aContent
, int width
, int height
) const;
85 virtual boost::shared_ptr
<VirtualDevice
> createVirtualDevice() const;
87 virtual void Resize( int width
, int height
);
89 virtual void flush() const;
92 X11PixmapSharedPtr
getPixmap() const { return mpPixmap
; }
93 void* getRenderFormat() const { return maSysData
.pRenderFormat
; }
94 long getDrawable() const { return mpPixmap
? mpPixmap
->mhDrawable
: maSysData
.hDrawable
; }
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */