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 #pragma once
11 
12 #include <com/sun/star/rendering/XCanvas.hpp>
13 
14 #include <o3tl/cow_wrapper.hxx>
15 #include <vector>
16 
17 namespace oglcanvas
18 {
19  class SpriteDeviceHelper;
20 
23  {
24  public:
25  CanvasHelper();
26 
27  // outline because of incomplete type Action
28  ~CanvasHelper();
30 
32  void disposing();
33 
48  void init( css::rendering::XGraphicDevice& rDevice,
49  SpriteDeviceHelper& rDeviceHelper );
50 
51  // CanvasHelper functionality
52  // ==========================
53 
54  // XCanvas (only providing, not implementing the
55  // interface. Also note subtle method parameter differences)
56  void clear();
57  void drawLine( const css::rendering::XCanvas* pCanvas,
58  const css::geometry::RealPoint2D& aStartPoint,
59  const css::geometry::RealPoint2D& aEndPoint,
60  const css::rendering::ViewState& viewState,
61  const css::rendering::RenderState& renderState );
62  void drawBezier( const css::rendering::XCanvas* pCanvas,
63  const css::geometry::RealBezierSegment2D& aBezierSegment,
64  const css::geometry::RealPoint2D& aEndPoint,
65  const css::rendering::ViewState& viewState,
66  const css::rendering::RenderState& renderState );
67  css::uno::Reference< css::rendering::XCachedPrimitive >
68  drawPolyPolygon( const css::rendering::XCanvas* pCanvas,
69  const css::uno::Reference<
70  css::rendering::XPolyPolygon2D >& xPolyPolygon,
71  const css::rendering::ViewState& viewState,
72  const css::rendering::RenderState& renderState );
73  css::uno::Reference< css::rendering::XCachedPrimitive >
74  strokePolyPolygon( const css::rendering::XCanvas* pCanvas,
75  const css::uno::Reference<
76  css::rendering::XPolyPolygon2D >& xPolyPolygon,
77  const css::rendering::ViewState& viewState,
78  const css::rendering::RenderState& renderState,
79  const css::rendering::StrokeAttributes& strokeAttributes );
80  css::uno::Reference< css::rendering::XCachedPrimitive >
81  strokeTexturedPolyPolygon( const css::rendering::XCanvas* pCanvas,
82  const css::uno::Reference<
83  css::rendering::XPolyPolygon2D >& xPolyPolygon,
84  const css::rendering::ViewState& viewState,
85  const css::rendering::RenderState& renderState,
86  const css::uno::Sequence<
87  css::rendering::Texture >& textures,
88  const css::rendering::StrokeAttributes& strokeAttributes );
89  css::uno::Reference< css::rendering::XCachedPrimitive >
90  strokeTextureMappedPolyPolygon( const css::rendering::XCanvas* pCanvas,
91  const css::uno::Reference<
92  css::rendering::XPolyPolygon2D >& xPolyPolygon,
93  const css::rendering::ViewState& viewState,
94  const css::rendering::RenderState& renderState,
95  const css::uno::Sequence<
96  css::rendering::Texture >& textures,
97  const css::uno::Reference<
98  css::geometry::XMapping2D >& xMapping,
99  const css::rendering::StrokeAttributes& strokeAttributes );
100  css::uno::Reference< css::rendering::XPolyPolygon2D >
101  queryStrokeShapes( const css::rendering::XCanvas* pCanvas,
102  const css::uno::Reference<
103  css::rendering::XPolyPolygon2D >& xPolyPolygon,
104  const css::rendering::ViewState& viewState,
105  const css::rendering::RenderState& renderState,
106  const css::rendering::StrokeAttributes& strokeAttributes );
107  css::uno::Reference< css::rendering::XCachedPrimitive >
108  fillPolyPolygon( const css::rendering::XCanvas* pCanvas,
109  const css::uno::Reference<
110  css::rendering::XPolyPolygon2D >& xPolyPolygon,
111  const css::rendering::ViewState& viewState,
112  const css::rendering::RenderState& renderState );
113  css::uno::Reference< css::rendering::XCachedPrimitive >
114  fillTexturedPolyPolygon( const css::rendering::XCanvas* pCanvas,
115  const css::uno::Reference<
116  css::rendering::XPolyPolygon2D >& xPolyPolygon,
117  const css::rendering::ViewState& viewState,
118  const css::rendering::RenderState& renderState,
119  const css::uno::Sequence<
120  css::rendering::Texture >& textures );
121  css::uno::Reference< css::rendering::XCachedPrimitive >
122  fillTextureMappedPolyPolygon( const css::rendering::XCanvas* pCanvas,
123  const css::uno::Reference<
124  css::rendering::XPolyPolygon2D >& xPolyPolygon,
125  const css::rendering::ViewState& viewState,
126  const css::rendering::RenderState& renderState,
127  const css::uno::Sequence<
128  css::rendering::Texture >& textures,
129  const css::uno::Reference<
130  css::geometry::XMapping2D >& xMapping );
131 
132  css::uno::Reference< css::rendering::XCanvasFont >
133  createFont( const css::rendering::XCanvas* pCanvas,
134  const css::rendering::FontRequest& fontRequest,
135  const css::uno::Sequence<
136  css::beans::PropertyValue >& extraFontProperties,
137  const css::geometry::Matrix2D& fontMatrix );
138 
139  css::uno::Sequence< css::rendering::FontInfo >
140  queryAvailableFonts( const css::rendering::XCanvas* pCanvas,
141  const css::rendering::FontInfo& aFilter,
142  const css::uno::Sequence<
143  css::beans::PropertyValue >& aFontProperties );
144 
145  css::uno::Reference< css::rendering::XCachedPrimitive >
146  drawText( const css::rendering::XCanvas* pCanvas,
147  const css::rendering::StringContext& text,
148  const css::uno::Reference<
149  css::rendering::XCanvasFont >& xFont,
150  const css::rendering::ViewState& viewState,
151  const css::rendering::RenderState& renderState,
152  sal_Int8 textDirection );
153 
154  css::uno::Reference< css::rendering::XCachedPrimitive >
155  drawTextLayout( const css::rendering::XCanvas* pCanvas,
156  const css::uno::Reference<
157  css::rendering::XTextLayout >& layoutetText,
158  const css::rendering::ViewState& viewState,
159  const css::rendering::RenderState& renderState );
160 
161  css::uno::Reference< css::rendering::XCachedPrimitive >
162  drawBitmap( const css::rendering::XCanvas* pCanvas,
163  const css::uno::Reference<
164  css::rendering::XBitmap >& xBitmap,
165  const css::rendering::ViewState& viewState,
166  const css::rendering::RenderState& renderState );
167  css::uno::Reference< css::rendering::XCachedPrimitive >
168  drawBitmapModulated( const css::rendering::XCanvas* pCanvas,
169  const css::uno::Reference<
170  css::rendering::XBitmap >& xBitmap,
171  const css::rendering::ViewState& viewState,
172  const css::rendering::RenderState& renderState );
173  css::uno::Reference< css::rendering::XGraphicDevice >
174  getDevice() { return css::uno::Reference< css::rendering::XGraphicDevice >(mpDevice); }
175 
178  bool renderRecordedActions() const;
179 
182  size_t getRecordedActionCount() const;
183 
185  css::rendering::XGraphicDevice* getDevice() const { return mpDevice; }
186 
187  struct Action;
190 
191  private:
192  CanvasHelper( const CanvasHelper& ) = delete;
193 
194  void setupGraphicsState( Action& o_action,
195  const css::rendering::ViewState& viewState,
196  const css::rendering::RenderState& renderState );
197 
203  css::rendering::XGraphicDevice* mpDevice;
204 
209 
215  RecordVectorT mpRecordedActions;
216  };
217 }
218 
219 /* 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.
exports com.sun.star. text
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 &)
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)