Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #ifndef _CAIROCANVAS_XLIB_CAIRO_HXX
21 : : #define _CAIROCANVAS_XLIB_CAIRO_HXX
22 : :
23 : : #include "cairo_cairo.hxx"
24 : :
25 : : struct SystemEnvData;
26 : : struct SystemGraphicsData;
27 : :
28 : : namespace cairo {
29 : :
30 : : /// Holds all X11-output relevant data
31 : : struct X11SysData
32 : : {
33 : : X11SysData();
34 : : explicit X11SysData( const SystemGraphicsData& );
35 : : explicit X11SysData( const SystemEnvData& );
36 : :
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
44 : : };
45 : :
46 : : /// RAII wrapper for a pixmap
47 : : struct X11Pixmap
48 : : {
49 : : void* mpDisplay; // the relevant display connection
50 : : long mhDrawable; // a drawable
51 : :
52 : 0 : X11Pixmap( long hDrawable, void* pDisplay ) :
53 : : mpDisplay(pDisplay),
54 : 0 : mhDrawable(hDrawable)
55 : 0 : {}
56 : :
57 : : ~X11Pixmap();
58 : :
59 : 0 : void clear() { mpDisplay=NULL; mhDrawable=0; }
60 : : };
61 : :
62 : : typedef boost::shared_ptr<X11Pixmap> X11PixmapSharedPtr;
63 : :
64 : 0 : class X11Surface : public Surface
65 : : {
66 : : const X11SysData maSysData;
67 : : X11PixmapSharedPtr mpPixmap;
68 : : CairoSurfaceSharedPtr mpSurface;
69 : :
70 : : X11Surface( const X11SysData& rSysData, const X11PixmapSharedPtr& rPixmap, const CairoSurfaceSharedPtr& pSurface );
71 : :
72 : : public:
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 );
79 : :
80 : : // Surface interface
81 : : virtual CairoSharedPtr getCairo() const;
82 : 0 : virtual CairoSurfaceSharedPtr getCairoSurface() const { return mpSurface; }
83 : : virtual SurfaceSharedPtr getSimilar( Content aContent, int width, int height ) const;
84 : :
85 : : virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const;
86 : :
87 : : virtual void Resize( int width, int height );
88 : :
89 : : virtual void flush() const;
90 : :
91 : : int getDepth() const;
92 : 0 : X11PixmapSharedPtr getPixmap() const { return mpPixmap; }
93 : 0 : void* getRenderFormat() const { return maSysData.pRenderFormat; }
94 : 0 : long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; }
95 : : };
96 : : }
97 : :
98 : : #endif
99 : :
100 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|