Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _NULLCANVAS_CANVASHELPER_HXX_
21 : #define _NULLCANVAS_CANVASHELPER_HXX_
22 :
23 : #include <com/sun/star/rendering/XCanvas.hpp>
24 : #include <com/sun/star/rendering/XIntegerBitmap.hpp>
25 :
26 : #include <basegfx/vector/b2isize.hxx>
27 : #include <basegfx/vector/b2dsize.hxx>
28 :
29 : #include <boost/utility.hpp>
30 :
31 :
32 : namespace nullcanvas
33 : {
34 : class SpriteCanvas;
35 :
36 : /** Helper class for basic canvas functionality. Also offers
37 : optional backbuffer painting, when providing it with a second
38 : HDC to render into.
39 : */
40 0 : class CanvasHelper : private ::boost::noncopyable
41 : {
42 : public:
43 : CanvasHelper();
44 :
45 : /// Release all references
46 : void disposing();
47 :
48 : /** Initialize canvas helper
49 :
50 : This method late-initializes the canvas helper, providing
51 : it with the necessary device and size. Note that the
52 : CanvasHelper does <em>not</em> take ownership of the
53 : passed rDevice reference, nor does it perform any
54 : reference counting. Thus, to prevent the reference counted
55 : SpriteCanvas object from deletion, the user of this class
56 : is responsible for holding ref-counted references itself!
57 :
58 : @param rSizePixel
59 : Size of the output surface in pixel.
60 :
61 : @param rDevice
62 : Reference device this canvas is associated with
63 :
64 : */
65 : void init( const ::basegfx::B2ISize& rSizePixel,
66 : SpriteCanvas& rDevice,
67 : bool bHasAlpha );
68 :
69 :
70 : // CanvasHelper functionality
71 : // ==========================
72 :
73 : // XCanvas (only providing, not implementing the
74 : // interface. Also note subtle method parameter differences)
75 : void clear();
76 : void drawPoint( const ::com::sun::star::rendering::XCanvas* pCanvas,
77 : const ::com::sun::star::geometry::RealPoint2D& aPoint,
78 : const ::com::sun::star::rendering::ViewState& viewState,
79 : const ::com::sun::star::rendering::RenderState& renderState );
80 : void drawLine( const ::com::sun::star::rendering::XCanvas* pCanvas,
81 : const ::com::sun::star::geometry::RealPoint2D& aStartPoint,
82 : const ::com::sun::star::geometry::RealPoint2D& aEndPoint,
83 : const ::com::sun::star::rendering::ViewState& viewState,
84 : const ::com::sun::star::rendering::RenderState& renderState );
85 : void drawBezier( const ::com::sun::star::rendering::XCanvas* pCanvas,
86 : const ::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment,
87 : const ::com::sun::star::geometry::RealPoint2D& aEndPoint,
88 : const ::com::sun::star::rendering::ViewState& viewState,
89 : const ::com::sun::star::rendering::RenderState& renderState );
90 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
91 : drawPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
92 : const ::com::sun::star::uno::Reference<
93 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
94 : const ::com::sun::star::rendering::ViewState& viewState,
95 : const ::com::sun::star::rendering::RenderState& renderState );
96 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
97 : strokePolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
98 : const ::com::sun::star::uno::Reference<
99 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
100 : const ::com::sun::star::rendering::ViewState& viewState,
101 : const ::com::sun::star::rendering::RenderState& renderState,
102 : const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
103 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
104 : strokeTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
105 : const ::com::sun::star::uno::Reference<
106 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
107 : const ::com::sun::star::rendering::ViewState& viewState,
108 : const ::com::sun::star::rendering::RenderState& renderState,
109 : const ::com::sun::star::uno::Sequence<
110 : ::com::sun::star::rendering::Texture >& textures,
111 : const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
112 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
113 : strokeTextureMappedPolyPolygon( 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 : const ::com::sun::star::uno::Sequence<
119 : ::com::sun::star::rendering::Texture >& textures,
120 : const ::com::sun::star::uno::Reference<
121 : ::com::sun::star::geometry::XMapping2D >& xMapping,
122 : const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
123 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
124 : queryStrokeShapes( const ::com::sun::star::rendering::XCanvas* pCanvas,
125 : const ::com::sun::star::uno::Reference<
126 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
127 : const ::com::sun::star::rendering::ViewState& viewState,
128 : const ::com::sun::star::rendering::RenderState& renderState,
129 : const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
130 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
131 : fillPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
132 : const ::com::sun::star::uno::Reference<
133 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
134 : const ::com::sun::star::rendering::ViewState& viewState,
135 : const ::com::sun::star::rendering::RenderState& renderState );
136 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
137 : fillTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
138 : const ::com::sun::star::uno::Reference<
139 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
140 : const ::com::sun::star::rendering::ViewState& viewState,
141 : const ::com::sun::star::rendering::RenderState& renderState,
142 : const ::com::sun::star::uno::Sequence<
143 : ::com::sun::star::rendering::Texture >& textures );
144 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
145 : fillTextureMappedPolyPolygon( 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 : const ::com::sun::star::uno::Reference<
153 : ::com::sun::star::geometry::XMapping2D >& xMapping );
154 :
155 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > SAL_CALL
156 : createFont( const ::com::sun::star::rendering::XCanvas* pCanvas,
157 : const ::com::sun::star::rendering::FontRequest& fontRequest,
158 : const ::com::sun::star::uno::Sequence<
159 : ::com::sun::star::beans::PropertyValue >& extraFontProperties,
160 : const ::com::sun::star::geometry::Matrix2D& fontMatrix );
161 :
162 : ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::FontInfo >
163 : queryAvailableFonts( const ::com::sun::star::rendering::XCanvas* pCanvas,
164 : const ::com::sun::star::rendering::FontInfo& aFilter,
165 : const ::com::sun::star::uno::Sequence<
166 : ::com::sun::star::beans::PropertyValue >& aFontProperties );
167 :
168 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
169 : drawText( const ::com::sun::star::rendering::XCanvas* pCanvas,
170 : const ::com::sun::star::rendering::StringContext& text,
171 : const ::com::sun::star::uno::Reference<
172 : ::com::sun::star::rendering::XCanvasFont >& xFont,
173 : const ::com::sun::star::rendering::ViewState& viewState,
174 : const ::com::sun::star::rendering::RenderState& renderState,
175 : sal_Int8 textDirection );
176 :
177 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
178 : drawTextLayout( const ::com::sun::star::rendering::XCanvas* pCanvas,
179 : const ::com::sun::star::uno::Reference<
180 : ::com::sun::star::rendering::XTextLayout >& layoutetText,
181 : const ::com::sun::star::rendering::ViewState& viewState,
182 : const ::com::sun::star::rendering::RenderState& renderState );
183 :
184 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
185 : drawBitmap( const ::com::sun::star::rendering::XCanvas* pCanvas,
186 : const ::com::sun::star::uno::Reference<
187 : ::com::sun::star::rendering::XBitmap >& xBitmap,
188 : const ::com::sun::star::rendering::ViewState& viewState,
189 : const ::com::sun::star::rendering::RenderState& renderState );
190 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
191 : drawBitmapModulated( const ::com::sun::star::rendering::XCanvas* pCanvas,
192 : const ::com::sun::star::uno::Reference<
193 : ::com::sun::star::rendering::XBitmap >& xBitmap,
194 : const ::com::sun::star::rendering::ViewState& viewState,
195 : const ::com::sun::star::rendering::RenderState& renderState );
196 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >
197 : getDevice();
198 :
199 : // BitmapCanvasHelper functionality
200 : // ================================
201 :
202 : void copyRect( const ::com::sun::star::rendering::XCanvas* pCanvas,
203 : const ::com::sun::star::uno::Reference<
204 : ::com::sun::star::rendering::XBitmapCanvas >& sourceCanvas,
205 : const ::com::sun::star::geometry::RealRectangle2D& sourceRect,
206 : const ::com::sun::star::rendering::ViewState& sourceViewState,
207 : const ::com::sun::star::rendering::RenderState& sourceRenderState,
208 : const ::com::sun::star::geometry::RealRectangle2D& destRect,
209 : const ::com::sun::star::rendering::ViewState& destViewState,
210 : const ::com::sun::star::rendering::RenderState& destRenderState );
211 :
212 : ::com::sun::star::geometry::IntegerSize2D getSize();
213 :
214 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >
215 : getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize,
216 : sal_Bool beFast );
217 :
218 : ::com::sun::star::uno::Sequence< sal_Int8 >
219 : getData( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
220 : const ::com::sun::star::geometry::IntegerRectangle2D& rect );
221 :
222 : void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data,
223 : const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
224 : const ::com::sun::star::geometry::IntegerRectangle2D& rect );
225 :
226 : void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color,
227 : const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
228 : const ::com::sun::star::geometry::IntegerPoint2D& pos );
229 :
230 : ::com::sun::star::uno::Sequence< sal_Int8 >
231 : getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
232 : const ::com::sun::star::geometry::IntegerPoint2D& pos );
233 :
234 : ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout();
235 :
236 : /** Called from XCanvas base classes, to notify that content
237 : is _about_ to change
238 : */
239 0 : void modifying() {}
240 :
241 : bool hasAlpha() const;
242 :
243 : protected:
244 : /** Phyical output device
245 :
246 : Deliberately not a refcounted reference, because of
247 : potential circular references for spritecanvas.
248 : */
249 : SpriteCanvas* mpDevice;
250 :
251 : private:
252 : /// Current size of the output surface in pixel
253 : ::basegfx::B2ISize maSize;
254 :
255 : /// When true, content is able to represent alpha
256 : bool mbHaveAlpha;
257 : };
258 : }
259 :
260 : #endif /* _NULLCANVAS_CANVASHELPER_HXX_ */
261 :
262 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|