1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #ifndef INCLUDED_CANVAS_SOURCE_OPENGL_OGL_CANVASHELPER_HXX
11 #define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_CANVASHELPER_HXX
13 #include <com/sun/star/rendering/XCanvas.hpp>
15 #include <basegfx/vector/b2isize.hxx>
16 #include <basegfx/vector/b2dsize.hxx>
18 #include <o3tl/cow_wrapper.hxx>
23 class SpriteDeviceHelper
;
25 /** Helper class for basic canvas functionality. */
31 // outline because of incomplete type Action
33 CanvasHelper
& operator=( const CanvasHelper
& );
35 /// Release all references
38 /** Initialize canvas helper
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!
49 Reference device this canvas is associated with
52 void init( ::com::sun::star::rendering::XGraphicDevice
& rDevice
,
53 SpriteDeviceHelper
& rDeviceHelper
);
55 // CanvasHelper functionality
56 // ==========================
58 // XCanvas (only providing, not implementing the
59 // interface. Also note subtle method parameter differences)
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
);
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
);
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
);
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
);
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
);
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 getDevice() { return css::uno::Reference
< css::rendering::XGraphicDevice
>(mpDevice
); }
184 /** Write out recorded actions
186 bool renderRecordedActions() const;
188 /** Retrieve number of recorded actions
190 size_t getRecordedActionCount() const;
192 SpriteDeviceHelper
* getDeviceHelper() const { return mpDeviceHelper
; }
193 ::com::sun::star::rendering::XGraphicDevice
* getDevice() const { return mpDevice
; }
196 typedef o3tl::cow_wrapper
< std::vector
<Action
>,
197 o3tl::ThreadSafeRefCountingPolicy
> RecordVectorT
;
200 CanvasHelper( const CanvasHelper
& ) SAL_DELETED_FUNCTION
;
202 void setupGraphicsState( Action
& o_action
,
203 const ::com::sun::star::rendering::ViewState
& viewState
,
204 const ::com::sun::star::rendering::RenderState
& renderState
);
206 /** Phyical output device
208 Deliberately not a refcounted reference, because of
209 potential circular references for spritecanvas.
211 ::com::sun::star::rendering::XGraphicDevice
* mpDevice
;
213 /** Internal helper - used for a few global GL objects,
214 e.g. shader programs; and caches
216 SpriteDeviceHelper
* mpDeviceHelper
;
218 /** Ptr to array of recorded render calls
220 Gets shared copy-on-write, when this CanvasHelper is
221 copied (used e.g. for CanvasBitmap)
223 RecordVectorT mpRecordedActions
;
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */