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_DEVICEHELPER_HXX 29 #define _CAIROCANVAS_DEVICEHELPER_HXX 30 31 #include <com/sun/star/awt/Rectangle.hpp> 32 #include <com/sun/star/rendering/XGraphicDevice.hpp> 33 #include <com/sun/star/rendering/XBufferController.hpp> 34 35 #include <boost/utility.hpp> 36 37 #include <vcl/window.hxx> 38 #include <vcl/bitmap.hxx> 39 40 #include "cairo_cairo.hxx" 41 #include "cairo_surfaceprovider.hxx" 42 43 /* Definition of DeviceHelper class */ 44 45 struct SystemEnvData; 46 class Window; 47 48 namespace cairocanvas 49 { 50 class Canvas; 51 class CanvasHelper; 52 53 class DeviceHelper : private ::boost::noncopyable 54 { 55 public: 56 DeviceHelper(); 57 58 /** init helper 59 60 @param rCanvas 61 Owning canvas. 62 63 @param rRefDevice 64 Reference output device. Needed for resolution 65 calculations etc. 66 */ 67 void init( SurfaceProvider& rSurfaceProvider, 68 OutputDevice& rRefDevice ); 69 70 /// Dispose all internal references 71 void disposing(); 72 73 // XWindowGraphicDevice 74 ::com::sun::star::geometry::RealSize2D getPhysicalResolution(); 75 ::com::sun::star::geometry::RealSize2D getPhysicalSize(); 76 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XLinePolyPolygon2D > createCompatibleLinePolyPolygon( 77 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 78 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& points ); 79 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBezierPolyPolygon2D > createCompatibleBezierPolyPolygon( 80 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 81 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& points ); 82 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleBitmap( 83 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 84 const ::com::sun::star::geometry::IntegerSize2D& size ); 85 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileBitmap( 86 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 87 const ::com::sun::star::geometry::IntegerSize2D& size ); 88 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleAlphaBitmap( 89 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 90 const ::com::sun::star::geometry::IntegerSize2D& size ); 91 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileAlphaBitmap( 92 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 93 const ::com::sun::star::geometry::IntegerSize2D& size ); 94 sal_Bool hasFullScreenMode( ); 95 sal_Bool enterFullScreenMode( sal_Bool bEnter ); 96 97 ::com::sun::star::uno::Any isAccelerated() const; 98 ::com::sun::star::uno::Any getDeviceHandle() const; 99 ::com::sun::star::uno::Any getSurfaceHandle() const; 100 ::com::sun::star::uno::Reference< 101 ::com::sun::star::rendering::XColorSpace > getColorSpace() const; 102 103 /** called when DumpScreenContent property is enabled on 104 XGraphicDevice, and writes out bitmaps of current screen. 105 */ 106 void dumpScreenContent() const; 107 108 OutputDevice* getOutputDevice() const { return mpRefDevice; } 109 const void* getSysData() { return mpSysData; } 110 ::cairo::SurfaceSharedPtr getSurface(); 111 ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA ); 112 ::cairo::SurfaceSharedPtr createSurface( BitmapSystemData& rData, const Size& rSize ); 113 114 protected: 115 /** init helper 116 117 @param rCanvas 118 Owning canvas. 119 120 @param rRefDevice 121 Reference output device. Needed for resolution 122 calculations etc. 123 */ 124 void implInit( SurfaceProvider& rSurfaceProvider, 125 OutputDevice& rRefDevice ); 126 void setSize( const ::basegfx::B2ISize& rSize ); 127 128 private: 129 /** Surface provider 130 131 Deliberately not a refcounted reference, because of 132 potential circular references for canvas. Provides us with 133 our output surface and associated functionality. 134 */ 135 SurfaceProvider* mpSurfaceProvider; 136 137 OutputDevice* mpRefDevice; 138 const void* mpSysData; 139 ::cairo::SurfaceSharedPtr mpSurface; 140 }; 141 } 142 143 #endif 144