diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-08-25 21:06:54 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-08-26 09:39:42 +0100 |
commit | fde9961034e954f39a6c221b714813557eb63040 (patch) | |
tree | f3ca3e790b38b3989ae6a4a9d3300198139aa2dd /include/basebmp | |
parent | 9f482b596195a2948a8f7f14664a7a870d348e95 (diff) |
keep acc.set within clip bounds
Change-Id: I6af2eda03148dd400afa2f375b98e396ab0d5f3c
Diffstat (limited to 'include/basebmp')
-rw-r--r-- | include/basebmp/clippedlinerenderer.hxx | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/include/basebmp/clippedlinerenderer.hxx b/include/basebmp/clippedlinerenderer.hxx index b3a5fd098f95..0265a65ee1bb 100644 --- a/include/basebmp/clippedlinerenderer.hxx +++ b/include/basebmp/clippedlinerenderer.hxx @@ -256,6 +256,12 @@ void renderClippedLine( basegfx::B2IPoint aPt1, sal_Int32 xs = x1; sal_Int32 ys = y1; bool bUseAlternateBresenham=false; + + sal_Int32 nMinY(rClipRect.getMinY()); + sal_Int32 nMaxY(rClipRect.getMaxY()-1); + sal_Int32 nMinX(rClipRect.getMinX()); + sal_Int32 nMaxX(rClipRect.getMaxX()-1); + if( adx >= ady ) { // semi-horizontal line @@ -263,10 +269,10 @@ void renderClippedLine( basegfx::B2IPoint aPt1, if( !prepareClip(x1, x2, y1, adx, ady, xs, ys, sx, sy, rem, n, clipCode1, clipCount1, clipCode2, clipCount2, - rClipRect.getMinX(), basegfx::tools::RectClipFlags::LEFT, - rClipRect.getMaxX()-1, basegfx::tools::RectClipFlags::RIGHT, - rClipRect.getMinY(), basegfx::tools::RectClipFlags::TOP, - rClipRect.getMaxY()-1, basegfx::tools::RectClipFlags::BOTTOM, + nMinX, basegfx::tools::RectClipFlags::LEFT, + nMaxX, basegfx::tools::RectClipFlags::RIGHT, + nMinY, basegfx::tools::RectClipFlags::TOP, + nMaxY, basegfx::tools::RectClipFlags::BOTTOM, bRoundTowardsPt2, bUseAlternateBresenham ) ) return; // line fully clipped away, no active pixel inside rect @@ -284,7 +290,8 @@ void renderClippedLine( basegfx::B2IPoint aPt1, while(true) { - acc.set(color, rowIter); + if (xs >= nMinX && xs <= nMaxX && ys >= nMinY && ys <= nMaxY) + acc.set(color, rowIter); if( rem >= 0 ) { @@ -313,7 +320,8 @@ void renderClippedLine( basegfx::B2IPoint aPt1, { while(true) { - acc.set(color, rowIter); + if (xs >= nMinX && xs <= nMaxX && ys >= nMinY && ys <= nMaxY) + acc.set(color, rowIter); if( --n < 0 ) break; @@ -344,10 +352,10 @@ void renderClippedLine( basegfx::B2IPoint aPt1, if( !prepareClip(y1, y2, x1, ady, adx, ys, xs, sy, sx, rem, n, clipCode1, clipCount1, clipCode2, clipCount2, - rClipRect.getMinY(), basegfx::tools::RectClipFlags::TOP, - rClipRect.getMaxY()-1, basegfx::tools::RectClipFlags::BOTTOM, - rClipRect.getMinX(), basegfx::tools::RectClipFlags::LEFT, - rClipRect.getMaxX()-1, basegfx::tools::RectClipFlags::RIGHT, + nMinY, basegfx::tools::RectClipFlags::TOP, + nMaxY, basegfx::tools::RectClipFlags::BOTTOM, + nMinX, basegfx::tools::RectClipFlags::LEFT, + nMaxY, basegfx::tools::RectClipFlags::RIGHT, bRoundTowardsPt2, bUseAlternateBresenham ) ) return; // line fully clipped away, no active pixel inside rect @@ -365,7 +373,8 @@ void renderClippedLine( basegfx::B2IPoint aPt1, while(true) { - acc.set(color, colIter); + if (xs >= nMinX && xs <= nMaxX && ys >= nMinY && ys <= nMaxY) + acc.set(color, colIter); if( rem >= 0 ) { @@ -376,6 +385,7 @@ void renderClippedLine( basegfx::B2IPoint aPt1, xs += sx; ys += sy; + rem -= ady; currIter.x += sx; @@ -394,7 +404,8 @@ void renderClippedLine( basegfx::B2IPoint aPt1, { while(true) { - acc.set(color, colIter); + if (xs >= nMinX && xs <= nMaxX && ys >= nMinY && ys <= nMaxY) + acc.set(color, colIter); if( --n < 0 ) break; |