LibreOffice Module canvas (master) 1
|
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< SpriteChangeRecord > | VectorOfChangeRecords |
typedef ::basegfx::B2DConnectedRanges< SpriteInfo > | SpriteConnectedRanges |
typedef SpriteConnectedRanges::ComponentType | AreaComponent |
typedef SpriteConnectedRanges::ConnectedComponents | UpdateArea |
typedef ::std::vector< Sprite::Reference > | VectorOfSprites |
Public Member Functions | |
SpriteRedrawManager () | |
SpriteRedrawManager (const SpriteRedrawManager &)=delete | |
SpriteRedrawManager & | operator= (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 |
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.
Definition at line 178 of file spriteredrawmanager.hxx.
typedef ::basegfx::B2DConnectedRanges< SpriteInfo > canvas::SpriteRedrawManager::SpriteConnectedRanges |
Definition at line 177 of file spriteredrawmanager.hxx.
Definition at line 179 of file spriteredrawmanager.hxx.
typedef ::std::vector< SpriteChangeRecord > canvas::SpriteRedrawManager::VectorOfChangeRecords |
Definition at line 176 of file spriteredrawmanager.hxx.
typedef ::std::vector< Sprite::Reference > canvas::SpriteRedrawManager::VectorOfSprites |
Definition at line 180 of file spriteredrawmanager.hxx.
canvas::SpriteRedrawManager::SpriteRedrawManager | ( | ) |
Definition at line 427 of file spriteredrawmanager.cxx.
|
delete |
|
private |
Definition at line 412 of file spriteredrawmanager.cxx.
References basegfx::B2DConnectedRanges< typename UserData >::ConnectedComponents::maComponentList.
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().
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().
|
inline |
Call given functor for each active sprite.
This method calls the given functor for each active sprite, in the order of sprite priority.
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().
|
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).
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().
|
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.
void canvas::SpriteRedrawManager::hideSprite | ( | const Sprite::Reference & | rSprite | ) |
Definition at line 456 of file spriteredrawmanager.cxx.
References maSprites.
Referenced by canvas::SpriteCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >::hideSprite().
|
private |
Definition at line 366 of file spriteredrawmanager.cxx.
|
private |
Definition at line 377 of file spriteredrawmanager.cxx.
References basegfx::Range2D< typename TYPE, typename TRAITS >::expand(), and basegfx::B2DConnectedRanges< typename UserData >::ConnectedComponents::maComponentList.
|
private |
Check whether given update area can be handled by a simple scroll.
o_rMoveStart | Start rect of the move |
o_rMoveEnd | End rect of the move. The content must be moved from start to end rect |
rUpdateArea | Area 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.
void canvas::SpriteRedrawManager::moveSprite | ( | const Sprite::Reference & | rSprite, |
const ::basegfx::B2DPoint & | rOldPos, | ||
const ::basegfx::B2DPoint & | rNewPos, | ||
const ::basegfx::B2DVector & | rSpriteSize | ||
) |
Definition at line 461 of file spriteredrawmanager.cxx.
References maChangeRecords.
Referenced by canvas::SpriteCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >::moveSprite().
|
delete |
|
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().
void canvas::SpriteRedrawManager::showSprite | ( | const Sprite::Reference & | rSprite | ) |
Definition at line 451 of file spriteredrawmanager.cxx.
References maSprites.
Referenced by canvas::SpriteCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >::showSprite().
void canvas::SpriteRedrawManager::updateSprite | ( | const Sprite::Reference & | rSprite, |
const ::basegfx::B2DPoint & | rPos, | ||
const ::basegfx::B2DRange & | rUpdateArea | ||
) |
Definition at line 472 of file spriteredrawmanager.cxx.
References maChangeRecords.
Referenced by setupUpdateAreas(), vclcanvas::SpriteCanvasHelper::updateScreen(), and canvas::SpriteCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >::updateSprite().
|
private |
Definition at line 398 of file spriteredrawmanager.hxx.
Referenced by clearChangeRecords(), disposing(), moveSprite(), setupUpdateAreas(), and updateSprite().
|
private |
Definition at line 386 of file spriteredrawmanager.hxx.
Referenced by disposing(), hideSprite(), setupUpdateAreas(), and showSprite().