LibreOffice Module canvas (master)  1
dx_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  * 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 INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASHELPER_HXX
21 #define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASHELPER_HXX
22 
23 #include <com/sun/star/rendering/XCanvas.hpp>
24 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
25 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
26 
29 
30 #include "dx_graphicsprovider.hxx"
31 #include "dx_gdiplususer.hxx"
32 #include "dx_impltools.hxx"
33 
34 
35 namespace dxcanvas
36 {
42  {
43  public:
44  CanvasHelper();
45 
47  CanvasHelper(const CanvasHelper&) = delete;
48  const CanvasHelper& operator=(const CanvasHelper&) = delete;
49 
51  void disposing();
52 
67  void setDevice( css::rendering::XGraphicDevice& rDevice );
68 
74  void setTarget( const GraphicsProviderSharedPtr& rTarget );
75 
84  void setTarget( const GraphicsProviderSharedPtr& rTarget,
85  const ::basegfx::B2ISize& rOutputOffset );
86 
87 
88  // CanvasHelper functionality
89  // ==========================
90 
91  // XCanvas (only providing, not implementing the
92  // interface. Also note subtle method parameter differences)
93  void clear();
94  void drawPoint( const css::rendering::XCanvas* pCanvas,
95  const css::geometry::RealPoint2D& aPoint,
96  const css::rendering::ViewState& viewState,
97  const css::rendering::RenderState& renderState );
98  void drawLine( const css::rendering::XCanvas* pCanvas,
99  const css::geometry::RealPoint2D& aStartPoint,
100  const css::geometry::RealPoint2D& aEndPoint,
101  const css::rendering::ViewState& viewState,
102  const css::rendering::RenderState& renderState );
103  void drawBezier( const css::rendering::XCanvas* pCanvas,
104  const css::geometry::RealBezierSegment2D& aBezierSegment,
105  const css::geometry::RealPoint2D& aEndPoint,
106  const css::rendering::ViewState& viewState,
107  const css::rendering::RenderState& renderState );
108  css::uno::Reference< css::rendering::XCachedPrimitive >
109  drawPolyPolygon( 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  strokePolyPolygon( 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::rendering::StrokeAttributes& strokeAttributes );
121  css::uno::Reference< css::rendering::XCachedPrimitive >
122  strokeTexturedPolyPolygon( 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::rendering::StrokeAttributes& strokeAttributes );
130  css::uno::Reference< css::rendering::XCachedPrimitive >
131  strokeTextureMappedPolyPolygon( const css::rendering::XCanvas* pCanvas,
132  const css::uno::Reference<
133  css::rendering::XPolyPolygon2D >& xPolyPolygon,
134  const css::rendering::ViewState& viewState,
135  const css::rendering::RenderState& renderState,
136  const css::uno::Sequence<
137  css::rendering::Texture >& textures,
138  const css::uno::Reference<
139  css::geometry::XMapping2D >& xMapping,
140  const css::rendering::StrokeAttributes& strokeAttributes );
141  css::uno::Reference< css::rendering::XPolyPolygon2D >
142  queryStrokeShapes( const css::rendering::XCanvas* pCanvas,
143  const css::uno::Reference<
144  css::rendering::XPolyPolygon2D >& xPolyPolygon,
145  const css::rendering::ViewState& viewState,
146  const css::rendering::RenderState& renderState,
147  const css::rendering::StrokeAttributes& strokeAttributes );
148  css::uno::Reference< css::rendering::XCachedPrimitive >
149  fillPolyPolygon( const css::rendering::XCanvas* pCanvas,
150  const css::uno::Reference<
151  css::rendering::XPolyPolygon2D >& xPolyPolygon,
152  const css::rendering::ViewState& viewState,
153  const css::rendering::RenderState& renderState );
154  css::uno::Reference< css::rendering::XCachedPrimitive >
155  fillTexturedPolyPolygon( const css::rendering::XCanvas* pCanvas,
156  const css::uno::Reference<
157  css::rendering::XPolyPolygon2D >& xPolyPolygon,
158  const css::rendering::ViewState& viewState,
159  const css::rendering::RenderState& renderState,
160  const css::uno::Sequence<
161  css::rendering::Texture >& textures );
162  css::uno::Reference< css::rendering::XCachedPrimitive >
163  fillTextureMappedPolyPolygon( const css::rendering::XCanvas* pCanvas,
164  const css::uno::Reference<
165  css::rendering::XPolyPolygon2D >& xPolyPolygon,
166  const css::rendering::ViewState& viewState,
167  const css::rendering::RenderState& renderState,
168  const css::uno::Sequence<
169  css::rendering::Texture >& textures,
170  const css::uno::Reference<
171  css::geometry::XMapping2D >& xMapping );
172 
173  css::uno::Reference< css::rendering::XCanvasFont >
174  createFont( const css::rendering::XCanvas* pCanvas,
175  const css::rendering::FontRequest& fontRequest,
176  const css::uno::Sequence<
177  css::beans::PropertyValue >& extraFontProperties,
178  const css::geometry::Matrix2D& fontMatrix );
179 
180  css::uno::Sequence< css::rendering::FontInfo >
181  queryAvailableFonts( const css::rendering::XCanvas* pCanvas,
182  const css::rendering::FontInfo& aFilter,
183  const css::uno::Sequence<
184  css::beans::PropertyValue >& aFontProperties );
185 
186  css::uno::Reference< css::rendering::XCachedPrimitive >
187  drawText( const css::rendering::XCanvas* pCanvas,
188  const css::rendering::StringContext& text,
189  const css::uno::Reference<
190  css::rendering::XCanvasFont >& xFont,
191  const css::rendering::ViewState& viewState,
192  const css::rendering::RenderState& renderState,
193  sal_Int8 textDirection );
194 
195  css::uno::Reference< css::rendering::XCachedPrimitive >
196  drawTextLayout( const css::rendering::XCanvas* pCanvas,
197  const css::uno::Reference<
198  css::rendering::XTextLayout >& laidOutText,
199  const css::rendering::ViewState& viewState,
200  const css::rendering::RenderState& renderState );
201 
202  css::uno::Reference< css::rendering::XCachedPrimitive >
203  drawBitmap( const css::rendering::XCanvas* pCanvas,
204  const css::uno::Reference<
205  css::rendering::XBitmap >& xBitmap,
206  const css::rendering::ViewState& viewState,
207  const css::rendering::RenderState& renderState );
208  css::uno::Reference< css::rendering::XCachedPrimitive >
209  drawBitmapModulated( const css::rendering::XCanvas* pCanvas,
210  const css::uno::Reference<
211  css::rendering::XBitmap >& xBitmap,
212  const css::rendering::ViewState& viewState,
213  const css::rendering::RenderState& renderState );
214  css::uno::Reference< css::rendering::XGraphicDevice >
215  getDevice();
216 
217  // Flush drawing queue to screen
218  void flush() const;
219 
223  void modifying() {}
224 
225  protected:
228 
234  css::rendering::XGraphicDevice* mpDevice;
235 
238 
239  bool needOutput() const { return mpGraphicsProvider.get() != nullptr; };
240 
241  // returns transparency of color
242  void setupGraphicsState( GraphicsSharedPtr const & rGraphics,
243  const css::rendering::ViewState& viewState,
244  const css::rendering::RenderState& renderState );
245 
246  Gdiplus::CompositingMode calcCompositingMode( sal_Int8 nMode );
247 
250  };
251 }
252 
253 #endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASHELPER_HXX
254 
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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)
void drawPoint(const css::rendering::XCanvas *pCanvas, const css::geometry::RealPoint2D &aPoint, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
signed char sal_Int8
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)
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::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)
void disposing()
Release all references.
const CanvasHelper & operator=(const CanvasHelper &)=delete
void setDevice(css::rendering::XGraphicDevice &rDevice)
Initialize canvas helper.
void setTarget(const GraphicsProviderSharedPtr &rTarget)
Set the target for rendering operations.
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 > 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)
Gdiplus::CompositingMode calcCompositingMode(sal_Int8 nMode)
::basegfx::B2ISize maOutputOffset
Current (transformation-independent) output buffer offset.
Helper class for basic canvas functionality.
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)
GDIPlusUserSharedPtr mpGdiPlusUser
Refcounted global GDI+ state container.
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)
css::rendering::XGraphicDevice * mpDevice
Phyical output device.
void modifying()
Called from XCanvas base classes, to notify that content is about to change.
void setupGraphicsState(GraphicsSharedPtr const &rGraphics, 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 > 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)
css::uno::Reference< css::rendering::XGraphicDevice > getDevice()
std::shared_ptr< GraphicsProvider > GraphicsProviderSharedPtr
GDIPlusUser::GDIPlusUserSharedPtr GDIPlusUserSharedPtr
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)
def text(shape, st)
GraphicsProviderSharedPtr mpGraphicsProvider
Provides the Gdiplus::Graphics to render into.
css::uno::Reference< css::rendering::XCachedPrimitive > drawTextLayout(const css::rendering::XCanvas *pCanvas, const css::uno::Reference< css::rendering::XTextLayout > &laidOutText, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState)
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::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)
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)
std::shared_ptr< Gdiplus::Graphics > GraphicsSharedPtr
Definition: dx_winstuff.hxx:61