1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _CAIROCANVAS_DEVICEHELPER_HXX 25 #define _CAIROCANVAS_DEVICEHELPER_HXX 26 27 #include <com/sun/star/awt/Rectangle.hpp> 28 #include <com/sun/star/rendering/XGraphicDevice.hpp> 29 #include <com/sun/star/rendering/XBufferController.hpp> 30 31 #include <boost/utility.hpp> 32 33 #include <vcl/window.hxx> 34 #include <vcl/bitmap.hxx> 35 36 #include "cairo_cairo.hxx" 37 #include "cairo_surfaceprovider.hxx" 38 39 /* Definition of DeviceHelper class */ 40 41 struct SystemEnvData; 42 class Window; 43 44 namespace cairocanvas 45 { 46 class Canvas; 47 class CanvasHelper; 48 49 class DeviceHelper : private ::boost::noncopyable 50 { 51 public: 52 DeviceHelper(); 53 54 /** init helper 55 56 @param rCanvas 57 Owning canvas. 58 59 @param rRefDevice 60 Reference output device. Needed for resolution 61 calculations etc. 62 */ 63 void init( SurfaceProvider& rSurfaceProvider, 64 OutputDevice& rRefDevice ); 65 66 /// Dispose all internal references 67 void disposing(); 68 69 // XWindowGraphicDevice 70 ::com::sun::star::geometry::RealSize2D getPhysicalResolution(); 71 ::com::sun::star::geometry::RealSize2D getPhysicalSize(); 72 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XLinePolyPolygon2D > createCompatibleLinePolyPolygon( 73 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 74 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& points ); 75 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBezierPolyPolygon2D > createCompatibleBezierPolyPolygon( 76 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 77 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& points ); 78 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleBitmap( 79 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 80 const ::com::sun::star::geometry::IntegerSize2D& size ); 81 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileBitmap( 82 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 83 const ::com::sun::star::geometry::IntegerSize2D& size ); 84 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleAlphaBitmap( 85 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 86 const ::com::sun::star::geometry::IntegerSize2D& size ); 87 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileAlphaBitmap( 88 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice, 89 const ::com::sun::star::geometry::IntegerSize2D& size ); 90 sal_Bool hasFullScreenMode( ); 91 sal_Bool enterFullScreenMode( sal_Bool bEnter ); 92 93 ::com::sun::star::uno::Any isAccelerated() const; 94 ::com::sun::star::uno::Any getDeviceHandle() const; 95 ::com::sun::star::uno::Any getSurfaceHandle() const; 96 ::com::sun::star::uno::Reference< 97 ::com::sun::star::rendering::XColorSpace > getColorSpace() const; 98 99 /** called when DumpScreenContent property is enabled on 100 XGraphicDevice, and writes out bitmaps of current screen. 101 */ 102 void dumpScreenContent() const; 103 getOutputDevice() const104 OutputDevice* getOutputDevice() const { return mpRefDevice; } getSysData()105 const void* getSysData() { return mpSysData; } 106 ::cairo::SurfaceSharedPtr getSurface(); 107 ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA ); 108 ::cairo::SurfaceSharedPtr createSurface( BitmapSystemData& rData, const Size& rSize ); 109 110 protected: 111 /** init helper 112 113 @param rCanvas 114 Owning canvas. 115 116 @param rRefDevice 117 Reference output device. Needed for resolution 118 calculations etc. 119 */ 120 void implInit( SurfaceProvider& rSurfaceProvider, 121 OutputDevice& rRefDevice ); 122 void setSize( const ::basegfx::B2ISize& rSize ); 123 124 private: 125 /** Surface provider 126 127 Deliberately not a refcounted reference, because of 128 potential circular references for canvas. Provides us with 129 our output surface and associated functionality. 130 */ 131 SurfaceProvider* mpSurfaceProvider; 132 133 OutputDevice* mpRefDevice; 134 const void* mpSysData; 135 ::cairo::SurfaceSharedPtr mpSurface; 136 }; 137 } 138 139 #endif 140