LibreOffice Module canvas (master)  1
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
canvas::SpriteRedrawManager Class Reference

This class manages smooth SpriteCanvas updates. More...

#include <spriteredrawmanager.hxx>

Classes

struct  AreaUpdateCaller
 Functor, to be used from forEachSpriteArea. More...
 
struct  SpriteChangeRecord
 Helper struct for SpriteTracer template. More...
 
class  SpriteInfo
 Data container for the connected components list. More...
 

Public Types

typedef ::std::vector< SpriteChangeRecordVectorOfChangeRecords
 
typedef ::basegfx::B2DConnectedRanges< SpriteInfoSpriteConnectedRanges
 
typedef SpriteConnectedRanges::ComponentType AreaComponent
 
typedef SpriteConnectedRanges::ConnectedComponents UpdateArea
 
typedef ::std::vector< Sprite::ReferenceVectorOfSprites
 

Public Member Functions

 SpriteRedrawManager ()
 
 SpriteRedrawManager (const SpriteRedrawManager &)=delete
 
SpriteRedrawManageroperator= (const SpriteRedrawManager &)=delete
 
void disposing ()
 Must be called when user of this object gets disposed. More...
 
template<typename Functor >
void forEachSpriteArea (Functor &rFunc) const
 Call given functor for each sprite area that needs an update. More...
 
template<typename Functor >
void forEachSprite (const Functor &rFunc) const
 Call given functor for each active sprite. More...
 
void clearChangeRecords ()
 Clear sprite change records (typically directly after a screen update) More...
 
void showSprite (const Sprite::Reference &rSprite)
 
void hideSprite (const Sprite::Reference &rSprite)
 
void moveSprite (const Sprite::Reference &rSprite, const ::basegfx::B2DPoint &rOldPos, const ::basegfx::B2DPoint &rNewPos, const ::basegfx::B2DVector &rSpriteSize)
 
void updateSprite (const Sprite::Reference &rSprite, const ::basegfx::B2DPoint &rPos, const ::basegfx::B2DRange &rUpdateArea)
 
template<typename Functor >
void handleArea (Functor &rFunc, const UpdateArea &rUpdateArea) const
 Internal, handles each distinct component for forEachAggregate() More...
 

Private Member Functions

void setupUpdateAreas (SpriteConnectedRanges &rUpdateAreas) const
 Central method of this class. More...
 
bool areSpritesChanged (const UpdateArea &rUpdateArea) const
 
bool isAreaUpdateNotOpaque (const ::basegfx::B2DRectangle &rUpdateRect, const AreaComponent &rComponent) const
 
bool isAreaUpdateOpaque (const UpdateArea &rUpdateArea,::std::size_t nNumSprites) const
 
bool isAreaUpdateScroll (::basegfx::B2DRectangle &o_rMoveStart,::basegfx::B2DRectangle &o_rMoveEnd, const UpdateArea &rUpdateArea,::std::size_t nNumSprites) const
 Check whether given update area can be handled by a simple scroll. More...
 

Private Attributes

VectorOfSprites maSprites
 
VectorOfChangeRecords maChangeRecords
 

Detailed Description

This class manages smooth SpriteCanvas updates.

Use this class to handle the canvas::SpriteSurface methods, that track and process sprite update events. Recorded update events are later grouped by connected areas (i.e. all sprites that somehow overlap over a rectangular area are grouped together); the forEachSpriteArea() method calls the passed functor for each of those connected areas.

