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