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