diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-18 14:50:39 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-19 08:30:31 +0200 |
commit | 5dccf84b14ed0e09262411295c5880f787342d59 (patch) | |
tree | 10a9cc313da0186f7a21c02ce8382c62b7f17c61 /basegfx/source/raster | |
parent | bc003c7d41c31509882646900c0b2cc8678f0215 (diff) |
loplugin:flatten in basegfx
Change-Id: Ic8bc586e1a4977322dcb371c0fff6411783df9d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92484
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basegfx/source/raster')
-rw-r--r-- | basegfx/source/raster/rasterconvert3d.cxx | 218 |
1 files changed, 109 insertions, 109 deletions
diff --git a/basegfx/source/raster/rasterconvert3d.cxx b/basegfx/source/raster/rasterconvert3d.cxx index 2e654831c5f3..48a5c7bb518f 100644 --- a/basegfx/source/raster/rasterconvert3d.cxx +++ b/basegfx/source/raster/rasterconvert3d.cxx @@ -57,96 +57,96 @@ namespace basegfx void RasterConverter3D::rasterconvertB3DArea(sal_Int32 nStartLine, sal_Int32 nStopLine) { - if(!maLineEntries.empty()) - { - OSL_ENSURE(nStopLine >= nStartLine, "nStopLine is bigger than nStartLine (!)"); + if(maLineEntries.empty()) + return; + + OSL_ENSURE(nStopLine >= nStartLine, "nStopLine is bigger than nStartLine (!)"); - // sort global entries by Y, X once. After this, the vector - // is seen as frozen. Pointers to its entries will be used in the following code. - std::sort(maLineEntries.begin(), maLineEntries.end()); + // sort global entries by Y, X once. After this, the vector + // is seen as frozen. Pointers to its entries will be used in the following code. + std::sort(maLineEntries.begin(), maLineEntries.end()); - // local parameters - std::vector< RasterConversionLineEntry3D >::iterator aCurrentEntry(maLineEntries.begin()); - std::vector< RasterConversionLineEntry3D* > aCurrentLine; - std::vector< RasterConversionLineEntry3D* > aNextLine; - std::vector< RasterConversionLineEntry3D* >::iterator aRasterConversionLineEntry3D; + // local parameters + std::vector< RasterConversionLineEntry3D >::iterator aCurrentEntry(maLineEntries.begin()); + std::vector< RasterConversionLineEntry3D* > aCurrentLine; + std::vector< RasterConversionLineEntry3D* > aNextLine; + std::vector< RasterConversionLineEntry3D* >::iterator aRasterConversionLineEntry3D; - // get scanlines first LineNumber as start - sal_Int32 nLineNumber(std::max(aCurrentEntry->getY(), nStartLine)); + // get scanlines first LineNumber as start + sal_Int32 nLineNumber(std::max(aCurrentEntry->getY(), nStartLine)); - while((!aCurrentLine.empty() || aCurrentEntry != maLineEntries.end()) && (nLineNumber < nStopLine)) + while((!aCurrentLine.empty() || aCurrentEntry != maLineEntries.end()) && (nLineNumber < nStopLine)) + { + // add all entries which start at current line to current scanline + while(aCurrentEntry != maLineEntries.end()) { - // add all entries which start at current line to current scanline - while(aCurrentEntry != maLineEntries.end()) + const sal_Int32 nCurrentLineNumber(aCurrentEntry->getY()); + + if(nCurrentLineNumber > nLineNumber) + { + // line is below current one, done (since array is sorted) + break; + } + else { - const sal_Int32 nCurrentLineNumber(aCurrentEntry->getY()); + // less or equal. Line is above or at current one. Advance it exactly to + // current line + const sal_uInt32 nStep(nLineNumber - nCurrentLineNumber); - if(nCurrentLineNumber > nLineNumber) - { - // line is below current one, done (since array is sorted) - break; - } - else + if(!nStep || aCurrentEntry->decrementRasterConversionLineEntry3D(nStep)) { - // less or equal. Line is above or at current one. Advance it exactly to - // current line - const sal_uInt32 nStep(nLineNumber - nCurrentLineNumber); - - if(!nStep || aCurrentEntry->decrementRasterConversionLineEntry3D(nStep)) + // add when exactly on current line or when increment to it did not + // completely consume it + if(nStep) { - // add when exactly on current line or when increment to it did not - // completely consume it - if(nStep) - { - aCurrentEntry->incrementRasterConversionLineEntry3D(nStep, *this); - } - - aCurrentLine.push_back(&(*aCurrentEntry)); + aCurrentEntry->incrementRasterConversionLineEntry3D(nStep, *this); } - } - ++aCurrentEntry; + aCurrentLine.push_back(&(*aCurrentEntry)); + } } - // sort current scanline using comparator. Only X is used there - // since all entries are already in one processed line. This needs to be done - // every time since not only new spans may have benn added or old removed, - // but incrementing may also have changed the order - std::sort(aCurrentLine.begin(), aCurrentLine.end(), lineComparator()); + ++aCurrentEntry; + } - // process current scanline - aRasterConversionLineEntry3D = aCurrentLine.begin(); - aNextLine.clear(); - sal_uInt32 nPairCount(0); + // sort current scanline using comparator. Only X is used there + // since all entries are already in one processed line. This needs to be done + // every time since not only new spans may have benn added or old removed, + // but incrementing may also have changed the order + std::sort(aCurrentLine.begin(), aCurrentLine.end(), lineComparator()); - while(aRasterConversionLineEntry3D != aCurrentLine.end()) - { - RasterConversionLineEntry3D& rPrevScanRasterConversionLineEntry3D(**aRasterConversionLineEntry3D++); + // process current scanline + aRasterConversionLineEntry3D = aCurrentLine.begin(); + aNextLine.clear(); + sal_uInt32 nPairCount(0); - // look for 2nd span - if(aRasterConversionLineEntry3D != aCurrentLine.end()) - { - // work on span from rPrevScanRasterConversionLineEntry3D to aRasterConversionLineEntry3D, fLineNumber is valid - processLineSpan(rPrevScanRasterConversionLineEntry3D, **aRasterConversionLineEntry3D, nLineNumber, nPairCount++); - } + while(aRasterConversionLineEntry3D != aCurrentLine.end()) + { + RasterConversionLineEntry3D& rPrevScanRasterConversionLineEntry3D(**aRasterConversionLineEntry3D++); - // increment to next line - if(rPrevScanRasterConversionLineEntry3D.decrementRasterConversionLineEntry3D(1)) - { - rPrevScanRasterConversionLineEntry3D.incrementRasterConversionLineEntry3D(1, *this); - aNextLine.push_back(&rPrevScanRasterConversionLineEntry3D); - } + // look for 2nd span + if(aRasterConversionLineEntry3D != aCurrentLine.end()) + { + // work on span from rPrevScanRasterConversionLineEntry3D to aRasterConversionLineEntry3D, fLineNumber is valid + processLineSpan(rPrevScanRasterConversionLineEntry3D, **aRasterConversionLineEntry3D, nLineNumber, nPairCount++); } - // copy back next scanline if count has changed - if(aNextLine.size() != aCurrentLine.size()) + // increment to next line + if(rPrevScanRasterConversionLineEntry3D.decrementRasterConversionLineEntry3D(1)) { - aCurrentLine = aNextLine; + rPrevScanRasterConversionLineEntry3D.incrementRasterConversionLineEntry3D(1, *this); + aNextLine.push_back(&rPrevScanRasterConversionLineEntry3D); } + } - // increment fLineNumber - nLineNumber++; + // copy back next scanline if count has changed + if(aNextLine.size() != aCurrentLine.size()) + { + aCurrentLine = aNextLine; } + + // increment fLineNumber + nLineNumber++; } } @@ -157,55 +157,55 @@ namespace basegfx sal_Int32 nYStart(fround(aStart.getY())); sal_Int32 nYEnd(fround(aEnd.getY())); - if(nYStart != nYEnd) + if(nYStart == nYEnd) + return; + + if(nYStart > nYEnd) { - if(nYStart > nYEnd) - { - std::swap(aStart, aEnd); - std::swap(nYStart, nYEnd); - std::swap(a, b); - } + std::swap(aStart, aEnd); + std::swap(nYStart, nYEnd); + std::swap(a, b); + } - const sal_uInt32 nYDelta(nYEnd - nYStart); - const double fInvYDelta(1.0 / nYDelta); - maLineEntries.emplace_back( - aStart.getX(), (aEnd.getX() - aStart.getX()) * fInvYDelta, - aStart.getZ(), (aEnd.getZ() - aStart.getZ()) * fInvYDelta, - nYStart, nYDelta); + const sal_uInt32 nYDelta(nYEnd - nYStart); + const double fInvYDelta(1.0 / nYDelta); + maLineEntries.emplace_back( + aStart.getX(), (aEnd.getX() - aStart.getX()) * fInvYDelta, + aStart.getZ(), (aEnd.getZ() - aStart.getZ()) * fInvYDelta, + nYStart, nYDelta); - // if extra interpolation data is used, add it to the last created entry - RasterConversionLineEntry3D& rEntry = maLineEntries[maLineEntries.size() - 1]; + // if extra interpolation data is used, add it to the last created entry + RasterConversionLineEntry3D& rEntry = maLineEntries[maLineEntries.size() - 1]; - if(rFill.areBColorsUsed()) - { - rEntry.setColorIndex(addColorInterpolator(rFill.getBColor(a), rFill.getBColor(b), fInvYDelta)); - } + if(rFill.areBColorsUsed()) + { + rEntry.setColorIndex(addColorInterpolator(rFill.getBColor(a), rFill.getBColor(b), fInvYDelta)); + } - if(rFill.areNormalsUsed()) - { - rEntry.setNormalIndex(addNormalInterpolator(rFill.getNormal(a), rFill.getNormal(b), fInvYDelta)); - } + if(rFill.areNormalsUsed()) + { + rEntry.setNormalIndex(addNormalInterpolator(rFill.getNormal(a), rFill.getNormal(b), fInvYDelta)); + } - if(rFill.areTextureCoordinatesUsed()) - { - if(pViewToEye) - { - const double fEyeA(((*pViewToEye) * aStart).getZ()); - const double fEyeB(((*pViewToEye) * aEnd).getZ()); + if(!rFill.areTextureCoordinatesUsed()) + return; - rEntry.setInverseTextureIndex(addInverseTextureInterpolator( - rFill.getTextureCoordinate(a), - rFill.getTextureCoordinate(b), - fEyeA, fEyeB, fInvYDelta)); - } - else - { - rEntry.setTextureIndex(addTextureInterpolator( - rFill.getTextureCoordinate(a), - rFill.getTextureCoordinate(b), - fInvYDelta)); - } - } + if(pViewToEye) + { + const double fEyeA(((*pViewToEye) * aStart).getZ()); + const double fEyeB(((*pViewToEye) * aEnd).getZ()); + + rEntry.setInverseTextureIndex(addInverseTextureInterpolator( + rFill.getTextureCoordinate(a), + rFill.getTextureCoordinate(b), + fEyeA, fEyeB, fInvYDelta)); + } + else + { + rEntry.setTextureIndex(addTextureInterpolator( + rFill.getTextureCoordinate(a), + rFill.getTextureCoordinate(b), + fInvYDelta)); } } |