summaryrefslogtreecommitdiff
path: root/canvas/source/opengl
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/source/opengl
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/source/opengl')
-rw-r--r--canvas/source/opengl/ogl_canvashelper.cxx54
-rw-r--r--canvas/source/opengl/ogl_texturecache.cxx22
2 files changed, 29 insertions, 47 deletions
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;