30#include <boost/range/adaptor/reversed.hpp>
54 void operator()(
const SpriteRedrawManager::SpriteChangeRecord& rSpriteRecord )
61 switch( rSpriteRecord.meChangeType )
68 rSpriteRecord.maOldPos,
69 rSpriteRecord.maOldPos + rSpriteRecord.maUpdateArea.getRange() );
91 "Unexpected case in SpriteUpdater::operator()" );
120 rUpdateCollector.addRange(
121 ::basegfx::unotools::b2DSurroundingIntegerRangeFromB2DRange(
maMoveEndArea ),
122 SpriteRedrawManager::SpriteInfo(
130 rUpdateCollector.addRange(
131 ::basegfx::unotools::b2DSurroundingIntegerRangeFromB2DRange(
maMoveStartArea ),
132 SpriteRedrawManager::SpriteInfo(
142 rUpdateCollector.addRange(
143 ::basegfx::unotools::b2DSurroundingIntegerRangeFromB2DRange(
maMoveEndArea ),
144 SpriteRedrawManager::SpriteInfo(
199 SpriteTracer aSpriteTracer( rSprite );
202 aSpriteTracer( aChange );
229 if( pSprite->isContentChanged() )
231 pSprite->getPosPixel(),
232 pSprite->getUpdateArea() );
237 std::sort( aSortedSpriteVector.begin(),
238 aSortedSpriteVector.end(),
250 aUpdatableSprites.push_back( rSprite );
253 std::sort( aUpdatableSprites.begin(),
254 aUpdatableSprites.end(),
257 VectorOfSprites::iterator aEnd=
258 std::unique( aUpdatableSprites.begin(),
259 aUpdatableSprites.end() );
264 std::for_each( aUpdatableSprites.begin(),
266 SpriteUpdater( rUpdateAreas,
278 std::set_difference( aSortedSpriteVector.begin(),
279 aSortedSpriteVector.end(),
280 aUpdatableSprites.begin(),
282 std::back_insert_iterator< VectorOfSprites >(aUnchangedSprites),
287 for(
const auto& pUnchangedSprite : aUnchangedSprites )
289 const ::basegfx::B2DRange& rUpdateArea( pUnchangedSprite->getUpdateArea() );
291 ::basegfx::unotools::b2DSurroundingIntegerRangeFromB2DRange( rUpdateArea ),
298#if OSL_DEBUG_LEVEL > 0
309 return fabs(rVecB.
getX() - rVecA.
getX()) <= fSmallValue
310 && fabs(rVecB.
getY() - rVecA.
getY()) <= fSmallValue;
317 std::size_t nNumSprites )
const
327 if( nNumSprites != 2 )
330 const SpriteConnectedRanges::ComponentListType::const_iterator aFirst(
332 SpriteConnectedRanges::ComponentListType::const_iterator aSecond(
336 if( !aFirst->second.isPureMove() ||
337 !aSecond->second.isPureMove() ||
338 !aFirst->second.getSprite().is() ||
340 !aFirst->second.getSprite()->isAreaUpdateOpaque( aFirst->second.getUpdateArea() ) ||
341 aSecond->second.getSprite().is() )
348 o_rMoveStart = aSecond->second.getUpdateArea();
349 o_rMoveEnd = aFirst->second.getUpdateArea();
351#if OSL_DEBUG_LEVEL > 0
353 aTotalBounds.
expand( o_rMoveEnd );
357 "SpriteRedrawManager::isAreaUpdateScroll(): sprite area and total area mismatch");
360 "SpriteRedrawManager::isAreaUpdateScroll(): scroll start and end area have mismatching size");
371 if( !pAffectedSprite.is() )
374 return !pAffectedSprite->isAreaUpdateOpaque( rUpdateRect );
378 std::size_t nNumSprites )
const
392 if( nNumSprites > 3 || nNumSprites < 1 )
399 aTrueArea.
expand(rArea.second.getUpdateArea());
401 const SpriteConnectedRanges::ComponentListType::const_iterator aEnd(
408 [&aTrueArea,
this](
const std::pair< ::basegfx::B2DRange, SpriteInfo >& cp )
409 { return this->isAreaUpdateNotOpaque(aTrueArea, cp); } );
419 const SpriteConnectedRanges::ComponentListType::const_iterator aEnd(
423 [](
const std::pair< ::basegfx::B2DRange, SpriteInfo >& cp )
424 { return cp.second.needsUpdate(); } );
440 for(
const auto& rCurr : boost::adaptors::reverse(
maSprites) )
462 const ::basegfx::B2DPoint& rOldPos,
463 const ::basegfx::B2DPoint& rNewPos,
464 const ::basegfx::B2DVector& rSpriteSize )
473 const ::basegfx::B2DPoint& rPos,
474 const ::basegfx::B2DRange& rUpdateArea )
void addRange(const B2DRange &rRange, const UserData &rUserData)
B2DVector getRange() const
void expand(const Tuple2D< TYPE > &rTuple)
Data container for the connected components list.
This class manages smooth SpriteCanvas updates.
::std::vector< SpriteChangeRecord > VectorOfChangeRecords
VectorOfSprites maSprites
bool areSpritesChanged(const UpdateArea &rUpdateArea) const
void clearChangeRecords()
Clear sprite change records (typically directly after a screen update)
::basegfx::B2DConnectedRanges< SpriteInfo > SpriteConnectedRanges
void moveSprite(const Sprite::Reference &rSprite, const ::basegfx::B2DPoint &rOldPos, const ::basegfx::B2DPoint &rNewPos, const ::basegfx::B2DVector &rSpriteSize)
bool isAreaUpdateNotOpaque(const ::basegfx::B2DRectangle &rUpdateRect, const AreaComponent &rComponent) const
void showSprite(const Sprite::Reference &rSprite)
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.
void setupUpdateAreas(SpriteConnectedRanges &rUpdateAreas) const
Central method of this class.
void updateSprite(const Sprite::Reference &rSprite, const ::basegfx::B2DPoint &rPos, const ::basegfx::B2DRange &rUpdateArea)
SpriteConnectedRanges::ComponentType AreaComponent
::std::vector< Sprite::Reference > VectorOfSprites
void hideSprite(const Sprite::Reference &rSprite)
void disposing()
Must be called when user of this object gets disposed.
bool isAreaUpdateOpaque(const UpdateArea &rUpdateArea, ::std::size_t nNumSprites) const
VectorOfChangeRecords maChangeRecords
::rtl::Reference< Sprite > Reference
#define ENSURE_OR_THROW(c, m)
#define SAL_WARN_IF(condition, area, stream)
static bool impIsEqualB2DVector(const basegfx::B2DVector &rVecA, const basegfx::B2DVector &rVecB, double fSmallValue)
static bool impIsEqualB2DRange(const basegfx::B2DRange &rRangeA, const basegfx::B2DRange &rRangeB, double fSmallValue)
::basegfx::B2DRectangle maMoveEndArea
SpriteRedrawManager::SpriteConnectedRanges & mrUpdater
::basegfx::B2DRectangle maMoveStartArea
Sprite::Reference mpAffectedSprite
const SpriteRedrawManager::VectorOfChangeRecords & mrChangeContainer
bool mbIsMove
True, if at least one move was encountered.
bool mbIsGenericUpdate
True, if at least one generic update was encountered.
ComponentListType maComponentList
Functor providing a StrictWeakOrdering for sprite references.