LibreOffice Module slideshow (master) 1
viewshape.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_SLIDESHOW_SOURCE_ENGINE_SHAPES_VIEWSHAPE_HXX
21#define INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_VIEWSHAPE_HXX
22
24#include <cppcanvas/bitmap.hxx>
25
28
29#include <tools.hxx>
31#include <animatedsprite.hxx>
32#include <viewlayer.hxx>
33#include <doctreenode.hxx>
34
35#include <vector>
36#include <memory>
37
38enum class UpdateFlags
39{
40 NONE = 0x00,
41 Transformation = 0x01,
42 Clip = 0x02,
43 Alpha = 0x04,
44 Position = 0x08,
45 Content = 0x10,
46 Force = 0x20,
47};
48namespace o3tl {
49 template<> struct typed_flags<UpdateFlags> : is_typed_flags<UpdateFlags, 0x3f> {};
50}
51
52
53
54namespace slideshow::internal
55 {
63 {
64 public:
70 explicit ViewShape( ViewLayerSharedPtr xViewLayer );
71
73 ViewShape(const ViewShape&) = delete;
75 ViewShape& operator=(const ViewShape&) = delete;
76
79 const ViewLayerSharedPtr& getViewLayer() const;
80
89
90
91 // animation methods
92
93
100 void enterAnimationMode();
101
107 void leaveAnimationMode();
108
109
110 // render methods
111
112
114 {
139 RenderArgs( const ::basegfx::B2DRectangle& rOrigBounds,
140 const ::basegfx::B2DRectangle& rUpdateBounds,
141 const ::basegfx::B2DRectangle& rBounds,
142 const ::basegfx::B2DRectangle& rUnitBounds,
143 const ShapeAttributeLayerSharedPtr& rAttr,
144 const VectorOfDocTreeNodes& rSubsets,
145 double nPrio ) :
146 maOrigBounds( rOrigBounds ),
147 maUpdateBounds( rUpdateBounds ),
148 maBounds( rBounds ),
149 maUnitBounds( rUnitBounds ),
150 mrAttr( rAttr ),
151 mrSubsets( rSubsets ),
152 mnShapePriority( nPrio )
153 {
154 }
155
156 const ::basegfx::B2DRectangle maOrigBounds;
157 const ::basegfx::B2DRectangle maUpdateBounds;
158 const ::basegfx::B2DRectangle maBounds;
159 const ::basegfx::B2DRectangle maUnitBounds;
162 const double mnShapePriority;
163 };
164
188 bool update( const GDIMetaFileSharedPtr& rMtf,
189 const RenderArgs& rArgs,
190 UpdateFlags nUpdateFlags,
191 bool bIsVisible ) const;
192
201 ::cppcanvas::RendererSharedPtr getRenderer( const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
202 const GDIMetaFileSharedPtr& rMtf,
203 const ShapeAttributeLayerSharedPtr& rAttr ) const;
204
205
206 private:
208 {
211 mpRenderer(),
212 mpMtf(),
213 mpLastBitmap(),
215 {
216 }
217
218 const ::cppcanvas::CanvasSharedPtr& getDestinationCanvas() const
219 {
220 return mpDestinationCanvas;
221 }
222
228 };
229
230 typedef ::std::vector< RendererCacheEntry > RendererCacheVector;
231
232
235 static bool prefetch( RendererCacheEntry& io_rCacheEntry,
236 const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
237 const GDIMetaFileSharedPtr& rMtf,
238 const ShapeAttributeLayerSharedPtr& rAttr );
239
245 bool draw( const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
246 const GDIMetaFileSharedPtr& rMtf,
247 const ShapeAttributeLayerSharedPtr& rAttr,
248 const ::basegfx::B2DHomMatrix& rTransform,
249 const ::basegfx::B2DPolyPolygon* pClip,
250 const VectorOfDocTreeNodes& rSubsets ) const;
251
254 bool renderSprite( const ViewLayerSharedPtr& rViewLayer,
255 const GDIMetaFileSharedPtr& rMtf,
256 const ::basegfx::B2DRectangle& rOrigBounds,
257 const ::basegfx::B2DRectangle& rBounds,
258 const ::basegfx::B2DRectangle& rUnitBounds,
259 UpdateFlags nUpdateFlags,
260 const ShapeAttributeLayerSharedPtr& pAttr,
261 const VectorOfDocTreeNodes& rSubsets,
262 double nPrio,
263 bool bIsVisible ) const;
264
267 bool render( const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
268 const GDIMetaFileSharedPtr& rMtf,
269 const ::basegfx::B2DRectangle& rBounds,
270 const ::basegfx::B2DRectangle& rUpdateBounds,
271 UpdateFlags nUpdateFlags,
272 const ShapeAttributeLayerSharedPtr& pAttr,
273 const VectorOfDocTreeNodes& rSubsets,
274 bool bIsVisible ) const;
275
277
290 RendererCacheVector::iterator getCacheEntry( const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas ) const;
291
292 void invalidateRenderer() const;
293
299
302
305
307 mutable bool mbAnimationMode;
308
310 mutable bool mbForceUpdate;
311 };
312
313 typedef ::std::shared_ptr< ViewShape > ViewShapeSharedPtr;
314
315}
316
317#endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_VIEWSHAPE_HXX
318
319/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class is the viewable representation of a draw document's XShape, associated to a specific View.
Definition: viewshape.hxx:63
ViewShape & operator=(const ViewShape &)=delete
Forbid copy assignment.
bool update(const GDIMetaFileSharedPtr &rMtf, const RenderArgs &rArgs, UpdateFlags nUpdateFlags, bool bIsVisible) const
Update the ViewShape.
Definition: viewshape.cxx:826
::cppcanvas::RendererSharedPtr getRenderer(const ::cppcanvas::CanvasSharedPtr &rDestinationCanvas, const GDIMetaFileSharedPtr &rMtf, const ShapeAttributeLayerSharedPtr &rAttr) const
Retrieve renderer for given canvas and metafile.
Definition: viewshape.cxx:760
::basegfx::B2DSize getAntialiasingBorder() const
Query dimension of a safety border around the shape for AA.
Definition: viewshape.cxx:794
bool render(const ::cppcanvas::CanvasSharedPtr &rDestinationCanvas, const GDIMetaFileSharedPtr &rMtf, const ::basegfx::B2DRectangle &rBounds, const ::basegfx::B2DRectangle &rUpdateBounds, UpdateFlags nUpdateFlags, const ShapeAttributeLayerSharedPtr &pAttr, const VectorOfDocTreeNodes &rSubsets, bool bIsVisible) const
Render shape to given canvas.
Definition: viewshape.cxx:497
RendererCacheVector maRenderers
A set of cached mtf/canvas combinations.
Definition: viewshape.hxx:301
bool renderSprite(const ViewLayerSharedPtr &rViewLayer, const GDIMetaFileSharedPtr &rMtf, const ::basegfx::B2DRectangle &rOrigBounds, const ::basegfx::B2DRectangle &rBounds, const ::basegfx::B2DRectangle &rUnitBounds, UpdateFlags nUpdateFlags, const ShapeAttributeLayerSharedPtr &pAttr, const VectorOfDocTreeNodes &rSubsets, double nPrio, bool bIsVisible) const
Render shape to an active sprite.
Definition: viewshape.cxx:278
const ViewLayerSharedPtr & getViewLayer() const
Query the associated view layer of this shape.
Definition: viewshape.cxx:720
void enterAnimationMode()
Notify the ViewShape that an animation starts now.
Definition: viewshape.cxx:813
AnimatedSpriteSharedPtr mpSprite
The sprite object.
Definition: viewshape.hxx:304
bool mbAnimationMode
If true, render() calls go to the sprite.
Definition: viewshape.hxx:307
bool draw(const ::cppcanvas::CanvasSharedPtr &rDestinationCanvas, const GDIMetaFileSharedPtr &rMtf, const ShapeAttributeLayerSharedPtr &rAttr, const ::basegfx::B2DHomMatrix &rTransform, const ::basegfx::B2DPolyPolygon *pClip, const VectorOfDocTreeNodes &rSubsets) const
Draw with prefetched Renderer to stored canvas.
Definition: viewshape.cxx:171
static bool prefetch(RendererCacheEntry &io_rCacheEntry, const ::cppcanvas::CanvasSharedPtr &rDestinationCanvas, const GDIMetaFileSharedPtr &rMtf, const ShapeAttributeLayerSharedPtr &rAttr)
Prefetch Renderer for given canvas.
Definition: viewshape.cxx:52
RendererCacheVector::iterator getCacheEntry(const ::cppcanvas::CanvasSharedPtr &rDestinationCanvas) const
Retrieve a valid iterator to renderer cache entry.
Definition: viewshape.cxx:725
ViewShape(const ViewShape &)=delete
Forbid copy construction.
ViewLayerSharedPtr mpViewLayer
The view layer this object is part of.
Definition: viewshape.hxx:298
void leaveAnimationMode()
Notify the ViewShape that it is no longer animated.
Definition: viewshape.cxx:819
::std::vector< RendererCacheEntry > RendererCacheVector
Definition: viewshape.hxx:230
ViewShape(ViewLayerSharedPtr xViewLayer)
Create a ViewShape for the given View.
Definition: viewshape.cxx:710
bool mbForceUpdate
If true, shape needs full repaint (and the sprite a setup, if any)
Definition: viewshape.hxx:310
NONE
Clip
std::shared_ptr< ::cppcanvas::Renderer > RendererSharedPtr
std::shared_ptr< BitmapCanvas > BitmapCanvasSharedPtr
std::shared_ptr< ::cppcanvas::Bitmap > BitmapSharedPtr
std::shared_ptr< Canvas > CanvasSharedPtr
::std::shared_ptr< ViewShape > ViewShapeSharedPtr
Definition: viewshape.hxx:313
::std::shared_ptr< ShapeAttributeLayer > ShapeAttributeLayerSharedPtr
::std::vector< DocTreeNode > VectorOfDocTreeNodes
std::shared_ptr< ViewLayer > ViewLayerSharedPtr
Definition: viewlayer.hxx:168
::std::shared_ptr< AnimatedSprite > AnimatedSpriteSharedPtr
std::shared_ptr< GDIMetaFile > GDIMetaFileSharedPtr
Definition: tools.hxx:63
const ::basegfx::B2DRectangle maUpdateBounds
Definition: viewshape.hxx:157
RenderArgs(const ::basegfx::B2DRectangle &rOrigBounds, const ::basegfx::B2DRectangle &rUpdateBounds, const ::basegfx::B2DRectangle &rBounds, const ::basegfx::B2DRectangle &rUnitBounds, const ShapeAttributeLayerSharedPtr &rAttr, const VectorOfDocTreeNodes &rSubsets, double nPrio)
Create render argument struct.
Definition: viewshape.hxx:139
const ::basegfx::B2DRectangle maOrigBounds
Definition: viewshape.hxx:156
const ::basegfx::B2DRectangle maBounds
Definition: viewshape.hxx:158
const VectorOfDocTreeNodes & mrSubsets
Definition: viewshape.hxx:161
const ::basegfx::B2DRectangle maUnitBounds
Definition: viewshape.hxx:159
const ShapeAttributeLayerSharedPtr & mrAttr
Definition: viewshape.hxx:160
::cppcanvas::RendererSharedPtr mpRenderer
Definition: viewshape.hxx:224
::cppcanvas::BitmapCanvasSharedPtr mpLastBitmapCanvas
Definition: viewshape.hxx:227
const ::cppcanvas::CanvasSharedPtr & getDestinationCanvas() const
Definition: viewshape.hxx:218
::cppcanvas::CanvasSharedPtr mpDestinationCanvas
Definition: viewshape.hxx:223
UpdateFlags
Definition: viewshape.hxx:39