xref: /AOO41X/main/canvas/source/null/null_canvashelper.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _NULLCANVAS_CANVASHELPER_HXX_
29*cdf0e10cSrcweir #define _NULLCANVAS_CANVASHELPER_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <basegfx/vector/b2isize.hxx>
35*cdf0e10cSrcweir #include <basegfx/vector/b2dsize.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <boost/utility.hpp>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir namespace nullcanvas
41*cdf0e10cSrcweir {
42*cdf0e10cSrcweir     class SpriteCanvas;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir     /** Helper class for basic canvas functionality. Also offers
45*cdf0e10cSrcweir         optional backbuffer painting, when providing it with a second
46*cdf0e10cSrcweir         HDC to render into.
47*cdf0e10cSrcweir      */
48*cdf0e10cSrcweir     class CanvasHelper : private ::boost::noncopyable
49*cdf0e10cSrcweir     {
50*cdf0e10cSrcweir     public:
51*cdf0e10cSrcweir         CanvasHelper();
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir         /// Release all references
54*cdf0e10cSrcweir         void disposing();
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 		/** Initialize canvas helper
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir         	This method late-initializes the canvas helper, providing
59*cdf0e10cSrcweir         	it with the necessary device and size. Note that the
60*cdf0e10cSrcweir         	CanvasHelper does <em>not</em> take ownership of the
61*cdf0e10cSrcweir         	passed rDevice reference, nor does it perform any
62*cdf0e10cSrcweir         	reference counting. Thus, to prevent the reference counted
63*cdf0e10cSrcweir         	SpriteCanvas object from deletion, the user of this class
64*cdf0e10cSrcweir         	is responsible for holding ref-counted references itself!
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir             @param rSizePixel
67*cdf0e10cSrcweir             Size of the output surface in pixel.
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir         	@param rDevice
70*cdf0e10cSrcweir             Reference device this canvas is associated with
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir          */
73*cdf0e10cSrcweir         void init( const ::basegfx::B2ISize& rSizePixel,
74*cdf0e10cSrcweir                    SpriteCanvas&             rDevice,
75*cdf0e10cSrcweir                    bool                      bHasAlpha );
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir         // CanvasHelper functionality
79*cdf0e10cSrcweir         // ==========================
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir         // XCanvas (only providing, not implementing the
82*cdf0e10cSrcweir         // interface. Also note subtle method parameter differences)
83*cdf0e10cSrcweir         void clear();
84*cdf0e10cSrcweir         void drawPoint( const ::com::sun::star::rendering::XCanvas* 	pCanvas,
85*cdf0e10cSrcweir                         const ::com::sun::star::geometry::RealPoint2D& 	aPoint,
86*cdf0e10cSrcweir                         const ::com::sun::star::rendering::ViewState& 	viewState,
87*cdf0e10cSrcweir                         const ::com::sun::star::rendering::RenderState& renderState );
88*cdf0e10cSrcweir         void drawLine( const ::com::sun::star::rendering::XCanvas* 		pCanvas,
89*cdf0e10cSrcweir                        const ::com::sun::star::geometry::RealPoint2D& 	aStartPoint,
90*cdf0e10cSrcweir                        const ::com::sun::star::geometry::RealPoint2D& 	aEndPoint,
91*cdf0e10cSrcweir                        const ::com::sun::star::rendering::ViewState& 	viewState,
92*cdf0e10cSrcweir                        const ::com::sun::star::rendering::RenderState& 	renderState	);
93*cdf0e10cSrcweir         void drawBezier( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
94*cdf0e10cSrcweir                          const ::com::sun::star::geometry::RealBezierSegment2D&	aBezierSegment,
95*cdf0e10cSrcweir                          const ::com::sun::star::geometry::RealPoint2D& 		aEndPoint,
96*cdf0e10cSrcweir                          const ::com::sun::star::rendering::ViewState& 			viewState,
97*cdf0e10cSrcweir                          const ::com::sun::star::rendering::RenderState& 		renderState );
98*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
99*cdf0e10cSrcweir         	drawPolyPolygon( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
100*cdf0e10cSrcweir                              const ::com::sun::star::uno::Reference<
101*cdf0e10cSrcweir                              		::com::sun::star::rendering::XPolyPolygon2D >&	xPolyPolygon,
102*cdf0e10cSrcweir                              const ::com::sun::star::rendering::ViewState& 			viewState,
103*cdf0e10cSrcweir                              const ::com::sun::star::rendering::RenderState& 		renderState );
104*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
105*cdf0e10cSrcweir         	strokePolyPolygon( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
106*cdf0e10cSrcweir                                const ::com::sun::star::uno::Reference<
107*cdf0e10cSrcweir                                		::com::sun::star::rendering::XPolyPolygon2D >& 	xPolyPolygon,
108*cdf0e10cSrcweir                                const ::com::sun::star::rendering::ViewState& 		viewState,
109*cdf0e10cSrcweir                                const ::com::sun::star::rendering::RenderState& 		renderState,
110*cdf0e10cSrcweir                                const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
111*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
112*cdf0e10cSrcweir         	strokeTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
113*cdf0e10cSrcweir                                        const ::com::sun::star::uno::Reference<
114*cdf0e10cSrcweir                                        		::com::sun::star::rendering::XPolyPolygon2D >& 	xPolyPolygon,
115*cdf0e10cSrcweir                                        const ::com::sun::star::rendering::ViewState& 		viewState,
116*cdf0e10cSrcweir                                        const ::com::sun::star::rendering::RenderState& 		renderState,
117*cdf0e10cSrcweir                                        const ::com::sun::star::uno::Sequence<
118*cdf0e10cSrcweir                                        		::com::sun::star::rendering::Texture >& 		textures,
119*cdf0e10cSrcweir                                        const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
120*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
121*cdf0e10cSrcweir         	strokeTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
122*cdf0e10cSrcweir                                             const ::com::sun::star::uno::Reference<
123*cdf0e10cSrcweir                                             		::com::sun::star::rendering::XPolyPolygon2D >& 	xPolyPolygon,
124*cdf0e10cSrcweir                                             const ::com::sun::star::rendering::ViewState& 			viewState,
125*cdf0e10cSrcweir                                             const ::com::sun::star::rendering::RenderState& 		renderState,
126*cdf0e10cSrcweir                                             const ::com::sun::star::uno::Sequence<
127*cdf0e10cSrcweir                                             		::com::sun::star::rendering::Texture >& 		textures,
128*cdf0e10cSrcweir                                             const ::com::sun::star::uno::Reference<
129*cdf0e10cSrcweir                                             		::com::sun::star::geometry::XMapping2D >& 		xMapping,
130*cdf0e10cSrcweir                                             const ::com::sun::star::rendering::StrokeAttributes& 	strokeAttributes );
131*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
132*cdf0e10cSrcweir         	queryStrokeShapes( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
133*cdf0e10cSrcweir                                const ::com::sun::star::uno::Reference<
134*cdf0e10cSrcweir                                		::com::sun::star::rendering::XPolyPolygon2D >& 	xPolyPolygon,
135*cdf0e10cSrcweir                                const ::com::sun::star::rendering::ViewState& 		viewState,
136*cdf0e10cSrcweir                                const ::com::sun::star::rendering::RenderState& 		renderState,
137*cdf0e10cSrcweir                                const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
138*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
139*cdf0e10cSrcweir         	fillPolyPolygon( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
140*cdf0e10cSrcweir                              const ::com::sun::star::uno::Reference<
141*cdf0e10cSrcweir                              		::com::sun::star::rendering::XPolyPolygon2D >& 	xPolyPolygon,
142*cdf0e10cSrcweir                              const ::com::sun::star::rendering::ViewState& 			viewState,
143*cdf0e10cSrcweir                              const ::com::sun::star::rendering::RenderState& 		renderState );
144*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
145*cdf0e10cSrcweir         	fillTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
146*cdf0e10cSrcweir                                      const ::com::sun::star::uno::Reference<
147*cdf0e10cSrcweir                                      		::com::sun::star::rendering::XPolyPolygon2D >& 	xPolyPolygon,
148*cdf0e10cSrcweir                                      const ::com::sun::star::rendering::ViewState& 			viewState,
149*cdf0e10cSrcweir                                      const ::com::sun::star::rendering::RenderState& 		renderState,
150*cdf0e10cSrcweir                                      const ::com::sun::star::uno::Sequence<
151*cdf0e10cSrcweir                                      		::com::sun::star::rendering::Texture >& 		textures );
152*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
153*cdf0e10cSrcweir         	fillTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
154*cdf0e10cSrcweir                                           const ::com::sun::star::uno::Reference<
155*cdf0e10cSrcweir                                           		::com::sun::star::rendering::XPolyPolygon2D >& 	xPolyPolygon,
156*cdf0e10cSrcweir                                           const ::com::sun::star::rendering::ViewState& 		viewState,
157*cdf0e10cSrcweir                                           const ::com::sun::star::rendering::RenderState& 		renderState,
158*cdf0e10cSrcweir                                           const ::com::sun::star::uno::Sequence<
159*cdf0e10cSrcweir                                           		::com::sun::star::rendering::Texture >& 		textures,
160*cdf0e10cSrcweir                                           const ::com::sun::star::uno::Reference<
161*cdf0e10cSrcweir                                           		::com::sun::star::geometry::XMapping2D >& 		xMapping );
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > SAL_CALL
164*cdf0e10cSrcweir         	createFont( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
165*cdf0e10cSrcweir                         const ::com::sun::star::rendering::FontRequest& 		fontRequest,
166*cdf0e10cSrcweir                         const ::com::sun::star::uno::Sequence<
167*cdf0e10cSrcweir                         		::com::sun::star::beans::PropertyValue >& 		extraFontProperties,
168*cdf0e10cSrcweir                         const ::com::sun::star::geometry::Matrix2D& 			fontMatrix );
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::FontInfo >
171*cdf0e10cSrcweir         	queryAvailableFonts( const ::com::sun::star::rendering::XCanvas* 		pCanvas,
172*cdf0e10cSrcweir                                  const ::com::sun::star::rendering::FontInfo& 		aFilter,
173*cdf0e10cSrcweir                                  const ::com::sun::star::uno::Sequence<
174*cdf0e10cSrcweir                                  		::com::sun::star::beans::PropertyValue >& 	aFontProperties );
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
177*cdf0e10cSrcweir         	drawText( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
178*cdf0e10cSrcweir                       const ::com::sun::star::rendering::StringContext& 	text,
179*cdf0e10cSrcweir                       const ::com::sun::star::uno::Reference<
180*cdf0e10cSrcweir                       		::com::sun::star::rendering::XCanvasFont >& 	xFont,
181*cdf0e10cSrcweir                       const ::com::sun::star::rendering::ViewState& 		viewState,
182*cdf0e10cSrcweir                       const ::com::sun::star::rendering::RenderState& 		renderState,
183*cdf0e10cSrcweir                       sal_Int8 												textDirection );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
186*cdf0e10cSrcweir         	drawTextLayout( const ::com::sun::star::rendering::XCanvas* 	pCanvas,
187*cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference<
188*cdf0e10cSrcweir                             	::com::sun::star::rendering::XTextLayout >& layoutetText,
189*cdf0e10cSrcweir                             const ::com::sun::star::rendering::ViewState& 	viewState,
190*cdf0e10cSrcweir                             const ::com::sun::star::rendering::RenderState& renderState );
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
193*cdf0e10cSrcweir         	drawBitmap( const ::com::sun::star::rendering::XCanvas* 	pCanvas,
194*cdf0e10cSrcweir                         const ::com::sun::star::uno::Reference<
195*cdf0e10cSrcweir                         		::com::sun::star::rendering::XBitmap >& xBitmap,
196*cdf0e10cSrcweir                         const ::com::sun::star::rendering::ViewState& 	viewState,
197*cdf0e10cSrcweir                         const ::com::sun::star::rendering::RenderState& renderState );
198*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
199*cdf0e10cSrcweir         	drawBitmapModulated( const ::com::sun::star::rendering::XCanvas* 		pCanvas,
200*cdf0e10cSrcweir                                  const ::com::sun::star::uno::Reference<
201*cdf0e10cSrcweir                                  		::com::sun::star::rendering::XBitmap >&		xBitmap,
202*cdf0e10cSrcweir                                  const ::com::sun::star::rendering::ViewState& 		viewState,
203*cdf0e10cSrcweir                                  const ::com::sun::star::rendering::RenderState& 	renderState );
204*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >
205*cdf0e10cSrcweir         	getDevice();
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir         // BitmapCanvasHelper functionality
208*cdf0e10cSrcweir         // ================================
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir         void copyRect( const ::com::sun::star::rendering::XCanvas* 			pCanvas,
211*cdf0e10cSrcweir                        const ::com::sun::star::uno::Reference<
212*cdf0e10cSrcweir                        		::com::sun::star::rendering::XBitmapCanvas >& 	sourceCanvas,
213*cdf0e10cSrcweir                        const ::com::sun::star::geometry::RealRectangle2D& 	sourceRect,
214*cdf0e10cSrcweir                        const ::com::sun::star::rendering::ViewState& 		sourceViewState,
215*cdf0e10cSrcweir                        const ::com::sun::star::rendering::RenderState& 		sourceRenderState,
216*cdf0e10cSrcweir                        const ::com::sun::star::geometry::RealRectangle2D& 	destRect,
217*cdf0e10cSrcweir                        const ::com::sun::star::rendering::ViewState& 		destViewState,
218*cdf0e10cSrcweir                        const ::com::sun::star::rendering::RenderState& 		destRenderState );
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir         ::com::sun::star::geometry::IntegerSize2D getSize();
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >
223*cdf0e10cSrcweir         	getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& 	newSize,
224*cdf0e10cSrcweir                              sal_Bool 										beFast );
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< sal_Int8 >
227*cdf0e10cSrcweir 	        getData( ::com::sun::star::rendering::IntegerBitmapLayout& 		bitmapLayout,
228*cdf0e10cSrcweir                      const ::com::sun::star::geometry::IntegerRectangle2D&  rect );
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir         void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >&         data,
231*cdf0e10cSrcweir                       const ::com::sun::star::rendering::IntegerBitmapLayout&    bitmapLayout,
232*cdf0e10cSrcweir                       const ::com::sun::star::geometry::IntegerRectangle2D&      rect );
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir         void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >&        color,
235*cdf0e10cSrcweir                        const ::com::sun::star::rendering::IntegerBitmapLayout&   bitmapLayout,
236*cdf0e10cSrcweir                        const ::com::sun::star::geometry::IntegerPoint2D&         pos );
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< sal_Int8 >
239*cdf0e10cSrcweir 	        getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
240*cdf0e10cSrcweir                       const ::com::sun::star::geometry::IntegerPoint2D& pos );
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapPalette > getPalette();
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir         ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout();
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir         // Flush drawing queue to screen
247*cdf0e10cSrcweir         void					flush() const;
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir         /** Called from XCanvas base classes, to notify that content
250*cdf0e10cSrcweir             is _about_ to change
251*cdf0e10cSrcweir         */
252*cdf0e10cSrcweir         void modifying() {}
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir         bool hasAlpha() const;
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     protected:
257*cdf0e10cSrcweir         /** Phyical output device
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir             Deliberately not a refcounted reference, because of
260*cdf0e10cSrcweir             potential circular references for spritecanvas.
261*cdf0e10cSrcweir          */
262*cdf0e10cSrcweir         SpriteCanvas*                   mpDevice;
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir     private:
265*cdf0e10cSrcweir         /// Current size of the output surface in pixel
266*cdf0e10cSrcweir         ::basegfx::B2ISize				maSize;
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir         /// When true, content is able to represent alpha
269*cdf0e10cSrcweir         bool                            mbHaveAlpha;
270*cdf0e10cSrcweir     };
271*cdf0e10cSrcweir }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir #endif /* _NULLCANVAS_CANVASHELPER_HXX_ */
274