LibreOffice Module canvas (master)  1
ogl_canvashelper.hxx
Go to the documentation of this file.
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 <o3tl/cow_wrapper.hxx>
16 #include <vector>
17 
18 namespace oglcanvas
19 {
20  class SpriteDeviceHelper;
21 
24  {
25  public:
26  CanvasHelper();
27 
28  // outline because of incomplete type Action
29  ~CanvasHelper();
31 
33  void disposing();
34 
49  void init( css::rendering::XGraphicDevice& rDevice,
50  SpriteDeviceHelper& rDeviceHelper );
51 
52  // CanvasHelper functionality
53  // ==========================
54 
55  // XCanvas (only providing, not implementing the
56  // interface. Also note subtle method parameter differences)
57  void clear();
58  void drawLine( const css::rendering::XCanvas* pCanvas,
59  const css::geometry::RealPoint2D& aStartPoint,
60  const css::geometry::RealPoint2D& aEndPoint,
61  const css::rendering::ViewState& viewState,
62  const css::rendering::RenderState& renderState );
63  void drawBezier( const css::rendering::XCanvas* pCanvas,
64  const css::geometry::RealBezierSegment2D& aBezierSegment,
65  const css::geometry::RealPoint2D& aEndPoint,
66  const css::rendering::ViewState& viewState,
67  const css::rendering::RenderState& renderState );
68  css::uno::Reference< css::rendering::XCachedPrimitive >
69  drawPolyPolygon( const css::rendering::XCanvas* pCanvas,
70  const css::uno::Reference<
71  css::rendering::XPolyPolygon2D >& xPolyPolygon,
72  const css::rendering::ViewState& viewState,
73  const css::rendering::RenderState& renderState );
74  css::uno::Reference< css::rendering::XCachedPrimitive >
75  strokePolyPolygon( const css::rendering::XCanvas* pCanvas,
76  const css::uno::Reference<
77  css::rendering::XPolyPolygon2D >& xPolyPolygon,
78  const css::rendering::ViewState& viewState,
79  const css::rendering::RenderState& renderState,
80  const css::rendering::StrokeAttributes& strokeAttributes );
81  css::uno::Reference< css::rendering::XCachedPrimitive >
82  strokeTexturedPolyPolygon( const css::rendering::XCanvas* pCanvas,
83  const css::uno::Reference<
84  css::rendering::XPolyPolygon2D >& xPolyPolygon,
85  const css::rendering::ViewState& viewState,
86  const css::rendering::RenderState& renderState,
87  const css::uno::Sequence<
88  css::rendering::Texture >& textures,
89  const css::rendering::StrokeAttributes& strokeAttributes );
90  css::uno::Reference< css::rendering::XCachedPrimitive >
91  strokeTextureMappedPolyPolygon( const css::rendering::XCanvas* pCanvas,
92  const css::uno::Reference<
93  css::rendering::XPolyPolygon2D >& xPolyPolygon,
94  const css::rendering::ViewState& viewState,
95  const css::rendering::RenderState& renderState,
96  const css::uno::Sequence<
97  css::rendering::Texture >& textures,
98  const css::uno::Reference<
99  css::geometry::XMapping2D >& xMapping,
100  const css::rendering::StrokeAttributes& strokeAttributes );
101  css::uno::Reference< css::rendering::XPolyPolygon2D >
102  queryStrokeShapes( const css::rendering::XCanvas* pCanvas,
103  const css::uno::Reference<
104  css::rendering::XPolyPolygon2D >& xPolyPolygon,
105  const css::rendering::ViewState& viewState,
106  const css::rendering::RenderState& renderState,
107  const css::rendering::StrokeAttributes& strokeAttributes );
108  css::uno::Reference< css::rendering::XCachedPrimitive >
109  fillPolyPolygon( const css::rendering::XCanvas* pCanvas,
110  const css::uno::Reference<
111  css::rendering::XPolyPolygon2D >& xPolyPolygon,
112  const css::rendering::ViewState& viewState,
113  const css::rendering::RenderState& renderState );
114  css::uno::Reference< css::rendering::XCachedPrimitive >
115  fillTexturedPolyPolygon( const css::rendering::XCanvas* pCanvas,
116  const css::uno::Reference<
117  css::rendering::XPolyPolygon2D >& xPolyPolygon,
118  const css::rendering::ViewState& viewState,
119  const css::rendering::RenderState& renderState,
120  const css::uno::Sequence<
121  css::rendering::Texture >& textures );
122  css::uno::Reference< css::rendering::XCachedPrimitive >
123  fillTextureMappedPolyPolygon( const css::rendering::XCanvas* pCanvas,
124  const css::uno::Reference<
125  css::rendering::XPolyPolygon2D >& xPolyPolygon,
126  const css::rendering::ViewState& viewState,
127  const css::rendering::RenderState& renderState,
128  const css::uno::Sequence<
129  css::rendering::Texture >& textures,
130  const css::uno::Reference<
131  css::geometry::XMapping2D >& xMapping );
132 
133  css::uno::Reference< css::rendering::XCanvasFont >
134  createFont( const css::rendering::XCanvas* pCanvas,
135  const css::rendering::FontRequest& fontRequest,
136  const css::uno::Sequence<
137  css::beans::PropertyValue >& extraFontProperties,
138  const css::geometry::Matrix2D& fontMatrix );
139 
140  css::uno::Sequence< css::rendering::FontInfo >
141  queryAvailableFonts( const css::rendering::XCanvas* pCanvas,
142  const css::rendering::FontInfo& aFilter,
143  const css::uno::Sequence<
144  css::beans::PropertyValue >& aFontProperties );
145 
146  css::uno::Reference< css::rendering::XCachedPrimitive >
147  drawText( const css::rendering::XCanvas* pCanvas,
148  const css::rendering::StringContext& text,
149  const css::uno::Reference<
150  css::rendering::XCanvasFont >& xFont,
151  const css::rendering::ViewState& viewState,
152  const css::rendering::RenderState& renderState,
153  sal_Int8 textDirection );
154 
155  css::uno::Reference< css::rendering::XCachedPrimitive >
156  drawTextLayout( const css::rendering::XCanvas* pCanvas,
157  const css::uno::Reference<
158  css::rendering::XTextLayout >& layoutetText,
159  const css::rendering::ViewState& viewState,
160  const css::rendering::RenderState& renderState );
161 
162  css::uno::Reference< css::rendering::XCachedPrimitive >
163  drawBitmap( const css::rendering::XCanvas* pCanvas,
164  const css::uno::Reference<
165  css::rendering::XBitmap >& xBitmap,
166  const css::rendering::ViewState& viewState,
167  const css::rendering::RenderState& renderState );
168  css::uno::Reference< css::rendering::XCachedPrimitive >
169  drawBitmapModulated( const css::rendering::XCanvas* pCanvas,
170  const css::uno::Reference<
171  css::rendering::XBitmap >& xBitmap,
172  const css::rendering::ViewState& viewState,
173  const css::rendering::RenderState& renderState );
174  css::uno::Reference< css::rendering::XGraphicDevice >
175  getDevice() { return css::uno::Reference< css::rendering::XGraphicDevice >(mpDevice); }
176 
179  bool renderRecordedActions() const;
180 
183  size_t getRecordedActionCount() const;
184 
186  css::rendering::XGraphicDevice* getDevice() const { return mpDevice; }
187 
188  struct Action;
191 
192  private:
193  CanvasHelper( const CanvasHelper& ) = delete;
194 
195  void setupGraphicsState( Action& o_action,
196  const css::rendering::ViewState& viewState,
197  const css::rendering::RenderState& renderState );
198 
204  css::rendering::XGraphicDevice* mpDevice;
205 
210 
216  RecordVectorT mpRecordedActions;
217  };
218 }
219 
220 #endif
221 
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::rendering::XCachedPrimitive > strokePolyPolygon(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XPolyPolygon2D > &xPolyPolygon, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, const css::rendering::StrokeAttributes &strokeAttributes)
void setupGraphicsState(Action &o_action, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
css::uno::Reference< css::rendering::XCachedPrimitive > drawPolyPolygon(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XPolyPolygon2D > &xPolyPolygon, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
signed char sal_Int8
css::uno::Reference< css::rendering::XCachedPrimitive > fillPolyPolygon(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XPolyPolygon2D > &xPolyPolygon, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
Helper class for basic canvas functionality.
css::uno::Reference< css::rendering::XCachedPrimitive > drawBitmap(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XBitmap > &xBitmap, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
css::uno::Reference< css::rendering::XPolyPolygon2D > queryStrokeShapes(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XPolyPolygon2D > &xPolyPolygon, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, const css::rendering::StrokeAttributes &strokeAttributes)
css::uno::Reference< css::rendering::XCachedPrimitive > drawBitmapModulated(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XBitmap > &xBitmap, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
css::uno::Reference< css::rendering::XCanvasFont > createFont(const css::rendering::XCanvas *pCanvas, const css::rendering::FontRequest &fontRequest, const css::uno::Sequence< css::beans::PropertyValue > &extraFontProperties, const css::geometry::Matrix2D &fontMatrix)
css::rendering::XGraphicDevice * getDevice() const
css::uno::Sequence< css::rendering::FontInfo > queryAvailableFonts(const css::rendering::XCanvas *pCanvas, const css::rendering::FontInfo &aFilter, const css::uno::Sequence< css::beans::PropertyValue > &aFontProperties)
css::uno::Reference< css::rendering::XCachedPrimitive > fillTextureMappedPolyPolygon(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XPolyPolygon2D > &xPolyPolygon, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, const css::uno::Sequence< css::rendering::Texture > &textures, const css::uno::Reference< css::geometry::XMapping2D > &xMapping)
o3tl::cow_wrapper< std::vector< Action >, o3tl::ThreadSafeRefCountingPolicy > RecordVectorT
css::uno::Reference< css::rendering::XCachedPrimitive > drawTextLayout(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XTextLayout > &layoutetText, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
SpriteDeviceHelper * mpDeviceHelper
Internal helper - used for a few global GL objects, e.g.
void disposing()
Release all references.
css::uno::Reference< css::rendering::XCachedPrimitive > strokeTextureMappedPolyPolygon(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XPolyPolygon2D > &xPolyPolygon, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, const css::uno::Sequence< css::rendering::Texture > &textures, const css::uno::Reference< css::geometry::XMapping2D > &xMapping, const css::rendering::StrokeAttributes &strokeAttributes)
css::rendering::XGraphicDevice * mpDevice
Phyical output device.
void drawLine(const css::rendering::XCanvas *pCanvas, const css::geometry::RealPoint2D &aStartPoint, const css::geometry::RealPoint2D &aEndPoint, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
RecordVectorT mpRecordedActions
Ptr to array of recorded render calls.
bool renderRecordedActions() const
Write out recorded actions.
css::uno::Reference< css::rendering::XCachedPrimitive > strokeTexturedPolyPolygon(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XPolyPolygon2D > &xPolyPolygon, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, const css::uno::Sequence< css::rendering::Texture > &textures, const css::rendering::StrokeAttributes &strokeAttributes)
css::uno::Reference< css::rendering::XCachedPrimitive > fillTexturedPolyPolygon(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XPolyPolygon2D > &xPolyPolygon, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, const css::uno::Sequence< css::rendering::Texture > &textures)
SpriteDeviceHelper * getDeviceHelper() const
void init(css::rendering::XGraphicDevice &rDevice, SpriteDeviceHelper &rDeviceHelper)
Initialize canvas helper.
void drawBezier(const css::rendering::XCanvas *pCanvas, const css::geometry::RealBezierSegment2D &aBezierSegment, const css::geometry::RealPoint2D &aEndPoint, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
CanvasHelper & operator=(const CanvasHelper &)
def text(shape, st)
css::uno::Reference< css::rendering::XGraphicDevice > getDevice()
size_t getRecordedActionCount() const
Retrieve number of recorded actions.
css::uno::Reference< css::rendering::XCachedPrimitive > drawText(const css::rendering::XCanvas *pCanvas, const css::rendering::StringContext &text, const css::uno::Reference< css::rendering::XCanvasFont > &xFont, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, sal_Int8 textDirection)