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 INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_XLIB_CAIRO_HXX
21 : #define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_XLIB_CAIRO_HXX
22 :
23 : #include <sal/config.h>
24 :
25 : #include <sal/types.h>
26 :
27 : #include "cairo_cairo.hxx"
28 :
29 : struct SystemEnvData;
30 : struct SystemGraphicsData;
31 :
32 : namespace cairo {
33 :
34 : /// Holds all X11-output relevant data
35 : struct X11SysData
36 : {
37 : X11SysData();
38 : explicit X11SysData( const SystemGraphicsData& );
39 : explicit X11SysData( const SystemEnvData& );
40 :
41 : void* pDisplay; // the relevant display connection
42 : long hDrawable; // a drawable
43 : void* pVisual; // the visual in use
44 : int nScreen; // the current screen of the drawable
45 : int nDepth; // depth of said visual
46 : long aColormap; // the colormap being used
47 : void* pRenderFormat; // render format for drawable
48 : };
49 :
50 : /// RAII wrapper for a pixmap
51 : struct X11Pixmap
52 : {
53 : void* mpDisplay; // the relevant display connection
54 : long mhDrawable; // a drawable
55 :
56 0 : X11Pixmap( long hDrawable, void* pDisplay ) :
57 : mpDisplay(pDisplay),
58 0 : mhDrawable(hDrawable)
59 0 : {}
60 :
61 : ~X11Pixmap();
62 :
63 : void clear() { mpDisplay=NULL; mhDrawable=0; }
64 : };
65 :
66 : typedef boost::shared_ptr<X11Pixmap> X11PixmapSharedPtr;
67 :
68 0 : class X11Surface : public Surface
69 : {
70 : const X11SysData maSysData;
71 : X11PixmapSharedPtr mpPixmap;
72 : CairoSurfaceSharedPtr mpSurface;
73 :
74 : X11Surface( const X11SysData& rSysData, const X11PixmapSharedPtr& rPixmap, const CairoSurfaceSharedPtr& pSurface );
75 :
76 : public:
77 : /// takes over ownership of passed cairo_surface
78 : explicit X11Surface( const CairoSurfaceSharedPtr& pSurface );
79 : /// create surface on subarea of given drawable
80 : X11Surface( const X11SysData& rSysData, int x, int y, int width, int height );
81 : /// create surface for given bitmap data
82 : X11Surface( const X11SysData& rSysData, const BitmapSystemData& rBmpData );
83 :
84 : // Surface interface
85 : virtual CairoSharedPtr getCairo() const SAL_OVERRIDE;
86 0 : virtual CairoSurfaceSharedPtr getCairoSurface() const SAL_OVERRIDE { return mpSurface; }
87 : virtual SurfaceSharedPtr getSimilar( Content aContent, int width, int height ) const SAL_OVERRIDE;
88 :
89 : virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const SAL_OVERRIDE;
90 :
91 : virtual void Resize( int width, int height ) SAL_OVERRIDE;
92 :
93 : virtual void flush() const SAL_OVERRIDE;
94 :
95 : int getDepth() const;
96 0 : X11PixmapSharedPtr getPixmap() const { return mpPixmap; }
97 0 : void* getRenderFormat() const { return maSysData.pRenderFormat; }
98 0 : long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; }
99 : };
100 : }
101 :
102 : #endif
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|