CWS-TOOLING: integrate CWS os146
[LibreOffice.git] / canvas / source / directx / dx_canvashelper.hxx
blob2f175cce88e5c1d4996bd749e9bced2bf6d08a4b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _DXCANVAS_CANVASHELPER_HXX_
29 #define _DXCANVAS_CANVASHELPER_HXX_
31 #include <com/sun/star/rendering/XCanvas.hpp>
33 #include <basegfx/vector/b2isize.hxx>
34 #include <basegfx/vector/b2dsize.hxx>
36 #include "dx_graphicsprovider.hxx"
37 #include "dx_gdiplususer.hxx"
38 #include "dx_impltools.hxx"
40 #include <boost/utility.hpp>
43 namespace dxcanvas
45 /** Helper class for basic canvas functionality. Also offers
46 optional backbuffer painting, when providing it with a second
47 HDC to render into.
49 class CanvasHelper : private ::boost::noncopyable
51 public:
52 CanvasHelper();
54 /// Release all references
55 void disposing();
57 /** Initialize canvas helper
59 This method late-initializes the canvas helper, providing
60 it with the necessary device and output objects. Note that
61 the CanvasHelper does <em>not</em> take ownership of the
62 passed rDevice reference, nor does it perform any
63 reference counting. Thus, to prevent the reference counted
64 SpriteCanvas object from deletion, the user of this class
65 is responsible for holding ref-counted references itself!
67 @param rDevice
68 Reference device this canvas is associated with
71 void setDevice( com::sun::star::rendering::XGraphicDevice& rDevice );
73 /** Set the target for rendering operations
75 @param rTarget
76 Render target
78 void setTarget( const GraphicsProviderSharedPtr& rTarget );
80 /** Set the target for rendering operations
82 @param rTarget
83 Render target
85 @param rOutputOffset
86 Output offset in pixel
88 void setTarget( const GraphicsProviderSharedPtr& rTarget,
89 const ::basegfx::B2ISize& rOutputOffset );
92 // CanvasHelper functionality
93 // ==========================
95 // XCanvas (only providing, not implementing the
96 // interface. Also note subtle method parameter differences)
97 void clear();
98 void drawPoint( const ::com::sun::star::rendering::XCanvas* pCanvas,
99 const ::com::sun::star::geometry::RealPoint2D& aPoint,
100 const ::com::sun::star::rendering::ViewState& viewState,
101 const ::com::sun::star::rendering::RenderState& renderState );
102 void drawLine( const ::com::sun::star::rendering::XCanvas* pCanvas,
103 const ::com::sun::star::geometry::RealPoint2D& aStartPoint,
104 const ::com::sun::star::geometry::RealPoint2D& aEndPoint,
105 const ::com::sun::star::rendering::ViewState& viewState,
106 const ::com::sun::star::rendering::RenderState& renderState );
107 void drawBezier( const ::com::sun::star::rendering::XCanvas* pCanvas,
108 const ::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment,
109 const ::com::sun::star::geometry::RealPoint2D& aEndPoint,
110 const ::com::sun::star::rendering::ViewState& viewState,
111 const ::com::sun::star::rendering::RenderState& renderState );
112 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
113 drawPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
114 const ::com::sun::star::uno::Reference<
115 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
116 const ::com::sun::star::rendering::ViewState& viewState,
117 const ::com::sun::star::rendering::RenderState& renderState );
118 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
119 strokePolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
120 const ::com::sun::star::uno::Reference<
121 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
122 const ::com::sun::star::rendering::ViewState& viewState,
123 const ::com::sun::star::rendering::RenderState& renderState,
124 const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
125 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
126 strokeTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
127 const ::com::sun::star::uno::Reference<
128 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
129 const ::com::sun::star::rendering::ViewState& viewState,
130 const ::com::sun::star::rendering::RenderState& renderState,
131 const ::com::sun::star::uno::Sequence<
132 ::com::sun::star::rendering::Texture >& textures,
133 const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
134 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
135 strokeTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
136 const ::com::sun::star::uno::Reference<
137 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
138 const ::com::sun::star::rendering::ViewState& viewState,
139 const ::com::sun::star::rendering::RenderState& renderState,
140 const ::com::sun::star::uno::Sequence<
141 ::com::sun::star::rendering::Texture >& textures,
142 const ::com::sun::star::uno::Reference<
143 ::com::sun::star::geometry::XMapping2D >& xMapping,
144 const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
145 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
146 queryStrokeShapes( const ::com::sun::star::rendering::XCanvas* pCanvas,
147 const ::com::sun::star::uno::Reference<
148 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
149 const ::com::sun::star::rendering::ViewState& viewState,
150 const ::com::sun::star::rendering::RenderState& renderState,
151 const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
152 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
153 fillPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
154 const ::com::sun::star::uno::Reference<
155 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
156 const ::com::sun::star::rendering::ViewState& viewState,
157 const ::com::sun::star::rendering::RenderState& renderState );
158 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
159 fillTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
160 const ::com::sun::star::uno::Reference<
161 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
162 const ::com::sun::star::rendering::ViewState& viewState,
163 const ::com::sun::star::rendering::RenderState& renderState,
164 const ::com::sun::star::uno::Sequence<
165 ::com::sun::star::rendering::Texture >& textures );
166 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
167 fillTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
168 const ::com::sun::star::uno::Reference<
169 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
170 const ::com::sun::star::rendering::ViewState& viewState,
171 const ::com::sun::star::rendering::RenderState& renderState,
172 const ::com::sun::star::uno::Sequence<
173 ::com::sun::star::rendering::Texture >& textures,
174 const ::com::sun::star::uno::Reference<
175 ::com::sun::star::geometry::XMapping2D >& xMapping );
177 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > SAL_CALL
178 createFont( const ::com::sun::star::rendering::XCanvas* pCanvas,
179 const ::com::sun::star::rendering::FontRequest& fontRequest,
180 const ::com::sun::star::uno::Sequence<
181 ::com::sun::star::beans::PropertyValue >& extraFontProperties,
182 const ::com::sun::star::geometry::Matrix2D& fontMatrix );
184 ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::FontInfo >
185 queryAvailableFonts( const ::com::sun::star::rendering::XCanvas* pCanvas,
186 const ::com::sun::star::rendering::FontInfo& aFilter,
187 const ::com::sun::star::uno::Sequence<
188 ::com::sun::star::beans::PropertyValue >& aFontProperties );
190 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
191 drawText( const ::com::sun::star::rendering::XCanvas* pCanvas,
192 const ::com::sun::star::rendering::StringContext& text,
193 const ::com::sun::star::uno::Reference<
194 ::com::sun::star::rendering::XCanvasFont >& xFont,
195 const ::com::sun::star::rendering::ViewState& viewState,
196 const ::com::sun::star::rendering::RenderState& renderState,
197 sal_Int8 textDirection );
199 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
200 drawTextLayout( const ::com::sun::star::rendering::XCanvas* pCanvas,
201 const ::com::sun::star::uno::Reference<
202 ::com::sun::star::rendering::XTextLayout >& layoutetText,
203 const ::com::sun::star::rendering::ViewState& viewState,
204 const ::com::sun::star::rendering::RenderState& renderState );
206 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
207 drawBitmap( const ::com::sun::star::rendering::XCanvas* pCanvas,
208 const ::com::sun::star::uno::Reference<
209 ::com::sun::star::rendering::XBitmap >& xBitmap,
210 const ::com::sun::star::rendering::ViewState& viewState,
211 const ::com::sun::star::rendering::RenderState& renderState );
212 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
213 drawBitmapModulated( const ::com::sun::star::rendering::XCanvas* pCanvas,
214 const ::com::sun::star::uno::Reference<
215 ::com::sun::star::rendering::XBitmap >& xBitmap,
216 const ::com::sun::star::rendering::ViewState& viewState,
217 const ::com::sun::star::rendering::RenderState& renderState );
218 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >
219 getDevice();
221 // Flush drawing queue to screen
222 void flush() const;
224 /** Called from XCanvas base classes, to notify that content
225 is _about_ to change
227 void modifying() {}
229 protected:
230 /// Refcounted global GDI+ state container
231 GDIPlusUserSharedPtr mpGdiPlusUser;
233 /** Phyical output device
235 Deliberately not a refcounted reference, because of
236 potential circular references for spritecanvas.
238 com::sun::star::rendering::XGraphicDevice* mpDevice;
240 /// Provides the Gdiplus::Graphics to render into
241 GraphicsProviderSharedPtr mpGraphicsProvider;
243 bool needOutput() const { return mpGraphicsProvider.get() != NULL; };
245 // returns transparency of color
246 void setupGraphicsState( GraphicsSharedPtr& rGraphics,
247 const ::com::sun::star::rendering::ViewState& viewState,
248 const ::com::sun::star::rendering::RenderState& renderState );
250 Gdiplus::CompositingMode calcCompositingMode( sal_Int8 nMode );
252 /// Current (transformation-independent) output buffer offset
253 ::basegfx::B2ISize maOutputOffset;
257 #endif /* _DXCANVAS_CANVASHELPER_HXX_ */