summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorDaniel Robertson <danlrobertson89@gmail.com>2015-08-25 12:24:33 -0400
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2015-08-30 13:03:22 +0000
commitb7f4940c150b3bdd639afa988573a29774fff1f6 (patch)
tree7c4c6bc9af26b8fa282781ebffbc1a95f6a6037a /canvas
parent49cb81b411e1c68cada5d3f4375de713118fce64 (diff)
canvas: replace while loops with range-based for
Change-Id: Ide16bee666cf4df41646f9336a585e22a7fe53bd Reviewed-on: https://gerrit.libreoffice.org/18131 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/directx/dx_config.cxx7
-rw-r--r--canvas/source/opengl/ogl_canvashelper.cxx54
-rw-r--r--canvas/source/opengl/ogl_texturecache.cxx22
-rw-r--r--canvas/source/tools/canvascustomspritehelper.cxx9
-rw-r--r--canvas/source/tools/page.cxx16
-rw-r--r--canvas/source/tools/pagemanager.cxx17
-rw-r--r--canvas/source/tools/spriteredrawmanager.cxx33
7 files changed, 54 insertions, 104 deletions
diff --git a/canvas/source/directx/dx_config.cxx b/canvas/source/directx/dx_config.cxx
index e4abde4dda51..be4c3c70bbf2 100644
--- a/canvas/source/directx/dx_config.cxx
+++ b/canvas/source/directx/dx_config.cxx
@@ -102,11 +102,9 @@ namespace dxcanvas
uno::Sequence< sal_Int32 > aValues( sizeof(DeviceInfo)/sizeof(sal_Int32)*maValues.size() );
sal_Int32* pValues = aValues.getArray();
- ValueSet::const_iterator aIter( maValues.begin() );
- const ValueSet::const_iterator aEnd( maValues.end() );
- while( aIter != aEnd )
+ for( const auto& rValueSet : maValues )
{
- const DeviceInfo& rInfo( *aIter );
+ const DeviceInfo& rInfo( rValueSet );
*pValues++ = rInfo.nVendorId;
*pValues++ = rInfo.nDeviceId;
*pValues++ = rInfo.nDeviceSubSysId;
@@ -115,7 +113,6 @@ namespace dxcanvas
*pValues++ = rInfo.nDriverVersion;
*pValues++ = rInfo.nDriverSubVersion;
*pValues++ = rInfo.nDriverBuildId;
- ++aIter;
}
uno::Sequence< uno::Any > aValue(1);
diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx
index 1534f7c3b10a..61a677350fa0 100644
--- a/canvas/source/opengl/ogl_canvashelper.cxx
+++ b/canvas/source/opengl/ogl_canvashelper.cxx
@@ -139,10 +139,8 @@ namespace oglcanvas
TransformationPreserver aPreserver;
setupState(rTransform, eSrcBlend, eDstBlend, rColor);
- ::basegfx::B2DPolyPolygonVector::const_iterator aCurr=rPolyPolygons.begin();
- const ::basegfx::B2DPolyPolygonVector::const_iterator aEnd=rPolyPolygons.end();
- while( aCurr != aEnd )
- renderPolyPolygon(*aCurr++);
+ for( const auto& rPoly : rPolyPolygons )
+ renderPolyPolygon( rPoly );
return true;
}
@@ -157,12 +155,10 @@ namespace oglcanvas
TransformationPreserver aPreserver;
setupState(rTransform, eSrcBlend, eDstBlend, rColor);
- ::basegfx::B2DPolyPolygonVector::const_iterator aCurr=rPolyPolygons.begin();
- const ::basegfx::B2DPolyPolygonVector::const_iterator aEnd=rPolyPolygons.end();
- while( aCurr != aEnd )
+ for( const auto& rPoly : rPolyPolygons )
{
- glBegin(GL_TRIANGLES);
- renderComplexPolyPolygon(*aCurr++);
+ glBegin( GL_TRIANGLES );
+ renderComplexPolyPolygon( rPoly );
glEnd();
}
@@ -186,10 +182,8 @@ namespace oglcanvas
::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
rTexture.AffineTransform );
::basegfx::B2DRange aBounds;
- ::basegfx::B2DPolyPolygonVector::const_iterator aCurr=rPolyPolygons.begin();
- const ::basegfx::B2DPolyPolygonVector::const_iterator aEnd=rPolyPolygons.end();
- while( aCurr != aEnd )
- aBounds.expand(::basegfx::tools::getRange(*aCurr++));
+ for( const auto& rPoly : rPolyPolygons )
+ aBounds.expand( ::basegfx::tools::getRange( rPoly ) );
aTextureTransform.translate(-aBounds.getMinX(), -aBounds.getMinY());
aTextureTransform.scale(1/aBounds.getWidth(), 1/aBounds.getHeight());
@@ -228,11 +222,10 @@ namespace oglcanvas
}
- aCurr=rPolyPolygons.begin();
- while( aCurr != aEnd )
+ for( const auto& rPoly : rPolyPolygons )
{
glBegin(GL_TRIANGLES);
- renderComplexPolyPolygon(*aCurr++);
+ renderComplexPolyPolygon( rPoly );
glEnd();
}
@@ -333,10 +326,8 @@ namespace oglcanvas
::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
rTexture.AffineTransform );
::basegfx::B2DRange aBounds;
- ::basegfx::B2DPolyPolygonVector::const_iterator aCurr=rPolyPolygons.begin();
- const ::basegfx::B2DPolyPolygonVector::const_iterator aEnd=rPolyPolygons.end();
- while( aCurr != aEnd )
- aBounds.expand(::basegfx::tools::getRange(*aCurr++));
+ for( const auto& rPolyPolygon : rPolyPolygons )
+ aBounds.expand( ::basegfx::tools::getRange( rPolyPolygon ) );
aTextureTransform.translate(-aBounds.getMinX(), -aBounds.getMinY());
aTextureTransform.scale(1/aBounds.getWidth(), 1/aBounds.getHeight());
aTextureTransform.invert();
@@ -354,11 +345,10 @@ namespace oglcanvas
// blend against fixed vertex color; texture alpha is multiplied in
glColor4f(1,1,1,rTexture.Alpha);
- aCurr=rPolyPolygons.begin();
- while( aCurr != aEnd )
+ for( const auto& rPolyPolygon : rPolyPolygons )
{
glBegin(GL_TRIANGLES);
- renderComplexPolyPolygon(*aCurr++);
+ renderComplexPolyPolygon( rPolyPolygon );
glEnd();
}
@@ -973,19 +963,15 @@ namespace oglcanvas
bool CanvasHelper::renderRecordedActions() const
{
- std::vector<Action>::const_iterator aCurr(mpRecordedActions->begin());
- const std::vector<Action>::const_iterator aEnd(mpRecordedActions->end());
- while( aCurr != aEnd )
+ for( const auto& rRecordedAction : *mpRecordedActions )
{
- if( !aCurr->maFunction( *this,
- aCurr->maTransform,
- aCurr->meSrcBlendMode,
- aCurr->meDstBlendMode,
- aCurr->maARGBColor,
- aCurr->maPolyPolys ) )
+ if( !rRecordedAction.maFunction( *this,
+ rRecordedAction.maTransform,
+ rRecordedAction.meSrcBlendMode,
+ rRecordedAction.meDstBlendMode,
+ rRecordedAction.maARGBColor,
+ rRecordedAction.maPolyPolys ) )
return false;
-
- ++aCurr;
}
return true;
diff --git a/canvas/source/opengl/ogl_texturecache.cxx b/canvas/source/opengl/ogl_texturecache.cxx
index 6283bd883993..9335ff965808 100644
--- a/canvas/source/opengl/ogl_texturecache.cxx
+++ b/canvas/source/opengl/ogl_texturecache.cxx
@@ -37,12 +37,9 @@ namespace oglcanvas
glBindTexture(GL_TEXTURE_2D, 0);
// delete all cached textures
- TextureCacheMapT::const_iterator aCurr=maCache.begin();
- const TextureCacheMapT::const_iterator aEnd=maCache.end();
- while( aCurr != aEnd )
+ for( const auto& rCache : maCache )
{
- glDeleteTextures(1, &aCurr->second.nTexture);
- ++aCurr;
+ glDeleteTextures( 1, &rCache.second.nTexture );
}
maCache.clear();
@@ -56,22 +53,21 @@ namespace oglcanvas
glBindTexture(GL_TEXTURE_2D, 0);
// delete already "old" textures, mark "new" entries "old"
- TextureCacheMapT::iterator aNext;
- TextureCacheMapT::iterator aCurr=maCache.begin();
- const TextureCacheMapT::iterator aEnd=maCache.end();
- while( aCurr != aEnd )
+ const TextureCacheMapT::const_iterator aEnd = maCache.end();
+ TextureCacheMapT::iterator aNext = maCache.begin();
+ ++aNext;
+ for( auto aCurr = maCache.begin(); aCurr != aEnd; ++aNext )
{
- aNext=aCurr; ++aNext;
if( aCurr->second.bOld )
{
- glDeleteTextures(1, &aCurr->second.nTexture);
- maCache.erase(aCurr);
+ glDeleteTextures( 1, &aCurr->second.nTexture );
+ maCache.erase( aCurr );
}
else
{
aCurr->second.bOld = true;
}
- aCurr=aNext;
+ aCurr = aNext;
}
mnMissCount = 0;
diff --git a/canvas/source/tools/canvascustomspritehelper.cxx b/canvas/source/tools/canvascustomspritehelper.cxx
index c02f890da09e..49a266ee6a91 100644
--- a/canvas/source/tools/canvascustomspritehelper.cxx
+++ b/canvas/source/tools/canvascustomspritehelper.cxx
@@ -123,17 +123,14 @@ namespace canvas
// translate this area to the final position,
// coordinates need to be relative to the
// spritecanvas.
- VectorOfRects::const_iterator aCurr( aClipDifferences.begin() );
- const VectorOfRects::const_iterator aEnd( aClipDifferences.end() );
- while( aCurr != aEnd )
+ for( const auto& rClipDiff : aClipDifferences )
{
mpSpriteCanvas->updateSprite(
rSprite,
maPosition,
::basegfx::B2DRectangle(
- maPosition + aCurr->getMinimum(),
- maPosition + aCurr->getMaximum() ) );
- ++aCurr;
+ maPosition + rClipDiff.getMinimum(),
+ maPosition + rClipDiff.getMaximum() ) );
}
// update calls all done
diff --git a/canvas/source/tools/page.cxx b/canvas/source/tools/page.cxx
index b942b3b9fa15..d9b7c08f3f75 100644
--- a/canvas/source/tools/page.cxx
+++ b/canvas/source/tools/page.cxx
@@ -84,11 +84,9 @@ namespace canvas
bool Page::insert( SurfaceRect& r )
{
- const FragmentContainer_t::const_iterator aEnd(mpFragments.end());
- FragmentContainer_t::const_iterator it(mpFragments.begin());
- while(it != aEnd)
+ for( const auto& pFragment : mpFragments )
{
- const SurfaceRect &rect = (*it)->getRect();
+ const SurfaceRect &rect = pFragment->getRect();
const sal_Int32 x = rect.maPos.getX();
const sal_Int32 y = rect.maPos.getY();
// to avoid interpolation artifacts from other textures,
@@ -107,8 +105,6 @@ namespace canvas
r.maPos.setY(y+h);
if(isValidLocation(r))
return true;
-
- ++it;
}
r.maPos.setX(0);
@@ -126,14 +122,10 @@ namespace canvas
if( !r.inside(aBoundary) )
return false;
- const FragmentContainer_t::const_iterator aEnd(mpFragments.end());
- FragmentContainer_t::const_iterator it(mpFragments.begin());
- while(it != aEnd)
+ for( const auto& pFragment : mpFragments )
{
- if(r.intersection((*it)->getRect()))
+ if( r.intersection( pFragment->getRect() ) )
return false;
-
- ++it;
}
return true;
diff --git a/canvas/source/tools/pagemanager.cxx b/canvas/source/tools/pagemanager.cxx
index 9b8466d7bb2c..f7faee000287 100644
--- a/canvas/source/tools/pagemanager.cxx
+++ b/canvas/source/tools/pagemanager.cxx
@@ -28,11 +28,9 @@ namespace canvas
// we are asked to find a location for the requested size.
// first we try to satisfy the request from the
// remaining space in the existing pages.
- const PageContainer_t::iterator aEnd(maPages.end());
- PageContainer_t::iterator it(maPages.begin());
- while(it != aEnd)
+ for( const auto& pPage : maPages )
{
- FragmentSharedPtr pFragment((*it)->allocateSpace(rSize));
+ FragmentSharedPtr pFragment( pPage->allocateSpace(rSize) );
if(pFragment)
{
// the page created a new fragment, since we maybe want
@@ -41,8 +39,6 @@ namespace canvas
maFragments.push_back(pFragment);
return pFragment;
}
-
- ++it;
}
// otherwise try to create a new page and allocate space there...
@@ -140,23 +136,18 @@ namespace canvas
// be naked, that is it is not located on any page.
// we try all available pages again, maybe some
// other fragment was deleted and we can exploit the space.
- const PageContainer_t::iterator aEnd(maPages.end());
- PageContainer_t::iterator it(maPages.begin());
- while(it != aEnd)
+ for( const auto& pPage : maPages )
{
// if the page at hand takes the fragment, we immediately
// call select() to pull the information from the associated
// image to the hardware surface.
- if((*it)->nakedFragment(pFragment))
+ if( pPage->nakedFragment( pFragment ) )
{
// dirty, since newly allocated.
pFragment->select(true);
return true;
}
-
- ++it;
}
-
return false;
}
diff --git a/canvas/source/tools/spriteredrawmanager.cxx b/canvas/source/tools/spriteredrawmanager.cxx
index 8e2bebf49cfc..aa44097b3ea5 100644
--- a/canvas/source/tools/spriteredrawmanager.cxx
+++ b/canvas/source/tools/spriteredrawmanager.cxx
@@ -225,15 +225,12 @@ namespace canvas
SpriteWeakOrder aSpriteComparator;
// put all sprites that have changed content into update areas
- ListOfSprites::const_iterator aCurrSprite( maSprites.begin() );
- const ListOfSprites::const_iterator aEndSprite ( maSprites.end() );
- while( aCurrSprite != aEndSprite )
+ for( const auto& pSprite : maSprites )
{
- if( (*aCurrSprite)->isContentChanged() )
- const_cast<SpriteRedrawManager*>(this)->updateSprite( *aCurrSprite,
- (*aCurrSprite)->getPosPixel(),
- (*aCurrSprite)->getUpdateArea() );
- ++aCurrSprite;
+ if( pSprite->isContentChanged() )
+ const_cast< SpriteRedrawManager* >( this )->updateSprite( pSprite,
+ pSprite->getPosPixel(),
+ pSprite->getUpdateArea() );
}
// sort sprites after prio
@@ -250,14 +247,11 @@ namespace canvas
// sprite pointer). This assumes that, until this scope
// ends, nobody changes the maChangeRecords vector!
VectorOfSprites aUpdatableSprites;
- VectorOfChangeRecords::const_iterator aCurrRecord( maChangeRecords.begin() );
- const VectorOfChangeRecords::const_iterator aEndRecords( maChangeRecords.end() );
- while( aCurrRecord != aEndRecords )
+ for( const auto& rChangeRecord : maChangeRecords )
{
- const Sprite::Reference& rSprite( aCurrRecord->getSprite() );
+ const Sprite::Reference& rSprite( rChangeRecord.getSprite() );
if( rSprite.is() )
aUpdatableSprites.push_back( rSprite );
- ++aCurrRecord;
}
::std::sort( aUpdatableSprites.begin(),
@@ -294,17 +288,14 @@ namespace canvas
// add each remaining unchanged sprite to connected ranges,
// marked as "don't need update"
- VectorOfSprites::const_iterator aCurr( aUnchangedSprites.begin() );
- const VectorOfSprites::const_iterator aEnd2( aUnchangedSprites.end() );
- while( aCurr != aEnd2 )
+ for( const auto& pUnchangedSprite : aUnchangedSprites )
{
- const ::basegfx::B2DRange& rUpdateArea( (*aCurr)->getUpdateArea() );
+ const ::basegfx::B2DRange& rUpdateArea( pUnchangedSprite->getUpdateArea() );
rUpdateAreas.addRange(
::basegfx::unotools::b2DSurroundingIntegerRangeFromB2DRange( rUpdateArea ),
- SpriteInfo(*aCurr,
- rUpdateArea,
- false) );
- ++aCurr;
+ SpriteInfo( pUnchangedSprite,
+ rUpdateArea,
+ false ) );
}
}