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 :
10 : #ifndef INCLUDED_CANVAS_SOURCE_OPENGL_OGL_CANVASHELPER_HXX
11 : #define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_CANVASHELPER_HXX
12 :
13 : #include <com/sun/star/rendering/XCanvas.hpp>
14 :
15 : #include <basegfx/vector/b2isize.hxx>
16 : #include <basegfx/vector/b2dsize.hxx>
17 :
18 : #include <o3tl/cow_wrapper.hxx>
19 : #include <vector>
20 :
21 : namespace oglcanvas
22 : {
23 : class SpriteDeviceHelper;
24 :
25 : /** Helper class for basic canvas functionality. */
26 : class CanvasHelper
27 : {
28 : public:
29 : CanvasHelper();
30 :
31 : // outline because of incomplete type Action
32 : ~CanvasHelper();
33 : CanvasHelper& operator=( const CanvasHelper& );
34 :
35 : /// Release all references
36 : void disposing();
37 :
38 : /** Initialize canvas helper
39 :
40 : This method late-initializes the canvas helper, providing
41 : it with the necessary device and output objects. Note that
42 : the CanvasHelper does <em>not</em> take ownership of the
43 : passed rDevice reference, nor does it perform any
44 : reference counting. Thus, to prevent the reference counted
45 : SpriteCanvas object from deletion, the user of this class
46 : is responsible for holding ref-counted references itself!
47 :
48 : @param rDevice
49 : Reference device this canvas is associated with
50 :
51 : */
52 : void init( ::com::sun::star::rendering::XGraphicDevice& rDevice,
53 : SpriteDeviceHelper& rDeviceHelper );
54 :
55 : // CanvasHelper functionality
56 : // ==========================
57 :
58 : // XCanvas (only providing, not implementing the
59 : // interface. Also note subtle method parameter differences)
60 : void clear();
61 : void drawPoint( const ::com::sun::star::rendering::XCanvas* pCanvas,
62 : const ::com::sun::star::geometry::RealPoint2D& aPoint,
63 : const ::com::sun::star::rendering::ViewState& viewState,
64 : const ::com::sun::star::rendering::RenderState& renderState );
65 : void drawLine( const ::com::sun::star::rendering::XCanvas* pCanvas,
66 : const ::com::sun::star::geometry::RealPoint2D& aStartPoint,
67 : const ::com::sun::star::geometry::RealPoint2D& aEndPoint,
68 : const ::com::sun::star::rendering::ViewState& viewState,
69 : const ::com::sun::star::rendering::RenderState& renderState );
70 : void drawBezier( const ::com::sun::star::rendering::XCanvas* pCanvas,
71 : const ::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment,
72 : const ::com::sun::star::geometry::RealPoint2D& aEndPoint,
73 : const ::com::sun::star::rendering::ViewState& viewState,
74 : const ::com::sun::star::rendering::RenderState& renderState );
75 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
76 : drawPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
77 : const ::com::sun::star::uno::Reference<
78 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
79 : const ::com::sun::star::rendering::ViewState& viewState,
80 : const ::com::sun::star::rendering::RenderState& renderState );
81 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
82 : strokePolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
83 : const ::com::sun::star::uno::Reference<
84 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
85 : const ::com::sun::star::rendering::ViewState& viewState,
86 : const ::com::sun::star::rendering::RenderState& renderState,
87 : const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
88 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
89 : strokeTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
90 : const ::com::sun::star::uno::Reference<
91 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
92 : const ::com::sun::star::rendering::ViewState& viewState,
93 : const ::com::sun::star::rendering::RenderState& renderState,
94 : const ::com::sun::star::uno::Sequence<
95 : ::com::sun::star::rendering::Texture >& textures,
96 : const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
97 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
98 : strokeTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
99 : const ::com::sun::star::uno::Reference<
100 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
101 : const ::com::sun::star::rendering::ViewState& viewState,
102 : const ::com::sun::star::rendering::RenderState& renderState,
103 : const ::com::sun::star::uno::Sequence<
104 : ::com::sun::star::rendering::Texture >& textures,
105 : const ::com::sun::star::uno::Reference<
106 : ::com::sun::star::geometry::XMapping2D >& xMapping,
107 : const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
108 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
109 : queryStrokeShapes( const ::com::sun::star::rendering::XCanvas* pCanvas,
110 : const ::com::sun::star::uno::Reference<
111 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
112 : const ::com::sun::star::rendering::ViewState& viewState,
113 : const ::com::sun::star::rendering::RenderState& renderState,
114 : const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
115 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
116 : fillPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
117 : const ::com::sun::star::uno::Reference<
118 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
119 : const ::com::sun::star::rendering::ViewState& viewState,
120 : const ::com::sun::star::rendering::RenderState& renderState );
121 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
122 : fillTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
123 : const ::com::sun::star::uno::Reference<
124 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
125 : const ::com::sun::star::rendering::ViewState& viewState,
126 : const ::com::sun::star::rendering::RenderState& renderState,
127 : const ::com::sun::star::uno::Sequence<
128 : ::com::sun::star::rendering::Texture >& textures );
129 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
130 : fillTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
131 : const ::com::sun::star::uno::Reference<
132 : ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
133 : const ::com::sun::star::rendering::ViewState& viewState,
134 : const ::com::sun::star::rendering::RenderState& renderState,
135 : const ::com::sun::star::uno::Sequence<
136 : ::com::sun::star::rendering::Texture >& textures,
137 : const ::com::sun::star::uno::Reference<
138 : ::com::sun::star::geometry::XMapping2D >& xMapping );
139 :
140 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > SAL_CALL
141 : createFont( const ::com::sun::star::rendering::XCanvas* pCanvas,
142 : const ::com::sun::star::rendering::FontRequest& fontRequest,
143 : const ::com::sun::star::uno::Sequence<
144 : ::com::sun::star::beans::PropertyValue >& extraFontProperties,
145 : const ::com::sun::star::geometry::Matrix2D& fontMatrix );
146 :
147 : ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::FontInfo >
148 : queryAvailableFonts( const ::com::sun::star::rendering::XCanvas* pCanvas,
149 : const ::com::sun::star::rendering::FontInfo& aFilter,
150 : const ::com::sun::star::uno::Sequence<
151 : ::com::sun::star::beans::PropertyValue >& aFontProperties );
152 :
153 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
154 : drawText( const ::com::sun::star::rendering::XCanvas* pCanvas,
155 : const ::com::sun::star::rendering::StringContext& text,
156 : const ::com::sun::star::uno::Reference<
157 : ::com::sun::star::rendering::XCanvasFont >& xFont,
158 : const ::com::sun::star::rendering::ViewState& viewState,
159 : const ::com::sun::star::rendering::RenderState& renderState,
160 : sal_Int8 textDirection );
161 :
162 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
163 : drawTextLayout( const ::com::sun::star::rendering::XCanvas* pCanvas,
164 : const ::com::sun::star::uno::Reference<
165 : ::com::sun::star::rendering::XTextLayout >& layoutetText,
166 : const ::com::sun::star::rendering::ViewState& viewState,
167 : const ::com::sun::star::rendering::RenderState& renderState );
168 :
169 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
170 : drawBitmap( const ::com::sun::star::rendering::XCanvas* pCanvas,
171 : const ::com::sun::star::uno::Reference<
172 : ::com::sun::star::rendering::XBitmap >& xBitmap,
173 : const ::com::sun::star::rendering::ViewState& viewState,
174 : const ::com::sun::star::rendering::RenderState& renderState );
175 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
176 : drawBitmapModulated( const ::com::sun::star::rendering::XCanvas* pCanvas,
177 : const ::com::sun::star::uno::Reference<
178 : ::com::sun::star::rendering::XBitmap >& xBitmap,
179 : const ::com::sun::star::rendering::ViewState& viewState,
180 : const ::com::sun::star::rendering::RenderState& renderState );
181 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >
182 0 : getDevice() { return css::uno::Reference< css::rendering::XGraphicDevice >(mpDevice); }
183 :
184 : /** Write out recorded actions
185 : */
186 : bool renderRecordedActions() const;
187 :
188 : /** Retrieve number of recorded actions
189 : */
190 : size_t getRecordedActionCount() const;
191 :
192 0 : SpriteDeviceHelper* getDeviceHelper() const { return mpDeviceHelper; }
193 0 : ::com::sun::star::rendering::XGraphicDevice* getDevice() const { return mpDevice; }
194 :
195 : struct Action;
196 : typedef o3tl::cow_wrapper< std::vector<Action>,
197 : o3tl::ThreadSafeRefCountingPolicy > RecordVectorT;
198 :
199 : private:
200 : CanvasHelper( const CanvasHelper& ) SAL_DELETED_FUNCTION;
201 :
202 : void setupGraphicsState( Action& o_action,
203 : const ::com::sun::star::rendering::ViewState& viewState,
204 : const ::com::sun::star::rendering::RenderState& renderState );
205 :
206 : /** Phyical output device
207 :
208 : Deliberately not a refcounted reference, because of
209 : potential circular references for spritecanvas.
210 : */
211 : ::com::sun::star::rendering::XGraphicDevice* mpDevice;
212 :
213 : /** Internal helper - used for a few global GL objects,
214 : e.g. shader programs; and caches
215 : */
216 : SpriteDeviceHelper* mpDeviceHelper;
217 :
218 : /** Ptr to array of recorded render calls
219 :
220 : Gets shared copy-on-write, when this CanvasHelper is
221 : copied (used e.g. for CanvasBitmap)
222 : */
223 : RecordVectorT mpRecordedActions;
224 : };
225 : }
226 :
227 : #endif
228 :
229 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|