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_CAIRO_HXX 29 #define _CAIROCANVAS_CAIRO_HXX 30 31 #include <sal/config.h> 32 #include <boost/shared_ptr.hpp> 33 34 struct SystemEnvData; 35 struct BitmapSystemData; 36 struct SystemGraphicsData; 37 class VirtualDevice; 38 class OutputDevice; 39 class Window; 40 class Size; 41 42 #include <cairo.h> //cannot be inside a namespace, otherwise Quartz fails to compile. 43 44 namespace cairo { 45 typedef cairo_t Cairo; 46 typedef cairo_matrix_t Matrix; 47 typedef cairo_format_t Format; 48 typedef cairo_content_t Content; 49 typedef cairo_pattern_t Pattern; 50 51 typedef boost::shared_ptr<cairo_surface_t> CairoSurfaceSharedPtr; 52 typedef boost::shared_ptr<Cairo> CairoSharedPtr; 53 54 const SystemEnvData* GetSysData(const Window *pOutputWindow); 55 56 /** Cairo surface interface 57 58 For each cairo-supported platform, there's an implementation of 59 this interface 60 */ 61 struct Surface 62 { 63 public: 64 virtual ~Surface() {} 65 66 // Query methods 67 virtual CairoSharedPtr getCairo() const = 0; 68 virtual CairoSurfaceSharedPtr getCairoSurface() const = 0; 69 virtual boost::shared_ptr<Surface> getSimilar( Content aContent, int width, int height ) const = 0; 70 71 /// factory for VirDev on this surface 72 virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const = 0; 73 74 /// Resize the surface (possibly destroying content) 75 virtual void Resize( int width, int height ) = 0; 76 77 /// Flush all pending output to surface 78 virtual void flush() const = 0; 79 }; 80 81 typedef boost::shared_ptr<Surface> SurfaceSharedPtr; 82 83 /// Create Surface from given cairo surface 84 SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface ); 85 /// Create surface with given dimensions 86 SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice, 87 int x, int y, int width, int height ); 88 /// Create Surface for given bitmap data 89 SurfaceSharedPtr createBitmapSurface( const OutputDevice& rRefDevice, 90 const BitmapSystemData& rData, 91 const Size& rSize ); 92 93 /// Check whether cairo will work on given window 94 bool IsCairoWorking( OutputDevice* ); 95 } 96 97 #endif 98