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

◆ AreaComponent

Definition at line 178 of file spriteredrawmanager.hxx.

◆ SpriteConnectedRanges

Definition at line 177 of file spriteredrawmanager.hxx.

◆ UpdateArea

Definition at line 179 of file spriteredrawmanager.hxx.

◆ VectorOfChangeRecords

Definition at line 176 of file spriteredrawmanager.hxx.

◆ VectorOfSprites

Definition at line 180 of file spriteredrawmanager.hxx.

Constructor & Destructor Documentation

◆ SpriteRedrawManager() [1/2]

canvas::SpriteRedrawManager::SpriteRedrawManager ( )

Definition at line 427 of file spriteredrawmanager.cxx.

◆ SpriteRedrawManager() [2/2]

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

Member Function Documentation

◆ areSpritesChanged()

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

◆ clearChangeRecords()

void canvas::SpriteRedrawManager::clearChangeRecords ( )

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

Definition at line 446 of file spriteredrawmanager.cxx.

References maChangeRecords.

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

◆ disposing()

void canvas::SpriteRedrawManager::disposing ( )

Must be called when user of this object gets disposed.

Frees all internal references.

Definition at line 431 of file spriteredrawmanager.cxx.

References maChangeRecords, and maSprites.

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

◆ forEachSprite()

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: \n Functor
Must provide a Functor::operator( Sprite::Reference& ) method.

Definition at line 257 of file spriteredrawmanager.hxx.

References maSprites.

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

◆ forEachSpriteArea()

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: \n 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 238 of file spriteredrawmanager.hxx.

References basegfx::B2DConnectedRanges< typename UserData >::forEachAggregate().

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

◆ handleArea()

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 285 of file spriteredrawmanager.hxx.

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

◆ hideSprite()

void canvas::SpriteRedrawManager::hideSprite ( const Sprite::Reference rSprite)

◆ isAreaUpdateNotOpaque()

bool canvas::SpriteRedrawManager::isAreaUpdateNotOpaque ( const ::basegfx::B2DRectangle rUpdateRect,
const AreaComponent rComponent 
) const
private

Definition at line 366 of file spriteredrawmanager.cxx.

◆ isAreaUpdateOpaque()

bool canvas::SpriteRedrawManager::isAreaUpdateOpaque ( const UpdateArea rUpdateArea,
::std::size_t  nNumSprites 
) const
private

◆ isAreaUpdateScroll()

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 314 of file spriteredrawmanager.cxx.

References basegfx::unotools::b2DSurroundingIntegerRangeFromB2DRange(), basegfx::Range2D< typename TYPE, typename TRAITS >::expand(), basegfx::B2DRange::getRange(), canvas::impIsEqualB2DRange(), canvas::impIsEqualB2DVector(), basegfx::B2DConnectedRanges< typename UserData >::ConnectedComponents::maComponentList, basegfx::B2DConnectedRanges< typename UserData >::ConnectedComponents::maTotalBounds, and SAL_WARN_IF.

◆ moveSprite()

void canvas::SpriteRedrawManager::moveSprite ( const Sprite::Reference rSprite,
const ::basegfx::B2DPoint rOldPos,
const ::basegfx::B2DPoint rNewPos,
const ::basegfx::B2DVector rSpriteSize 
)

◆ operator=()

SpriteRedrawManager & canvas::SpriteRedrawManager::operator= ( const SpriteRedrawManager )
delete

◆ setupUpdateAreas()

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 213 of file spriteredrawmanager.cxx.

References basegfx::B2DConnectedRanges< typename UserData >::addRange(), maChangeRecords, maSprites, and updateSprite().

◆ showSprite()

void canvas::SpriteRedrawManager::showSprite ( const Sprite::Reference rSprite)

◆ updateSprite()

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

Member Data Documentation

◆ maChangeRecords

VectorOfChangeRecords canvas::SpriteRedrawManager::maChangeRecords
private

◆ maSprites

VectorOfSprites canvas::SpriteRedrawManager::maSprites
private

Definition at line 386 of file spriteredrawmanager.hxx.

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


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