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