Note that, although this class generally works with IEEE doubles, the calculation of connected areas happens in the integer domain - it is generally expected that repaints can only be divided at pixel boundaries, without causing visible artifacts. Therefore, sprites that touch the same pixel (but don't necessarily have the same floating point coordinates there) will reside in a common sprite area and handled together in the forEachSpriteArea functor call.

Definition at line 57 of file spriteredrawmanager.hxx.

Member Typedef Documentation

Definition at line 180 of file spriteredrawmanager.hxx.

Definition at line 179 of file spriteredrawmanager.hxx.

Definition at line 181 of file spriteredrawmanager.hxx.

Definition at line 178 of file spriteredrawmanager.hxx.

Definition at line 182 of file spriteredrawmanager.hxx.

Constructor & Destructor Documentation

canvas::SpriteRedrawManager::SpriteRedrawManager ( )

Definition at line 431 of file spriteredrawmanager.cxx.

References maSprites.

canvas::SpriteRedrawManager::SpriteRedrawManager ( const SpriteRedrawManager )
delete

Member Function Documentation

bool canvas::SpriteRedrawManager::areSpritesChanged ( const UpdateArea rUpdateArea) const
private
void canvas::SpriteRedrawManager::clearChangeRecords ( )

Clear sprite change records (typically directly after a screen update)

Definition at line 452 of file spriteredrawmanager.cxx.

References maChangeRecords.

Referenced by cairocanvas::SpriteCanvasHelper::updateScreen(), vclcanvas::SpriteCanvasHelper::updateScreen(), and dxcanvas::SpriteCanvasHelper::updateScreen().

void canvas::SpriteRedrawManager::disposing ( )

Must be called when user of this object gets disposed.

Frees all internal references.

Definition at line 437 of file spriteredrawmanager.cxx.

References maChangeRecords, and maSprites.

Referenced by canvas::SpriteCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >::disposeThis().

template<typename Functor >
void canvas::SpriteRedrawManager::forEachSprite ( const Functor &  rFunc) const
inline

Call given functor for each active sprite.

This method calls the given functor for each active sprite, in the order of sprite priority.

Template parameter:
Functor Must provide a Functor::operator( Sprite::Reference& ) method.

Definition at line 259 of file spriteredrawmanager.hxx.

References maSprites.

Referenced by vclcanvas::SpriteCanvasHelper::renderMemUsage(), vclcanvas::SpriteCanvasHelper::renderSpriteCount(), cairocanvas::SpriteCanvasHelper::updateScreen(), vclcanvas::SpriteCanvasHelper::updateScreen(), and dxcanvas::SpriteCanvasHelper::updateScreen().

template<typename Functor >
void canvas::SpriteRedrawManager::forEachSpriteArea ( Functor &  rFunc) const
inline

Call given functor for each sprite area that needs an update.

This method calls the given functor for each update area (calculated from the sprite change records).

Template parameter:
Functor Must provide the following four methods:
void backgroundPaint( ::basegfx::B2DRange aUpdateRect );
void scrollUpdate( basegfx::B2DRange& o_rMoveStart,
                   basegfx::B2DRange& o_rMoveEnd,
                   UpdateArea           aUpdateArea );
void opaqueUpdate( const basegfx::B2DRange&                          rTotalArea,
                   const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites );
void genericUpdate( const basegfx::B2DRange&                          rTotalArea,
                    const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites );
The backgroundPaint() method is called to simply repaint background content, the scrollUpdate() method is used to scroll a given area, and paint background in the uncovered areas, the opaqueUpdate() method is called when a sprite can be painted in the given area without taking background content into account, and finally, genericUpdate() is called for complex updates, where first the background and then all sprites consecutively have to be repainted.

Definition at line 240 of file spriteredrawmanager.hxx.

References basegfx::B2DConnectedRanges< class >::forEachAggregate().

Referenced by cairocanvas::SpriteCanvasHelper::updateScreen(), vclcanvas::SpriteCanvasHelper::updateScreen(), and dxcanvas::SpriteCanvasHelper::updateScreen().

template<typename Functor >
void canvas::SpriteRedrawManager::handleArea ( Functor &  rFunc,
const UpdateArea rUpdateArea 
) const
inline

Internal, handles each distinct component for forEachAggregate()

The reason why this must be public is that it needs to be accessible from the AreaUpdateCaller functor.

Definition at line 287 of file spriteredrawmanager.hxx.

References basegfx::B2DConnectedRanges< class >::ConnectedComponents::maComponentList, and basegfx::B2DConnectedRanges< class >::ConnectedComponents::maTotalBounds.

void canvas::SpriteRedrawManager::hideSprite ( const Sprite::Reference rSprite)
bool canvas::SpriteRedrawManager::isAreaUpdateNotOpaque ( const ::basegfx::B2DRectangle rUpdateRect,
const AreaComponent rComponent 
) const
private

Definition at line 370 of file spriteredrawmanager.cxx.

Referenced by isAreaUpdateOpaque().

bool canvas::SpriteRedrawManager::isAreaUpdateOpaque ( const UpdateArea rUpdateArea,
::std::size_t  nNumSprites 
) const
private
bool canvas::SpriteRedrawManager::isAreaUpdateScroll ( ::basegfx::B2DRectangle o_rMoveStart,
::basegfx::B2DRectangle o_rMoveEnd,
const UpdateArea rUpdateArea,
::std::size_t  nNumSprites 
) const
private

Check whether given update area can be handled by a simple scroll.

Parameters
o_rMoveStartStart rect of the move
o_rMoveEndEnd rect of the move. The content must be moved from start to end rect
rUpdateAreaArea to check for scroll update optimization

Definition at line 318 of file spriteredrawmanager.cxx.

References basegfx::unotools::b2DSurroundingIntegerRangeFromB2DRange(), basegfx::B2DRange::expand(), basegfx::B2DRange::getRange(), canvas::impIsEqualB2DRange(), canvas::impIsEqualB2DVector(), basegfx::B2DConnectedRanges< class >::ConnectedComponents::maComponentList, basegfx::B2DConnectedRanges< class >::ConnectedComponents::maTotalBounds, and SAL_WARN_IF.

void canvas::SpriteRedrawManager::moveSprite ( const Sprite::Reference rSprite,
const ::basegfx::B2DPoint rOldPos,
const ::basegfx::B2DPoint rNewPos,
const ::basegfx::B2DVector rSpriteSize 
)
SpriteRedrawManager& canvas::SpriteRedrawManager::operator= ( const SpriteRedrawManager )
delete
void canvas::SpriteRedrawManager::setupUpdateAreas ( SpriteConnectedRanges rUpdateAreas) const
private

Central method of this class.

Calculates the set of disjunct components that need an update.

Definition at line 214 of file spriteredrawmanager.cxx.

References basegfx::B2DConnectedRanges< class >::addRange(), basegfx::unotools::b2DSurroundingIntegerRangeFromB2DRange(), maChangeRecords, and maSprites.

void canvas::SpriteRedrawManager::showSprite ( const Sprite::Reference rSprite)
void canvas::SpriteRedrawManager::updateSprite ( const Sprite::Reference rSprite,
const ::basegfx::B2DPoint rPos,
const ::basegfx::B2DRange rUpdateArea 
)

Member Data Documentation

VectorOfChangeRecords canvas::SpriteRedrawManager::maChangeRecords
private
VectorOfSprites canvas::SpriteRedrawManager::maSprites
private

Definition at line 388 of file spriteredrawmanager.hxx.

Referenced by disposing(), hideSprite(), setupUpdateAreas(), and showSprite().


The documentation for this class was generated from the following files: