Branch libreoffice-5-0-4
[LibreOffice.git] / canvas / source / directx / dx_canvashelper.hxx
blob69c692a3c784c8d92273401178052d5510faab72
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASHELPER_HXX
21 #define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASHELPER_HXX
23 #include <com/sun/star/rendering/XCanvas.hpp>
24 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
25 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
27 #include <basegfx/vector/b2isize.hxx>
28 #include <basegfx/vector/b2dsize.hxx>
30 #include "dx_graphicsprovider.hxx"
31 #include "dx_gdiplususer.hxx"
32 #include "dx_impltools.hxx"
34 #include <boost/utility.hpp>
37 namespace dxcanvas
39 /** Helper class for basic canvas functionality. Also offers
40 optional backbuffer painting, when providing it with a second
41 HDC to render into.
43 class CanvasHelper : private ::boost::noncopyable
45 public:
46 CanvasHelper();
48 /// Release all references
49 void disposing();
51 /** Initialize canvas helper
53 This method late-initializes the canvas helper, providing
54 it with the necessary device and output objects. Note that
55 the CanvasHelper does <em>not</em> take ownership of the
56 passed rDevice reference, nor does it perform any
57 reference counting. Thus, to prevent the reference counted
58 SpriteCanvas object from deletion, the user of this class
59 is responsible for holding ref-counted references itself!
61 @param rDevice
62 Reference device this canvas is associated with
65 void setDevice( com::sun::star::rendering::XGraphicDevice& rDevice );
67 /** Set the target for rendering operations
69 @param rTarget
70 Render target
72 void setTarget( const GraphicsProviderSharedPtr& rTarget );
74 /** Set the target for rendering operations
76 @param rTarget
77 Render target
79 @param rOutputOffset
80 Output offset in pixel
82 void setTarget( const GraphicsProviderSharedPtr& rTarget,
83 const ::basegfx::B2ISize& rOutputOffset );
86 // CanvasHelper functionality
87 // ==========================
89 // XCanvas (only providing, not implementing the
90 // interface. Also note subtle method parameter differences)
91 void clear();
92 void drawPoint( const ::com::sun::star::rendering::XCanvas* pCanvas,
93 const ::com::sun::star::geometry::RealPoint2D& aPoint,
94 const ::com::sun::star::rendering::ViewState& viewState,
95 const ::com::sun::star::rendering::RenderState& renderState );
96 void drawLine( const ::com::sun::star::rendering::XCanvas* pCanvas,
97 const ::com::sun::star::geometry::RealPoint2D& aStartPoint,
98 const ::com::sun::star::geometry::RealPoint2D& aEndPoint,
99 const ::com::sun::star::rendering::ViewState& viewState,
100 const ::com::sun::star::rendering::RenderState& renderState );
101 void drawBezier( const ::com::sun::star::rendering::XCanvas* pCanvas,
102 const ::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment,
103 const ::com::sun::star::geometry::RealPoint2D& aEndPoint,
104 const ::com::sun::star::rendering::ViewState& viewState,
105 const ::com::sun::star::rendering::RenderState& renderState );
106 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
107 drawPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
108 const ::com::sun::star::uno::Reference<
109 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
110 const ::com::sun::star::rendering::ViewState& viewState,
111 const ::com::sun::star::rendering::RenderState& renderState );
112 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
113 strokePolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
114 const ::com::sun::star::uno::Reference<
115 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
116 const ::com::sun::star::rendering::ViewState& viewState,
117 const ::com::sun::star::rendering::RenderState& renderState,
118 const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
119 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
120 strokeTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
121 const ::com::sun::star::uno::Reference<
122 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
123 const ::com::sun::star::rendering::ViewState& viewState,
124 const ::com::sun::star::rendering::RenderState& renderState,
125 const ::com::sun::star::uno::Sequence<
126 ::com::sun::star::rendering::Texture >& textures,
127 const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
128 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
129 strokeTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
130 const ::com::sun::star::uno::Reference<
131 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
132 const ::com::sun::star::rendering::ViewState& viewState,
133 const ::com::sun::star::rendering::RenderState& renderState,
134 const ::com::sun::star::uno::Sequence<
135 ::com::sun::star::rendering::Texture >& textures,
136 const ::com::sun::star::uno::Reference<
137 ::com::sun::star::geometry::XMapping2D >& xMapping,
138 const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
139 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
140 queryStrokeShapes( const ::com::sun::star::rendering::XCanvas* pCanvas,
141 const ::com::sun::star::uno::Reference<
142 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
143 const ::com::sun::star::rendering::ViewState& viewState,
144 const ::com::sun::star::rendering::RenderState& renderState,
145 const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
146 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
147 fillPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
148 const ::com::sun::star::uno::Reference<
149 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
150 const ::com::sun::star::rendering::ViewState& viewState,
151 const ::com::sun::star::rendering::RenderState& renderState );
152 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
153 fillTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
154 const ::com::sun::star::uno::Reference<
155 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
156 const ::com::sun::star::rendering::ViewState& viewState,
157 const ::com::sun::star::rendering::RenderState& renderState,
158 const ::com::sun::star::uno::Sequence<
159 ::com::sun::star::rendering::Texture >& textures );
160 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
161 fillTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas* pCanvas,
162 const ::com::sun::star::uno::Reference<
163 ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
164 const ::com::sun::star::rendering::ViewState& viewState,
165 const ::com::sun::star::rendering::RenderState& renderState,
166 const ::com::sun::star::uno::Sequence<
167 ::com::sun::star::rendering::Texture >& textures,
168 const ::com::sun::star::uno::Reference<
169 ::com::sun::star::geometry::XMapping2D >& xMapping );
171 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > SAL_CALL
172 createFont( const ::com::sun::star::rendering::XCanvas* pCanvas,
173 const ::com::sun::star::rendering::FontRequest& fontRequest,
174 const ::com::sun::star::uno::Sequence<
175 ::com::sun::star::beans::PropertyValue >& extraFontProperties,
176 const ::com::sun::star::geometry::Matrix2D& fontMatrix );
178 ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::FontInfo >
179 queryAvailableFonts( const ::com::sun::star::rendering::XCanvas* pCanvas,
180 const ::com::sun::star::rendering::FontInfo& aFilter,
181 const ::com::sun::star::uno::Sequence<
182 ::com::sun::star::beans::PropertyValue >& aFontProperties );
184 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
185 drawText( const ::com::sun::star::rendering::XCanvas* pCanvas,
186 const ::com::sun::star::rendering::StringContext& text,
187 const ::com::sun::star::uno::Reference<
188 ::com::sun::star::rendering::XCanvasFont >& xFont,
189 const ::com::sun::star::rendering::ViewState& viewState,
190 const ::com::sun::star::rendering::RenderState& renderState,
191 sal_Int8 textDirection );
193 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
194 drawTextLayout( const ::com::sun::star::rendering::XCanvas* pCanvas,
195 const ::com::sun::star::uno::Reference<
196 ::com::sun::star::rendering::XTextLayout >& laidOutText,
197 const ::com::sun::star::rendering::ViewState& viewState,
198 const ::com::sun::star::rendering::RenderState& renderState );
200 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
201 drawBitmap( const ::com::sun::star::rendering::XCanvas* pCanvas,
202 const ::com::sun::star::uno::Reference<
203 ::com::sun::star::rendering::XBitmap >& xBitmap,
204 const ::com::sun::star::rendering::ViewState& viewState,
205 const ::com::sun::star::rendering::RenderState& renderState );
206 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
207 drawBitmapModulated( const ::com::sun::star::rendering::XCanvas* pCanvas,
208 const ::com::sun::star::uno::Reference<
209 ::com::sun::star::rendering::XBitmap >& xBitmap,
210 const ::com::sun::star::rendering::ViewState& viewState,
211 const ::com::sun::star::rendering::RenderState& renderState );
212 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >
213 getDevice();
215 // Flush drawing queue to screen
216 void flush() const;
218 /** Called from XCanvas base classes, to notify that content
219 is _about_ to change
221 void modifying() {}
223 protected:
224 /// Refcounted global GDI+ state container
225 GDIPlusUserSharedPtr mpGdiPlusUser;
227 /** Phyical output device
229 Deliberately not a refcounted reference, because of
230 potential circular references for spritecanvas.
232 com::sun::star::rendering::XGraphicDevice* mpDevice;
234 /// Provides the Gdiplus::Graphics to render into
235 GraphicsProviderSharedPtr mpGraphicsProvider;
237 bool needOutput() const { return mpGraphicsProvider.get() != NULL; };
239 // returns transparency of color
240 void setupGraphicsState( GraphicsSharedPtr& rGraphics,
241 const ::com::sun::star::rendering::ViewState& viewState,
242 const ::com::sun::star::rendering::RenderState& renderState );
244 Gdiplus::CompositingMode calcCompositingMode( sal_Int8 nMode );
246 /// Current (transformation-independent) output buffer offset
247 ::basegfx::B2ISize maOutputOffset;
251 #endif // INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CANVASHELPER_HXX
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */