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 _NULLCANVAS_CANVASHELPER_HXX_
29 #define _NULLCANVAS_CANVASHELPER_HXX_
31 #include <com/sun/star/rendering/XCanvas.hpp>
32 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
34 #include <basegfx/vector/b2isize.hxx>
35 #include <basegfx/vector/b2dsize.hxx>
37 #include <boost/utility.hpp>
44 /** Helper class for basic canvas functionality. Also offers
45 optional backbuffer painting, when providing it with a second
48 class CanvasHelper
: private ::boost::noncopyable
53 /// Release all references
56 /** Initialize canvas helper
58 This method late-initializes the canvas helper, providing
59 it with the necessary device and size. Note that the
60 CanvasHelper does <em>not</em> take ownership of the
61 passed rDevice reference, nor does it perform any
62 reference counting. Thus, to prevent the reference counted
63 SpriteCanvas object from deletion, the user of this class
64 is responsible for holding ref-counted references itself!
67 Size of the output surface in pixel.
70 Reference device this canvas is associated with
73 void init( const ::basegfx::B2ISize
& rSizePixel
,
74 SpriteCanvas
& rDevice
,
78 // CanvasHelper functionality
79 // ==========================
81 // XCanvas (only providing, not implementing the
82 // interface. Also note subtle method parameter differences)
84 void drawPoint( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
85 const ::com::sun::star::geometry::RealPoint2D
& aPoint
,
86 const ::com::sun::star::rendering::ViewState
& viewState
,
87 const ::com::sun::star::rendering::RenderState
& renderState
);
88 void drawLine( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
89 const ::com::sun::star::geometry::RealPoint2D
& aStartPoint
,
90 const ::com::sun::star::geometry::RealPoint2D
& aEndPoint
,
91 const ::com::sun::star::rendering::ViewState
& viewState
,
92 const ::com::sun::star::rendering::RenderState
& renderState
);
93 void drawBezier( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
94 const ::com::sun::star::geometry::RealBezierSegment2D
& aBezierSegment
,
95 const ::com::sun::star::geometry::RealPoint2D
& aEndPoint
,
96 const ::com::sun::star::rendering::ViewState
& viewState
,
97 const ::com::sun::star::rendering::RenderState
& renderState
);
98 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
99 drawPolyPolygon( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
100 const ::com::sun::star::uno::Reference
<
101 ::com::sun::star::rendering::XPolyPolygon2D
>& xPolyPolygon
,
102 const ::com::sun::star::rendering::ViewState
& viewState
,
103 const ::com::sun::star::rendering::RenderState
& renderState
);
104 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
105 strokePolyPolygon( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
106 const ::com::sun::star::uno::Reference
<
107 ::com::sun::star::rendering::XPolyPolygon2D
>& xPolyPolygon
,
108 const ::com::sun::star::rendering::ViewState
& viewState
,
109 const ::com::sun::star::rendering::RenderState
& renderState
,
110 const ::com::sun::star::rendering::StrokeAttributes
& strokeAttributes
);
111 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
112 strokeTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
113 const ::com::sun::star::uno::Reference
<
114 ::com::sun::star::rendering::XPolyPolygon2D
>& xPolyPolygon
,
115 const ::com::sun::star::rendering::ViewState
& viewState
,
116 const ::com::sun::star::rendering::RenderState
& renderState
,
117 const ::com::sun::star::uno::Sequence
<
118 ::com::sun::star::rendering::Texture
>& textures
,
119 const ::com::sun::star::rendering::StrokeAttributes
& strokeAttributes
);
120 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
121 strokeTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
122 const ::com::sun::star::uno::Reference
<
123 ::com::sun::star::rendering::XPolyPolygon2D
>& xPolyPolygon
,
124 const ::com::sun::star::rendering::ViewState
& viewState
,
125 const ::com::sun::star::rendering::RenderState
& renderState
,
126 const ::com::sun::star::uno::Sequence
<
127 ::com::sun::star::rendering::Texture
>& textures
,
128 const ::com::sun::star::uno::Reference
<
129 ::com::sun::star::geometry::XMapping2D
>& xMapping
,
130 const ::com::sun::star::rendering::StrokeAttributes
& strokeAttributes
);
131 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XPolyPolygon2D
>
132 queryStrokeShapes( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
133 const ::com::sun::star::uno::Reference
<
134 ::com::sun::star::rendering::XPolyPolygon2D
>& xPolyPolygon
,
135 const ::com::sun::star::rendering::ViewState
& viewState
,
136 const ::com::sun::star::rendering::RenderState
& renderState
,
137 const ::com::sun::star::rendering::StrokeAttributes
& strokeAttributes
);
138 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
139 fillPolyPolygon( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
140 const ::com::sun::star::uno::Reference
<
141 ::com::sun::star::rendering::XPolyPolygon2D
>& xPolyPolygon
,
142 const ::com::sun::star::rendering::ViewState
& viewState
,
143 const ::com::sun::star::rendering::RenderState
& renderState
);
144 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
145 fillTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
146 const ::com::sun::star::uno::Reference
<
147 ::com::sun::star::rendering::XPolyPolygon2D
>& xPolyPolygon
,
148 const ::com::sun::star::rendering::ViewState
& viewState
,
149 const ::com::sun::star::rendering::RenderState
& renderState
,
150 const ::com::sun::star::uno::Sequence
<
151 ::com::sun::star::rendering::Texture
>& textures
);
152 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
153 fillTextureMappedPolyPolygon( 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 const ::com::sun::star::uno::Sequence
<
159 ::com::sun::star::rendering::Texture
>& textures
,
160 const ::com::sun::star::uno::Reference
<
161 ::com::sun::star::geometry::XMapping2D
>& xMapping
);
163 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCanvasFont
> SAL_CALL
164 createFont( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
165 const ::com::sun::star::rendering::FontRequest
& fontRequest
,
166 const ::com::sun::star::uno::Sequence
<
167 ::com::sun::star::beans::PropertyValue
>& extraFontProperties
,
168 const ::com::sun::star::geometry::Matrix2D
& fontMatrix
);
170 ::com::sun::star::uno::Sequence
< ::com::sun::star::rendering::FontInfo
>
171 queryAvailableFonts( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
172 const ::com::sun::star::rendering::FontInfo
& aFilter
,
173 const ::com::sun::star::uno::Sequence
<
174 ::com::sun::star::beans::PropertyValue
>& aFontProperties
);
176 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
177 drawText( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
178 const ::com::sun::star::rendering::StringContext
& text
,
179 const ::com::sun::star::uno::Reference
<
180 ::com::sun::star::rendering::XCanvasFont
>& xFont
,
181 const ::com::sun::star::rendering::ViewState
& viewState
,
182 const ::com::sun::star::rendering::RenderState
& renderState
,
183 sal_Int8 textDirection
);
185 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
186 drawTextLayout( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
187 const ::com::sun::star::uno::Reference
<
188 ::com::sun::star::rendering::XTextLayout
>& layoutetText
,
189 const ::com::sun::star::rendering::ViewState
& viewState
,
190 const ::com::sun::star::rendering::RenderState
& renderState
);
192 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
193 drawBitmap( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
194 const ::com::sun::star::uno::Reference
<
195 ::com::sun::star::rendering::XBitmap
>& xBitmap
,
196 const ::com::sun::star::rendering::ViewState
& viewState
,
197 const ::com::sun::star::rendering::RenderState
& renderState
);
198 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XCachedPrimitive
>
199 drawBitmapModulated( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
200 const ::com::sun::star::uno::Reference
<
201 ::com::sun::star::rendering::XBitmap
>& xBitmap
,
202 const ::com::sun::star::rendering::ViewState
& viewState
,
203 const ::com::sun::star::rendering::RenderState
& renderState
);
204 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XGraphicDevice
>
207 // BitmapCanvasHelper functionality
208 // ================================
210 void copyRect( const ::com::sun::star::rendering::XCanvas
* pCanvas
,
211 const ::com::sun::star::uno::Reference
<
212 ::com::sun::star::rendering::XBitmapCanvas
>& sourceCanvas
,
213 const ::com::sun::star::geometry::RealRectangle2D
& sourceRect
,
214 const ::com::sun::star::rendering::ViewState
& sourceViewState
,
215 const ::com::sun::star::rendering::RenderState
& sourceRenderState
,
216 const ::com::sun::star::geometry::RealRectangle2D
& destRect
,
217 const ::com::sun::star::rendering::ViewState
& destViewState
,
218 const ::com::sun::star::rendering::RenderState
& destRenderState
);
220 ::com::sun::star::geometry::IntegerSize2D
getSize();
222 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XBitmap
>
223 getScaledBitmap( const ::com::sun::star::geometry::RealSize2D
& newSize
,
226 ::com::sun::star::uno::Sequence
< sal_Int8
>
227 getData( ::com::sun::star::rendering::IntegerBitmapLayout
& bitmapLayout
,
228 const ::com::sun::star::geometry::IntegerRectangle2D
& rect
);
230 void setData( const ::com::sun::star::uno::Sequence
< sal_Int8
>& data
,
231 const ::com::sun::star::rendering::IntegerBitmapLayout
& bitmapLayout
,
232 const ::com::sun::star::geometry::IntegerRectangle2D
& rect
);
234 void setPixel( const ::com::sun::star::uno::Sequence
< sal_Int8
>& color
,
235 const ::com::sun::star::rendering::IntegerBitmapLayout
& bitmapLayout
,
236 const ::com::sun::star::geometry::IntegerPoint2D
& pos
);
238 ::com::sun::star::uno::Sequence
< sal_Int8
>
239 getPixel( ::com::sun::star::rendering::IntegerBitmapLayout
& bitmapLayout
,
240 const ::com::sun::star::geometry::IntegerPoint2D
& pos
);
242 ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XBitmapPalette
> getPalette();
244 ::com::sun::star::rendering::IntegerBitmapLayout
getMemoryLayout();
246 // Flush drawing queue to screen
249 /** Called from XCanvas base classes, to notify that content
254 bool hasAlpha() const;
257 /** Phyical output device
259 Deliberately not a refcounted reference, because of
260 potential circular references for spritecanvas.
262 SpriteCanvas
* mpDevice
;
265 /// Current size of the output surface in pixel
266 ::basegfx::B2ISize maSize
;
268 /// When true, content is able to represent alpha
273 #endif /* _NULLCANVAS_CANVASHELPER_HXX_ */