[Libreoffice-commits] core.git: 2 commits - basebmp/CppunitTest_basebmp.mk basebmp/inc basebmp/Library_basebmp.mk basebmp/source basebmp/StaticLibrary_basebmp.mk basebmp/test include/basebmp vcl/android vcl/headless
Caolán McNamara
caolanm at redhat.com
Mon Jan 18 06:00:18 PST 2016
basebmp/CppunitTest_basebmp.mk | 7
basebmp/Library_basebmp.mk | 1
basebmp/StaticLibrary_basebmp.mk | 1
basebmp/inc/clippedlinerenderer.hxx | 438 ---------------------
basebmp/inc/polypolygonrenderer.hxx | 355 -----------------
basebmp/source/bitmapdevice.cxx | 684 ---------------------------------
basebmp/source/polypolygonrenderer.cxx | 121 -----
basebmp/test/bmpmasktest.cxx | 213 ----------
basebmp/test/bmptest.cxx | 195 ---------
basebmp/test/cliptest.cxx | 239 -----------
basebmp/test/filltest.cxx | 239 -----------
basebmp/test/linetest.cxx | 234 -----------
basebmp/test/masktest.cxx | 143 ------
basebmp/test/polytest.cxx | 326 ---------------
include/basebmp/bitmapdevice.hxx | 344 ----------------
vcl/android/androidinst.cxx | 1
vcl/headless/svpgdi.cxx | 19
17 files changed, 15 insertions(+), 3545 deletions(-)
New commits:
commit 0646821f5578a3919cbbb44ab1ec4666872ffd79
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Jan 18 12:02:26 2016 +0000
drop newly unused basebmp methods
Change-Id: Ifd9906e7288c613eb2ac6cde7ca8bc7607f349fa
diff --git a/basebmp/CppunitTest_basebmp.mk b/basebmp/CppunitTest_basebmp.mk
index 17ba6db..08fc174 100644
--- a/basebmp/CppunitTest_basebmp.mk
+++ b/basebmp/CppunitTest_basebmp.mk
@@ -25,13 +25,6 @@ $(eval $(call gb_CppunitTest_use_libraries,basebmp,\
$(eval $(call gb_CppunitTest_add_exception_objects,basebmp,\
basebmp/test/basictest \
- basebmp/test/bmpmasktest \
- basebmp/test/bmptest \
- basebmp/test/cliptest \
- basebmp/test/filltest \
- basebmp/test/linetest \
- basebmp/test/masktest \
- basebmp/test/polytest \
basebmp/test/tools \
))
diff --git a/basebmp/Library_basebmp.mk b/basebmp/Library_basebmp.mk
index 809671c..3523ddf 100644
--- a/basebmp/Library_basebmp.mk
+++ b/basebmp/Library_basebmp.mk
@@ -49,7 +49,6 @@ endif
$(eval $(call gb_Library_add_exception_objects,basebmp,\
basebmp/source/bitmapdevice \
basebmp/source/debug \
- basebmp/source/polypolygonrenderer \
))
# vim: set noet sw=4 ts=4:
diff --git a/basebmp/StaticLibrary_basebmp.mk b/basebmp/StaticLibrary_basebmp.mk
index e98e266..d08646f 100644
--- a/basebmp/StaticLibrary_basebmp.mk
+++ b/basebmp/StaticLibrary_basebmp.mk
@@ -34,7 +34,6 @@ $(eval $(call gb_StaticLibrary_add_defs,basebmp,\
$(eval $(call gb_StaticLibrary_add_exception_objects,basebmp,\
basebmp/source/bitmapdevice \
basebmp/source/debug \
- basebmp/source/polypolygonrenderer \
))
# vim: set noet sw=4 ts=4:
diff --git a/basebmp/inc/clippedlinerenderer.hxx b/basebmp/inc/clippedlinerenderer.hxx
deleted file mode 100644
index e863872..0000000
--- a/basebmp/inc/clippedlinerenderer.hxx
+++ /dev/null
@@ -1,438 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_BASEBMP_INC_CLIPPEDLINERENDERER_HXX
-#define INCLUDED_BASEBMP_INC_CLIPPEDLINERENDERER_HXX
-
-#include <basegfx/tools/rectcliptools.hxx>
-#include <basegfx/point/b2ipoint.hxx>
-#include <basegfx/range/b2ibox.hxx>
-
-#include <vigra/diff2d.hxx>
-#include <vigra/iteratortraits.hxx>
-
-namespace basebmp
-{
-
-// factored-out bresenham setup code, which is used from two different
-// places in renderClippedLine() below. Admittedly messy for the long
-// parameter list...
-inline bool prepareClip( sal_Int32 a1,
- sal_Int32 a2,
- sal_Int32 b1,
- sal_Int32 da,
- sal_Int32 db,
- sal_Int32& o_as,
- sal_Int32& o_bs,
- int sa,
- int sb,
- sal_Int32& io_rem,
- int& o_n,
- sal_uInt32 clipCode1,
- sal_uInt32 clipCount1,
- sal_uInt32 clipCode2,
- sal_uInt32 clipCount2,
- sal_Int32 aMin,
- sal_uInt32 aMinFlag,
- sal_Int32 aMax,
- sal_uInt32 aMaxFlag,
- sal_Int32 bMin,
- sal_uInt32 bMinFlag,
- sal_Int32 bMax,
- sal_uInt32 bMaxFlag,
- bool bRoundTowardsPt2,
- bool& o_bUseAlternateBresenham )
-{
- int ca(0), cb(0);
- if( clipCode1 )
- {
- if( clipCode1 & aMinFlag )
- {
- ca = 2*db*(aMin - a1);
- o_as = aMin;
- }
- else if( clipCode1 & aMaxFlag )
- {
- ca = 2*db*(a1 - aMax);
- o_as = aMax;
- }
-
- if( clipCode1 & bMinFlag )
- {
- cb = 2*da*(bMin - b1);
- o_bs = bMin;
- }
- else if( clipCode1 & bMaxFlag )
- {
- cb = 2*da*(b1 - bMax);
- o_bs = bMax;
- }
-
- if( clipCount1 == 2 )
- clipCode1 &= (ca + da < cb + int(!bRoundTowardsPt2)) ? ~(aMinFlag|aMaxFlag) : ~(bMinFlag|bMaxFlag);
-
- if( clipCode1 & (aMinFlag|aMaxFlag) )
- {
- sal_Int32 da2 = 2*da;
-
- if (da2 == 0)
- return false; // overflow
-
- cb = (ca + da - int(!bRoundTowardsPt2)) / (da2);
-
- if( sb >= 0 )
- {
- o_bs = b1 + cb;
- if( o_bs > bMax )
- return false; // fully clipped
- }
- else
- {
- o_bs = b1 - cb;
- if( o_bs < bMin )
- return false; // fully clipped
- }
-
- io_rem += ca - da2*cb;
- }
- else
- {
- sal_Int32 db2 = 2*db;
-
- if (db2 == 0)
- return false; // overflow
-
- ca = (cb - da + db2 - int(bRoundTowardsPt2)) / (db2);
- if( sa >= 0 )
- {
- o_as = a1 + ca;
- if( o_as > aMax )
- return false; // fully clipped
- }
- else
- {
- o_as = a1 - ca;
- if( o_as < aMin )
- return false; // fully clipped
- }
-
- io_rem += db2*ca - cb;
- }
- }
- else
- {
- o_as = a1; o_bs = b1;
- }
-
- if( clipCode2 )
- {
- if( clipCount2 == 2 )
- {
- ca = 2*db*((clipCode2 & aMinFlag) ? a1 - aMin : aMax - a1);
- cb = 2*da*((clipCode2 & bMinFlag) ? b1 - bMin : bMax - b1);
- clipCode2 &= (cb + da < ca + int(bRoundTowardsPt2)) ? ~(aMinFlag|aMaxFlag) : ~(bMinFlag|bMaxFlag);
- }
-
- if( clipCode2 & (aMinFlag|aMaxFlag) )
- o_n = (clipCode2 & aMinFlag) ? o_as - aMin : aMax - o_as;
- else
- {
- o_n = (clipCode2 & bMinFlag) ? o_bs - bMin : bMax - o_bs;
- o_bUseAlternateBresenham = true;
- }
- }
- else
- o_n = (a2 >= o_as) ? a2 - o_as : o_as - a2;
-
- return true; // at least one pixel to render
-}
-
-
-/** Render line to image iterators, clip against given rectangle
-
- This method renders a line from aPt1 to aPt2, clipped against
- rClipRect (the clipping will take place pixel-perfect, i.e. as if
- the original bresenham-rendered line would have been clipped each
- pixel individually. No slight shifts compared to unclipped lines).
-
- @param aPt1
- Start point of the line
-
- @param aPt2
- End point of the line
-
- @param rClipRect
- Rectangle to clip against
-
- @param color
- Color value to render the line with
-
- @param begin
- left-top image iterator
-
- @param end
- right-bottom image iterator
-
- @param acc
- Image accessor
-
- @param bRoundTowardsPt2
- Rounding mode to use. Giving false here results in line pixel tend
- towards pt1, i.e. when a pixel exactly hits the middle between two
- pixel, the pixel closer to pt1 will be chosen. Giving true here
- makes renderClippedLine() choose pt2 in those cases.
- */
-template< class Iterator, class Accessor >
-void renderClippedLine( basegfx::B2IPoint aPt1,
- basegfx::B2IPoint aPt2,
- const basegfx::B2IBox& rClipRect,
- typename Accessor::value_type color,
- Iterator begin,
- Accessor acc,
- bool bRoundTowardsPt2=false )
-{
- // Algorithm according to Steven Eker's 'Pixel-perfect line clipping',
- // Graphics Gems V, pp. 314-322
- sal_uInt32 clipCode1 = basegfx::tools::getCohenSutherlandClipFlags(aPt1,
- rClipRect);
- sal_uInt32 clipCode2 = basegfx::tools::getCohenSutherlandClipFlags(aPt2,
- rClipRect);
-
- if( clipCode1 & clipCode2 )
- return; // line fully clipped away, both endpoints share a half-plane
-
- sal_uInt32 clipCount1 = basegfx::tools::getNumberOfClipPlanes(clipCode1);
- sal_uInt32 clipCount2 = basegfx::tools::getNumberOfClipPlanes(clipCode2);
-
- if( (clipCode1 != 0 && clipCode2 == 0)
- || (clipCount1 == 2 && clipCount2 == 1) )
- {
- std::swap(clipCount2,clipCount1);
- std::swap(clipCode2,clipCode1);
- std::swap(aPt1,aPt2);
- bRoundTowardsPt2 = !bRoundTowardsPt2;
- }
-
- const sal_Int32 x1 = aPt1.getX();
- const sal_Int32 x2 = aPt2.getX();
- const sal_Int32 y1 = aPt1.getY();
- const sal_Int32 y2 = aPt2.getY();
-
- // TODO(E1): This might overflow
- sal_Int32 adx = x2 - x1;
- int sx = 1;
- if( adx < 0 )
- {
- adx *= -1;
- sx = -1;
- }
-
- // TODO(E1): This might overflow
- sal_Int32 ady = y2 - y1;
- int sy = 1;
- if( ady < 0 )
- {
- ady *= -1;
- sy = -1;
- }
-
- int n = 0;
- 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
- sal_Int32 rem = 2*ady - adx - int(!bRoundTowardsPt2);
-
- if( !prepareClip(x1, x2, y1, adx, ady, xs, ys, sx, sy,
- rem, n, clipCode1, clipCount1, clipCode2, clipCount2,
- 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
-
- Iterator currIter( begin + vigra::Diff2D(0,ys) );
- typename vigra::IteratorTraits<Iterator>::row_iterator
- rowIter( currIter.rowIterator() + xs );
-
- adx *= 2;
- ady *= 2;
-
- if( bUseAlternateBresenham )
- {
- if (rem < 0 && ady <= 0)
- return; //break will never be hit under these circumstances
-
- while(true)
- {
- if (xs >= nMinX && xs <= nMaxX && ys >= nMinY && ys <= nMaxY)
- acc.set(color, rowIter);
-
- if( rem >= 0 )
- {
- // this is intended - we clip endpoint against y
- // plane, so n here denotes y range to render
- if( --n < 0 )
- break;
-
- ys += sy;
- xs += sx;
- rem -= adx;
-
- currIter.y += sy;
- rowIter = currIter.rowIterator() + xs;
- }
- else
- {
- xs += sx;
- rowIter += sx;
- }
-
- rem += ady;
- }
- }
- else
- {
- while(true)
- {
- if (xs >= nMinX && xs <= nMaxX && ys >= nMinY && ys <= nMaxY)
- acc.set(color, rowIter);
-
- if( --n < 0 )
- break;
-
- if( rem >= 0 )
- {
- ys += sy;
- xs += sx;
- rem -= adx;
-
- currIter.y += sy;
- rowIter = currIter.rowIterator() + xs;
- }
- else
- {
- xs += sx;
- rowIter += sx;
- }
-
- rem += ady;
- }
- }
- }
- else
- {
- // semi-vertical line
- sal_Int32 rem = 2*adx - ady - int(!bRoundTowardsPt2);
-
- if( !prepareClip(y1, y2, x1, ady, adx, ys, xs, sy, sx,
- rem, n, clipCode1, clipCount1, clipCode2, clipCount2,
- 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
-
- Iterator currIter( begin + vigra::Diff2D(xs,0) );
- typename vigra::IteratorTraits<Iterator>::column_iterator
- colIter( currIter.columnIterator() + ys );
-
- adx *= 2;
- ady *= 2;
-
- if( bUseAlternateBresenham )
- {
- if (rem < 0 && adx <= 0)
- return; //break will never be hit under these circumstances
-
- while(true)
- {
- if (xs >= nMinX && xs <= nMaxX && ys >= nMinY && ys <= nMaxY)
- acc.set(color, colIter);
-
- if( rem >= 0 )
- {
- // this is intended - we clip endpoint against x
- // plane, so n here denotes x range to render
- if( --n < 0 )
- break;
-
- xs += sx;
- ys += sy;
-
- rem -= ady;
-
- currIter.x += sx;
- colIter = currIter.columnIterator() + ys;
- }
- else
- {
- ys += sy;
- colIter += sy;
- }
-
- rem += adx;
- }
- }
- else
- {
- while(true)
- {
- if (xs >= nMinX && xs <= nMaxX && ys >= nMinY && ys <= nMaxY)
- acc.set(color, colIter);
-
- if( --n < 0 )
- break;
-
- if( rem >= 0 )
- {
- xs += sx;
- ys += sy;
- rem -= ady;
-
- currIter.x += sx;
- colIter = currIter.columnIterator() + ys;
- }
- else
- {
- ys += sy;
- colIter += sy;
- }
-
- rem += adx;
- }
- }
- }
-}
-
-} // namespace basebmp
-
-#endif /* INCLUDED_BASEBMP_INC_CLIPPEDLINERENDERER_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basebmp/inc/polypolygonrenderer.hxx b/basebmp/inc/polypolygonrenderer.hxx
deleted file mode 100644
index fef2f7f..0000000
--- a/basebmp/inc/polypolygonrenderer.hxx
+++ /dev/null
@@ -1,355 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_BASEBMP_INC_POLYPOLYGONRENDERER_HXX
-#define INCLUDED_BASEBMP_INC_POLYPOLYGONRENDERER_HXX
-
-#include <basegfx/point/b2dpoint.hxx>
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/range/b2ibox.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <basegfx/polygon/b2dpolypolygonfillrule.hxx>
-#include <basegfx/numeric/ftools.hxx>
-
-#include <vigra/diff2d.hxx>
-#include <vigra/iteratortraits.hxx>
-
-#include <vector>
-
-
-namespace basebmp
-{
- namespace detail
- {
- /// convert int32 to 32:32 fixed point
- inline sal_Int64 toFractional( sal_Int32 v ) { return sal_Int64(sal_uInt64(v) << 32); }
- /// convert double to 32:32 fixed point
- inline sal_Int64 toFractional( double v ) { return (sal_Int64)(v*SAL_MAX_UINT32 + (v < 0.0 ? -0.5 : 0.5 )); }
- /// convert 32:32 fixed point to int32 (truncate)
- inline sal_Int32 toInteger( sal_Int64 v ) { return (sal_Int32)(v < 0 ? ~((~v) >> 32) : v >> 32); }
- /// convert 32:32 fixed point to int32 (properly rounded)
- inline sal_Int32 toRoundedInteger( sal_Int64 v ) { return toInteger(v) + (sal_Int32)((v&0x80000000) >> 31); }
-
- /** internal vertex store -
-
- Different from B2DPoint, since we don't need floating
- point coords, but orientation of vertex and y counter
- */
- struct Vertex
- {
- sal_Int32 mnYCounter;
- sal_Int64 mnX;
- sal_Int64 mnXDelta;
-
- bool mbDownwards; // needed for nonzero winding rule
- // fills
-
- Vertex() :
- mnYCounter(0),
- mnX(0),
- mnXDelta(0),
- mbDownwards(true)
- {}
- Vertex( basegfx::B2DPoint const& rPt1,
- basegfx::B2DPoint const& rPt2,
- bool bDownwards ) :
- mnYCounter( basegfx::fround(rPt2.getY()) -
- basegfx::fround(rPt1.getY()) ),
- mnX( toFractional( basegfx::fround(rPt1.getX()) )),
- mnXDelta( toFractional(
- ((rPt2.getX() - rPt1.getX()) /
- (double)mnYCounter) )),
- mbDownwards(bDownwards)
- {}
- };
-
- typedef std::vector< std::vector<Vertex> > VectorOfVectorOfVertices;
- typedef std::vector< Vertex* > VectorOfVertexPtr;
-
- /// non-templated setup of GET
- sal_uInt32 setupGlobalEdgeTable( VectorOfVectorOfVertices& rGET,
- basegfx::B2DPolyPolygon const& rPoly,
- sal_Int32 nMinY );
- /// sort rAETSrc, copy not-yet-ended edges over to rAETDest
- void sortAET( VectorOfVertexPtr& rAETSrc,
- VectorOfVertexPtr& rAETDest );
-
- /// For the STL algorithms
- struct RasterConvertVertexComparator
- {
- RasterConvertVertexComparator() {}
-
- bool operator()( const Vertex& rLHS,
- const Vertex& rRHS ) const
- {
- return rLHS.mnX < rRHS.mnX;
- }
-
- bool operator()( const Vertex* pLHS,
- const Vertex* pRHS ) const
- {
- return pLHS->mnX < pRHS->mnX;
- }
- };
-
- } // namespace detail
-
-
- /** Raster-convert a poly-polygon.
-
- This algorithm does not perform antialiasing, and thus
- internally works with integer vertex coordinates.
-
- @param begin
- Left, top edge of the destination bitmap. This position is
- considered (0,0) relative to all polygon vertices
-
- @param ad
- Accessor to set pixel values
-
- @param fillColor
- Color to use for filling
-
- @param rClipRect
- Clipping rectangle, relative to the begin iterator. No pixel outside
- this clip rect will be modified.
-
- @param rPoly
- Polygon to fill
- */
- template< class DestIterator, class DestAccessor, typename T >
- void renderClippedPolyPolygon( DestIterator begin,
- DestAccessor ad,
- T fillColor,
- const basegfx::B2IBox& rClipRect,
- basegfx::B2DPolyPolygon const& rPoly,
- basegfx::FillRule eFillRule )
- {
- const sal_Int32 nClipX1( std::max((sal_Int32)0,rClipRect.getMinX()) );
- const sal_Int32 nClipX2( rClipRect.getMaxX() );
- const sal_Int32 nClipY1( std::max((sal_Int32)0,rClipRect.getMinY()) );
- const sal_Int32 nClipY2( rClipRect.getMaxY() );
- const sal_Int64 nClipX1_frac( detail::toFractional(nClipX1) );
- const sal_Int64 nClipX2_frac( detail::toFractional(nClipX2) );
-
- basegfx::B2DRange const aPolyBounds( basegfx::tools::getRange(rPoly) );
-
- const sal_Int32 nMinY( basegfx::fround(aPolyBounds.getMinY()) );
- const sal_Int32 nMaxY(
- std::min(
- nClipY2-1,
- basegfx::fround(aPolyBounds.getMaxY())));
-
- if( nMinY > nMaxY )
- return; // really, nothing to do then.
-
- detail::VectorOfVectorOfVertices aGET; // the Global Edge Table
- aGET.resize( nMaxY - nMinY + 1 );
-
- sal_uInt32 const nVertexCount(
- detail::setupGlobalEdgeTable( aGET, rPoly, nMinY ) );
-
-
- // Perform actual scan conversion
-
-
- if( aGET.empty() )
- return;
-
- detail::VectorOfVertexPtr aAET1; // the Active Edge Table
- detail::VectorOfVertexPtr aAET2;
- detail::VectorOfVertexPtr* pAET = &aAET1;
- detail::VectorOfVertexPtr* pAETOther = &aAET2;
- aAET1.reserve( nVertexCount );
- aAET2.reserve( nVertexCount );
-
- // current scanline - initially, points to first scanline
- // within the clip rect, or to the polygon's first scanline
- // (whichever is greater)
- DestIterator aScanline( begin +
- vigra::Diff2D(
- 0,
- std::max(nMinY,
- nClipY1)) );
- detail::RasterConvertVertexComparator aComp;
-
-
- // now process each of the nMaxY - nMinY + 1 scanlines
-
-
- for( sal_Int32 y=nMinY; y <= nMaxY; ++y )
- {
- if( !aGET[y-nMinY].empty() )
- {
- // merge AET with current scanline's new vertices (both
- // are already correctly sorted)
- detail::VectorOfVectorOfVertices::value_type::iterator vertex=aGET[y-nMinY].begin();
- detail::VectorOfVectorOfVertices::value_type::iterator const end=aGET[y-nMinY].end();
- while( vertex != end )
- {
- // find insertion pos by binary search, and put ptr
- // into active edge vector
- pAET->insert( std::lower_bound( pAET->begin(),
- pAET->end(),
- &(*vertex),
- aComp ),
- &(*vertex) );
-
- ++vertex;
- }
- }
-
- // with less than two active edges, no fill visible
- if( pAET->size() >= 2 )
- {
- typename vigra::IteratorTraits<DestIterator>::row_iterator
- rowIter( aScanline.rowIterator() );
-
- // process each span in current scanline, with
- // even-odd fill rule
- detail::VectorOfVertexPtr::iterator currVertex( pAET->begin() );
- detail::VectorOfVertexPtr::iterator const lastVertex( pAET->end()-1 );
- sal_uInt32 nCrossedEdges(0);
- while( currVertex != lastVertex )
- {
- // TODO(P1): might be worth a try to extend the
- // size()==2 case also to the actual filling
- // here. YMMV.
- detail::Vertex& rV1( **currVertex );
- detail::Vertex const& rV2( **++currVertex );
-
- // calc fill status for both rules. might save a
- // few percent runtime to specialize here...
- const bool bEvenOddFill(
- eFillRule == basegfx::FillRule::EvenOdd && !(nCrossedEdges & 0x01) );
-
- // is span visible?
- if( bEvenOddFill &&
- y >= nClipY1 &&
- rV1.mnX < nClipX2_frac &&
- rV2.mnX > nClipX1_frac )
- {
- // clip span to horizontal bounds
- sal_Int32 const nStartX(
- std::max( nClipX1,
- std::min( nClipX2-1,
- detail::toRoundedInteger(rV1.mnX) )));
- sal_Int32 const nEndX(
- std::max( nClipX1,
- std::min( nClipX2,
- detail::toRoundedInteger(rV2.mnX) )));
-
- typename vigra::IteratorTraits<DestIterator>::row_iterator
- currPix( rowIter + nStartX);
- typename vigra::IteratorTraits<DestIterator>::row_iterator
- rowEnd( rowIter + nEndX );
-
- // TODO(P2): Provide specialized span fill methods on the
- // iterator/accessor
- while( currPix != rowEnd )
- ad.set(fillColor, currPix++);
- }
-
- // step vertices
- rV1.mnX += rV1.mnXDelta;
- --rV1.mnYCounter;
-
- ++nCrossedEdges;
- }
-
- // step vertex also for the last one
- detail::Vertex& rLastV( **currVertex );
- rLastV.mnX += rLastV.mnXDelta;
- --rLastV.mnYCounter;
-
-
- // prune AET from ended edges, and keep it sorted
-
-
- pAETOther->clear();
- if( pAET->size() == 2 )
- {
- // the case of exactly two active edges is both
- // sufficiently common (all 'simple' polygons have
- // it), and further more would complicate the
- // generic case below (which works with a sliding
- // triple of vertices).
- if( !aComp(*(*pAET)[0], *(*pAET)[1]) )
- std::swap(*(*pAET)[0], *(*pAET)[1]);
-
- if( (*pAET)[0]->mnYCounter > 0 )
- pAETOther->push_back( (*pAET)[0] );
- if( (*pAET)[1]->mnYCounter > 0 )
- pAETOther->push_back( (*pAET)[1] );
- }
- else
- {
- bool bFallbackTaken(false);
- currVertex = pAET->begin();
- detail::VectorOfVertexPtr::iterator prevVertex( currVertex );
- while( currVertex != lastVertex )
- {
- // try to get away with one linear swoop and
- // simple neighbor swapping. this is an
- // overwhelmingly common case - polygons with
- // excessively crisscrossing edges (which on
- // top of that cross more than one other edge
- // per scanline) are seldom. And even if we
- // get such a beast here, this extra loop has
- // still only linear cost
- if( aComp(**(currVertex+1),**currVertex) )
- {
- std::swap(*currVertex, *(currVertex+1));
-
- if( aComp(**currVertex,**prevVertex) )
- {
- // one swap was not sufficient -
- // fallback to generic sort algo, then
- detail::sortAET(*pAET, *pAETOther);
- bFallbackTaken = true;
- break;
- }
- }
-
- if( (*currVertex)->mnYCounter > 0 )
- pAETOther->push_back( *currVertex );
-
- prevVertex = currVertex++;
- }
-
- // don't forget to add last vertex (loop above
- // only deals with n-1 vertices)
- if( !bFallbackTaken && (*currVertex)->mnYCounter > 0 )
- pAETOther->push_back( *currVertex );
- }
-
- std::swap( pAET, pAETOther );
- }
-
- if( y >= nClipY1 )
- ++aScanline.y;
- }
- }
-
-} // namespace basebmp
-
-#endif /* INCLUDED_BASEBMP_INC_POLYPOLYGONRENDERER_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index ed5937d..3ab2652 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -44,8 +44,6 @@
#include <basebmp/scanlineformats.hxx>
#include <fillimage.hxx>
#include <scaleimage.hxx>
-#include <clippedlinerenderer.hxx>
-#include <polypolygonrenderer.hxx>
#include <genericcolorimageaccessor.hxx>
#include <tools.hxx>
@@ -198,15 +196,6 @@ namespace
typename raw_accessor_type::value_type>::to to_uint32_functor;
-
- typedef typename raw_accessor_traits::xor_accessor raw_xor_accessor_type;
- typedef AccessorTraits<raw_xor_accessor_type> raw_xor_accessor_traits;
- typedef typename accessor_selector::template wrap_accessor<
- raw_xor_accessor_type >::type xor_accessor_type;
- typedef AccessorTraits<xor_accessor_type> xor_accessor_traits;
-
-
-
typedef typename raw_accessor_traits::template masked_accessor<
mask_rawaccessor_type,
dest_iterator_type,
@@ -214,52 +203,6 @@ namespace
Masks::clipmask_polarity>::type raw_maskedaccessor_type;
typedef typename accessor_selector::template wrap_accessor<
raw_maskedaccessor_type >::type masked_accessor_type;
- typedef typename AccessorTraits<
- raw_maskedaccessor_type>::xor_accessor raw_maskedxor_accessor_type;
- typedef typename accessor_selector::template wrap_accessor<
- raw_maskedxor_accessor_type >::type masked_xoraccessor_type;
-
-
-
- // ((iter,mask),mask) special case (e.g. for clipped
- // drawMaskedColor())
- typedef AccessorTraits< raw_maskedaccessor_type > raw_maskedaccessor_traits;
- typedef typename raw_maskedaccessor_traits::template masked_accessor<
- mask_rawaccessor_type,
- composite_iterator_type,
- mask_iterator_type,
- Masks::clipmask_polarity>::type raw_maskedmask_accessor_type;
-
- typedef CompositeIterator2D<
- composite_iterator_type,
- mask_iterator_type> composite_composite_mask_iterator_type;
-
-
-
- typedef ConstantColorBlendSetterAccessorAdapter<
- dest_accessor_type,
- typename alphamask_rawaccessor_type::value_type,
- Masks::alphamask_polarity> colorblend_accessor_type;
- typedef AccessorTraits<colorblend_accessor_type> colorblend_accessor_traits;
- typedef typename colorblend_accessor_traits::template masked_accessor<
- mask_rawaccessor_type,
- dest_iterator_type,
- mask_iterator_type,
- Masks::clipmask_polarity>::type masked_colorblend_accessor_type;
-
-
-
- typedef ConstantColorBlendSetterAccessorAdapter<
- dest_accessor_type,
- Color,
- Masks::alphamask_polarity> colorblend_generic_accessor_type;
- typedef AccessorTraits<colorblend_generic_accessor_type> colorblend_generic_accessor_traits;
- typedef typename colorblend_generic_accessor_traits::template masked_accessor<
- mask_rawaccessor_type,
- dest_iterator_type,
- mask_iterator_type,
- Masks::clipmask_polarity>::type masked_colorblend_generic_accessor_type;
-
typedef JoinImageAccessorAdapter< dest_accessor_type,
@@ -273,14 +216,9 @@ namespace
typename accessor_traits::color_lookup maColorLookup;
to_uint32_functor maToUInt32Converter;
dest_accessor_type maAccessor;
- colorblend_accessor_type maColorBlendAccessor;
- colorblend_generic_accessor_type maGenericColorBlendAccessor;
raw_accessor_type maRawAccessor;
masked_accessor_type maMaskedAccessor;
- masked_colorblend_accessor_type maMaskedColorBlendAccessor;
- masked_colorblend_generic_accessor_type maGenericMaskedColorBlendAccessor;
raw_maskedaccessor_type maRawMaskedAccessor;
- raw_maskedmask_accessor_type maRawMaskedMaskAccessor;
@@ -301,14 +239,9 @@ namespace
maColorLookup(),
maToUInt32Converter(),
maAccessor( accessor ),
- maColorBlendAccessor( accessor ),
- maGenericColorBlendAccessor( accessor ),
maRawAccessor( rawAccessor ),
maMaskedAccessor( accessor ),
- maMaskedColorBlendAccessor( maColorBlendAccessor ),
- maGenericMaskedColorBlendAccessor( maGenericColorBlendAccessor ),
- maRawMaskedAccessor( rawAccessor ),
- maRawMaskedMaskAccessor( rawAccessor )
+ maRawMaskedAccessor( rawAccessor )
{}
private:
@@ -404,44 +337,6 @@ namespace
return maToUInt32Converter(maRawAccessor(pixel));
}
- template< typename Iterator, typename Accessor, typename RawAcc >
- void implRenderLine( const basegfx::B2IPoint& rPt1,
- const basegfx::B2IPoint& rPt2,
- const basegfx::B2IBox& rBounds,
- Color col,
- const Iterator& begin,
- const Accessor& acc,
- const RawAcc& rawAcc )
- {
- renderClippedLine( rPt1,rPt2,rBounds,
- maColorLookup( acc,
- col ),
- begin,
- rawAcc );
- }
-
- template< typename Iterator, typename RawAcc >
- void implDrawLine( const basegfx::B2IPoint& rPt1,
- const basegfx::B2IPoint& rPt2,
- const basegfx::B2IBox& rBounds,
- Color col,
- const Iterator& begin,
- const RawAcc& rawAcc )
- {
- implRenderLine( rPt1, rPt2, rBounds, col,
- begin, maAccessor, rawAcc );
- }
-
- virtual void drawLine_i(const basegfx::B2IPoint& rPt1,
- const basegfx::B2IPoint& rPt2,
- const basegfx::B2IBox& rBounds,
- Color lineColor ) override
- {
- implDrawLine(rPt1,rPt2,rBounds,lineColor,
- maBegin,
- maRawAccessor);
- }
-
composite_iterator_type getMaskedIter( const BitmapDeviceSharedPtr& rClip ) const
{
std::shared_ptr<mask_bitmap_type> pMask( getCompatibleClipMask(rClip) );
@@ -451,109 +346,6 @@ namespace
pMask->maBegin );
}
- virtual void drawLine_i(const basegfx::B2IPoint& rPt1,
- const basegfx::B2IPoint& rPt2,
- const basegfx::B2IBox& rBounds,
- Color lineColor,
- const BitmapDeviceSharedPtr& rClip ) override
- {
- implDrawLine(rPt1,rPt2,rBounds,lineColor,
- getMaskedIter(rClip),
- maRawMaskedAccessor);
- }
-
- template< typename Iterator, typename RawAcc >
- void implDrawPolygon( const basegfx::B2DPolygon& rPoly,
- const basegfx::B2IBox& rBounds,
- Color col,
- const Iterator& begin,
- const RawAcc& acc )
- {
- basegfx::B2DPolygon aPoly( rPoly );
- if( rPoly.areControlPointsUsed() )
- aPoly = basegfx::tools::adaptiveSubdivideByCount( rPoly );
-
- const typename dest_iterator_type::value_type colorIndex( maColorLookup(
- maAccessor,
- col));
- const sal_uInt32 nVertices( aPoly.count() );
- for( sal_uInt32 i=1; i<nVertices; ++i )
- renderClippedLine( basegfx::fround(aPoly.getB2DPoint(i-1)),
- basegfx::fround(aPoly.getB2DPoint(i)),
- rBounds,
- colorIndex,
- begin,
- acc );
-
- if( nVertices > 1 && aPoly.isClosed() )
- renderClippedLine( basegfx::fround(aPoly.getB2DPoint(nVertices-1)),
- basegfx::fround(aPoly.getB2DPoint(0)),
- rBounds,
- colorIndex,
- begin,
- acc );
- }
-
- virtual void drawPolygon_i(const basegfx::B2DPolygon& rPoly,
- const basegfx::B2IBox& rBounds,
- Color lineColor ) override
- {
- implDrawPolygon( rPoly, rBounds, lineColor,
- maBegin,
- maRawAccessor );
- }
-
- virtual void drawPolygon_i(const basegfx::B2DPolygon& rPoly,
- const basegfx::B2IBox& rBounds,
- Color lineColor,
- const BitmapDeviceSharedPtr& rClip ) override
- {
- implDrawPolygon( rPoly, rBounds, lineColor,
- getMaskedIter(rClip),
- maRawMaskedAccessor );
- }
-
- template< typename Iterator, typename RawAcc >
- void implFillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
- Color col,
- const Iterator& begin,
- const RawAcc& acc,
- const basegfx::B2IBox& rBounds )
- {
- basegfx::B2DPolyPolygon aPoly( rPoly );
- if( rPoly.areControlPointsUsed() )
- aPoly = basegfx::tools::adaptiveSubdivideByCount( rPoly );
-
- renderClippedPolyPolygon( begin,
- acc,
- maColorLookup( maAccessor,
- col),
- rBounds,
- aPoly,
- basegfx::FillRule::EvenOdd );
- }
-
- virtual void fillPolyPolygon_i(const basegfx::B2DPolyPolygon& rPoly,
- Color fillColor,
- const basegfx::B2IBox& rBounds ) override
- {
- implFillPolyPolygon( rPoly, fillColor,
- maBegin,
- maRawAccessor,
- rBounds );
- }
-
- virtual void fillPolyPolygon_i(const basegfx::B2DPolyPolygon& rPoly,
- Color fillColor,
- const basegfx::B2IBox& rBounds,
- const BitmapDeviceSharedPtr& rClip ) override
- {
- implFillPolyPolygon( rPoly, fillColor,
- getMaskedIter(rClip),
- maRawMaskedAccessor,
- rBounds );
- }
-
template< typename Iterator, typename RawAcc >
void implDrawBitmap(const BitmapDeviceSharedPtr& rSrcBitmap,
const basegfx::B2IBox& rSrcRect,
@@ -685,116 +477,6 @@ namespace
}
}
- virtual void drawMaskedColor_i(Color aSrcColor,
- const BitmapDeviceSharedPtr& rAlphaMask,
- const basegfx::B2IBox& rSrcRect,
- const basegfx::B2IPoint& rDstPoint ) override
- {
- std::shared_ptr<mask_bitmap_type> pMask( getCompatibleClipMask(rAlphaMask) );
- std::shared_ptr<alphamask_bitmap_type> pAlpha( getCompatibleAlphaMask(rAlphaMask) );
-
- if( pAlpha )
- {
- maColorBlendAccessor.setColor( aSrcColor );
-
- vigra::copyImage( srcIterRange(pAlpha->maBegin,
- pAlpha->maRawAccessor,
- rSrcRect),
- destIter(maBegin,
- maColorBlendAccessor,
- rDstPoint) );
- }
- else if( pMask )
- {
- const composite_iterator_type aBegin(
- maBegin + vigra::Diff2D(rDstPoint.getX(),
- rDstPoint.getY()),
- pMask->maBegin + topLeft(rSrcRect) );
-
- fillImage(aBegin,
- aBegin + vigra::Diff2D(rSrcRect.getWidth(),
- rSrcRect.getHeight()),
- maRawMaskedAccessor,
- maColorLookup(
- maAccessor,
- aSrcColor) );
- }
- else
- {
- GenericColorImageAccessor aSrcAcc( rAlphaMask );
- maGenericColorBlendAccessor.setColor( aSrcColor );
-
- vigra::copyImage( srcIterRange(vigra::Diff2D(),
- aSrcAcc,
- rSrcRect),
- destIter(maBegin,
- maGenericColorBlendAccessor,
- rDstPoint) );
- }
- }
-
- virtual void drawMaskedColor_i(Color aSrcColor,
- const BitmapDeviceSharedPtr& rAlphaMask,
- const basegfx::B2IBox& rSrcRect,
- const basegfx::B2IPoint& rDstPoint,
- const BitmapDeviceSharedPtr& rClip ) override
- {
- std::shared_ptr<mask_bitmap_type> pMask( getCompatibleClipMask(rAlphaMask) );
- std::shared_ptr<alphamask_bitmap_type> pAlpha( getCompatibleAlphaMask(rAlphaMask) );
-
- if( pAlpha )
- {
- const composite_iterator_type aBegin( getMaskedIter(rClip) );
- maMaskedColorBlendAccessor.get1stWrappedAccessor().setColor(
- aSrcColor );
-
- vigra::copyImage( srcIterRange(pAlpha->maBegin,
- pAlpha->maRawAccessor,
- rSrcRect),
- destIter(aBegin,
- maMaskedColorBlendAccessor,
- rDstPoint) );
- }
- else if( pMask )
- {
- std::shared_ptr<mask_bitmap_type> pClipMask( getCompatibleClipMask(rClip) );
- OSL_ASSERT( pClipMask );
-
- // setup a ((iter,mask),clipMask) composite composite
- // iterator, to pass both masks (clip and alpha mask)
- // to the algorithm
- const composite_composite_mask_iterator_type aBegin(
- composite_iterator_type(
- maBegin + vigra::Diff2D(rDstPoint.getX(),
- rDstPoint.getY()),
- pMask->maBegin + topLeft(rSrcRect)),
- pClipMask->maBegin + vigra::Diff2D(rDstPoint.getX(),
- rDstPoint.getY()) );
-
- fillImage(aBegin,
- aBegin + vigra::Diff2D(rSrcRect.getWidth(),
- rSrcRect.getHeight()),
- maRawMaskedMaskAccessor,
- maColorLookup(
- maAccessor,
- aSrcColor) );
- }
- else
- {
- GenericColorImageAccessor aSrcAcc( rAlphaMask );
- const composite_iterator_type aBegin( getMaskedIter(rClip) );
- maGenericMaskedColorBlendAccessor.get1stWrappedAccessor().setColor(
- aSrcColor );
-
- vigra::copyImage( srcIterRange(vigra::Diff2D(),
- aSrcAcc,
- rSrcRect),
- destIter(aBegin,
- maGenericMaskedColorBlendAccessor,
- rDstPoint) );
- }
- }
-
template< typename Iterator, typename Acc >
void implDrawMaskedBitmap(const BitmapDeviceSharedPtr& rSrcBitmap,
const BitmapDeviceSharedPtr& rMask,
@@ -858,50 +540,6 @@ namespace
rDstRect));
}
- virtual void drawMaskedBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap,
- const BitmapDeviceSharedPtr& rMask,
- const basegfx::B2IBox& rSrcRect,
- const basegfx::B2IBox& rDstRect ) override
- {
- if( isCompatibleClipMask(rMask) &&
- isCompatibleBitmap(rSrcBitmap) )
- {
- implDrawMaskedBitmap(rSrcBitmap, rMask,
- rSrcRect, rDstRect,
- maBegin,
- maAccessor);
- }
- else
- {
- implDrawMaskedBitmapGeneric(rSrcBitmap, rMask,
- rSrcRect, rDstRect,
- maBegin,
- maAccessor);
- }
- }
-
- virtual void drawMaskedBitmap_i(const BitmapDeviceSharedPtr& rSrcBitmap,
- const BitmapDeviceSharedPtr& rMask,
- const basegfx::B2IBox& rSrcRect,
- const basegfx::B2IBox& rDstRect,
- const BitmapDeviceSharedPtr& rClip ) override
- {
- if( isCompatibleClipMask(rMask) &&
- isCompatibleBitmap(rSrcBitmap) )
- {
- implDrawMaskedBitmap(rSrcBitmap, rMask,
- rSrcRect, rDstRect,
- getMaskedIter(rClip),
- maMaskedAccessor);
- }
- else
- {
- implDrawMaskedBitmapGeneric(rSrcBitmap, rMask,
- rSrcRect, rDstRect,
- getMaskedIter(rClip),
- maMaskedAccessor);
- }
- }
};
} // namespace
@@ -1069,104 +707,8 @@ sal_uInt32 BitmapDevice::getPixelData( const basegfx::B2IPoint& rPt )
return 0;
}
-void BitmapDevice::drawLine( const basegfx::B2IPoint& rPt1,
- const basegfx::B2IPoint& rPt2,
- Color lineColor )
-{
- drawLine_i( rPt1,
- rPt2,
- mpImpl->maBounds,
- lineColor );
-}
-
-void BitmapDevice::drawLine( const basegfx::B2IPoint& rPt1,
- const basegfx::B2IPoint& rPt2,
- Color lineColor,
- const BitmapDeviceSharedPtr& rClip )
-{
- if( !rClip )
- {
- drawLine(rPt1,rPt2,lineColor);
- return;
- }
-
- if( isCompatibleClipMask( rClip ) )
- drawLine_i( rPt1,
- rPt2,
- mpImpl->maBounds,
- lineColor,
- rClip );
- else
- getGenericRenderer()->drawLine( rPt1, rPt2, lineColor,
- rClip );
-}
-
-void BitmapDevice::drawPolygon( const basegfx::B2DPolygon& rPoly,
- Color lineColor )
-{
- const sal_uInt32 numVertices( rPoly.count() );
- if( numVertices )
- drawPolygon_i( rPoly,
- mpImpl->maBounds,
- lineColor );
-}
-
-void BitmapDevice::drawPolygon( const basegfx::B2DPolygon& rPoly,
- Color lineColor,
- const BitmapDeviceSharedPtr& rClip )
-{
- if( !rClip )
- {
- drawPolygon(rPoly,lineColor);
- return;
- }
-
- const sal_uInt32 numVertices( rPoly.count() );
- if( numVertices )
- {
- if( isCompatibleClipMask( rClip ) )
- drawPolygon_i( rPoly,
- mpImpl->maBounds,
- lineColor, rClip );
- else
- getGenericRenderer()->drawPolygon( rPoly, lineColor,
- rClip );
- }
-}
-
-void BitmapDevice::fillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
- Color fillColor )
-{
- fillPolyPolygon_i( rPoly, fillColor, mpImpl->maBounds );
-}
-
-void BitmapDevice::fillPolyPolygon( const basegfx::B2DPolyPolygon& rPoly,
- Color fillColor,
- const BitmapDeviceSharedPtr& rClip )
-{
- if( !rClip )
- {
- fillPolyPolygon(rPoly,fillColor);
- return;
- }
-
- if( isCompatibleClipMask( rClip ) )
- fillPolyPolygon_i( rPoly, fillColor, mpImpl->maBounds, rClip );
- else
- getGenericRenderer()->fillPolyPolygon( rPoly, fillColor,
- rClip );
-}
-
-
namespace
{
- void assertImagePoint( const basegfx::B2IPoint& rPt,
- const basegfx::B2IBox& rPermittedRange )
- {
- (void)rPt; (void)rPermittedRange;
- OSL_ASSERT( rPermittedRange.isInside(rPt) );
- }
-
void assertImageRange( const basegfx::B2IBox& rRange,
const basegfx::B2IBox& rPermittedRange )
{
@@ -1182,54 +724,6 @@ namespace
// TODO(Q3): Move canvas/canvastools.hxx clipBlit() down
// to basegfx, and use here!
- bool clipAreaImpl( ::basegfx::B2IBox& io_rSourceArea,
- ::basegfx::B2IPoint& io_rDestPoint,
- const ::basegfx::B2IBox& rSourceBounds,
- const ::basegfx::B2IBox& rDestBounds )
- {
- const ::basegfx::B2IPoint aSourceTopLeft(
- io_rSourceArea.getMinimum() );
-
- ::basegfx::B2IBox aLocalSourceArea( io_rSourceArea );
-
- // clip source area (which must be inside rSourceBounds)
- aLocalSourceArea.intersect( rSourceBounds );
-
- if( aLocalSourceArea.isEmpty() )
- return false;
-
- // calc relative new source area points (relative to orig
- // source area)
- const ::basegfx::B2IVector aUpperLeftOffset(
- aLocalSourceArea.getMinimum()-aSourceTopLeft );
- const ::basegfx::B2IVector aLowerRightOffset(
- aLocalSourceArea.getMaximum()-aSourceTopLeft );
-
- ::basegfx::B2IBox aLocalDestArea( io_rDestPoint + aUpperLeftOffset,
- io_rDestPoint + aLowerRightOffset );
-
- // clip dest area (which must be inside rDestBounds)
- aLocalDestArea.intersect( rDestBounds );
-
- if( aLocalDestArea.isEmpty() )
- return false;
-
- // calc relative new dest area points (relative to orig
- // source area)
- const ::basegfx::B2IVector aDestUpperLeftOffset(
- aLocalDestArea.getMinimum()-io_rDestPoint );
- const ::basegfx::B2IVector aDestLowerRightOffset(
- aLocalDestArea.getMaximum()-io_rDestPoint );
-
- io_rSourceArea = ::basegfx::B2IBox( aSourceTopLeft + aDestUpperLeftOffset,
- aSourceTopLeft + aDestLowerRightOffset );
- io_rDestPoint = aLocalDestArea.getMinimum();
-
- return true;
- }
-
- // TODO(Q3): Move canvas/canvastools.hxx clipBlit() down
- // to basegfx, and use here!
bool clipAreaImpl( ::basegfx::B2IBox& io_rDestArea,
::basegfx::B2IBox& io_rSourceArea,
const ::basegfx::B2IBox& rDestBounds,
@@ -1360,170 +854,6 @@ void BitmapDevice::drawBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
}
}
-void BitmapDevice::drawMaskedColor( Color aSrcColor,
- const BitmapDeviceSharedPtr& rAlphaMask,
- const basegfx::B2IBox& rSrcRect,
- const basegfx::B2IPoint& rDstPoint )
-{
- const basegfx::B2IVector& rSrcSize( rAlphaMask->getSize() );
- const basegfx::B2IBox aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
- basegfx::B2IBox aSrcRange( rSrcRect );
- basegfx::B2IPoint aDestPoint( rDstPoint );
-
- if( clipAreaImpl( aSrcRange,
- aDestPoint,
- aSrcBounds,
- mpImpl->maBounds ))
- {
- assertImagePoint(aDestPoint,mpImpl->maBounds);
- assertImageRange(aSrcRange,aSrcBounds);
-
- if( isSharedBuffer(rAlphaMask) )
- {
- // src == dest, copy rAlphaMask beforehand
-
-
- const basegfx::B2ITuple aSize( aSrcRange.getWidth(),
- aSrcRange.getHeight() );
- BitmapDeviceSharedPtr pAlphaCopy(
- cloneBitmapDevice( aSize,
- shared_from_this()) );
- const basegfx::B2IBox aAlphaRange( basegfx::B2ITuple(),
- aSize );
- pAlphaCopy->drawBitmap(rAlphaMask,
- aSrcRange,
- aAlphaRange);
- drawMaskedColor_i( aSrcColor, pAlphaCopy, aAlphaRange, aDestPoint );
- }
- else
- {
- drawMaskedColor_i( aSrcColor, rAlphaMask, aSrcRange, aDestPoint );
- }
- }
-}
-
-void BitmapDevice::drawMaskedColor( Color aSrcColor,
- const BitmapDeviceSharedPtr& rAlphaMask,
- const basegfx::B2IBox& rSrcRect,
- const basegfx::B2IPoint& rDstPoint,
- const BitmapDeviceSharedPtr& rClip )
-{
- if( !rClip )
- {
- drawMaskedColor(aSrcColor,rAlphaMask,rSrcRect,rDstPoint);
- return;
- }
-
- const basegfx::B2IVector& rSrcSize( rAlphaMask->getSize() );
- const basegfx::B2IBox aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
- basegfx::B2IBox aSrcRange( rSrcRect );
- basegfx::B2IPoint aDestPoint( rDstPoint );
-
- if( clipAreaImpl( aSrcRange,
- aDestPoint,
- aSrcBounds,
- mpImpl->maBounds ))
- {
- assertImagePoint(aDestPoint,mpImpl->maBounds);
- assertImageRange(aSrcRange,aSrcBounds);
-
- if( isCompatibleClipMask( rClip ) )
- {
- if( isSharedBuffer(rAlphaMask) )
- {
- // src == dest, copy rAlphaMask beforehand
-
-
- const basegfx::B2ITuple aSize( aSrcRange.getWidth(),
- aSrcRange.getHeight() );
- BitmapDeviceSharedPtr pAlphaCopy(
- cloneBitmapDevice( aSize,
- shared_from_this()) );
- const basegfx::B2IBox aAlphaRange( basegfx::B2ITuple(),
- aSize );
- pAlphaCopy->drawBitmap(rAlphaMask,
- aSrcRange,
- aAlphaRange);
- drawMaskedColor_i( aSrcColor, pAlphaCopy, aAlphaRange, aDestPoint, rClip );
- }
- else
- {
- drawMaskedColor_i( aSrcColor, rAlphaMask, aSrcRange, aDestPoint, rClip );
- }
- }
- else
- {
- getGenericRenderer()->drawMaskedColor( aSrcColor, rAlphaMask,
- rSrcRect, rDstPoint, rClip );
- }
- }
-}
-
-void BitmapDevice::drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
- const BitmapDeviceSharedPtr& rMask,
- const basegfx::B2IBox& rSrcRect,
- const basegfx::B2IBox& rDstRect )
-{
- OSL_ASSERT( rMask->getSize() == rSrcBitmap->getSize() );
-
- const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() );
- const basegfx::B2IBox aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
- basegfx::B2IBox aSrcRange( rSrcRect );
- basegfx::B2IBox aDestRange( rDstRect );
-
- if( clipAreaImpl( aDestRange,
- aSrcRange,
- mpImpl->maBounds,
- aSrcBounds ))
- {
- assertImageRange(aDestRange,mpImpl->maBounds);
- assertImageRange(aSrcRange,aSrcBounds);
-
- drawMaskedBitmap_i( rSrcBitmap, rMask, aSrcRange, aDestRange );
- }
-}
-
-void BitmapDevice::drawMaskedBitmap( const BitmapDeviceSharedPtr& rSrcBitmap,
- const BitmapDeviceSharedPtr& rMask,
- const basegfx::B2IBox& rSrcRect,
- const basegfx::B2IBox& rDstRect,
- const BitmapDeviceSharedPtr& rClip )
-{
- if( !rClip )
- {
- drawMaskedBitmap(rSrcBitmap,rMask,rSrcRect,rDstRect);
- return;
- }
-
- OSL_ASSERT( rMask->getSize() == rSrcBitmap->getSize() );
-
- const basegfx::B2IVector& rSrcSize( rSrcBitmap->getSize() );
- const basegfx::B2IBox aSrcBounds( 0,0,rSrcSize.getX(),rSrcSize.getY() );
- basegfx::B2IBox aSrcRange( rSrcRect );
- basegfx::B2IBox aDestRange( rDstRect );
-
- if( clipAreaImpl( aDestRange,
- aSrcRange,
- mpImpl->maBounds,
- aSrcBounds ))
- {
- assertImageRange(aDestRange,mpImpl->maBounds);
- assertImageRange(aSrcRange,aSrcBounds);
-
- if( isCompatibleClipMask( rClip ) )
- {
- drawMaskedBitmap_i( rSrcBitmap, rMask, aSrcRange, aDestRange, rClip );
- }
- else
- {
- getGenericRenderer()->drawMaskedBitmap( rSrcBitmap, rMask, rSrcRect,
- rDstRect, rClip );
- }
- }
-}
-
-
-
/** Standard clip and alpha masks
*/
struct StdMasks
@@ -1910,18 +1240,6 @@ BitmapDeviceSharedPtr createBitmapDevice( const basegfx::B2IVector& rSize
nullptr );
}
-BitmapDeviceSharedPtr subsetBitmapDevice( const BitmapDeviceSharedPtr& rProto,
- const basegfx::B2IBox& rSubset )
-{
- SAL_INFO( "basebmp.bitmapdevice", "subsetBitmapDevice: proto=" << rProto.get() );
- return createBitmapDeviceImpl( rProto->getSize(),
- rProto->isTopDown(),
- rProto->getScanlineFormat(),
- rProto->getBuffer(),
- rProto->getPalette(),
- &rSubset );
-}
-
BitmapDeviceSharedPtr cloneBitmapDevice( const basegfx::B2IVector& rSize,
const BitmapDeviceSharedPtr& rProto )
{
diff --git a/basebmp/source/polypolygonrenderer.cxx b/basebmp/source/polypolygonrenderer.cxx
deleted file mode 100644
index 91cd273..0000000
--- a/basebmp/source/polypolygonrenderer.cxx
+++ /dev/null
@@ -1,121 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <polypolygonrenderer.hxx>
-
-#include <algorithm>
-
-
-namespace basebmp
-{
-namespace detail
-{
- sal_uInt32 setupGlobalEdgeTable( VectorOfVectorOfVertices& rGET,
- basegfx::B2DPolyPolygon const& rPolyPoly,
- sal_Int32 nMinY )
- {
- sal_Int32 const nNumScanlines( (sal_Int32)rGET.size() );
-
- // add all polygons to GET
- for( sal_uInt32 i(0), nCount(rPolyPoly.count());
- i<nCount;
- ++i )
- {
- // add all vertices to GET
- const basegfx::B2DPolygon& rPoly( rPolyPoly.getB2DPolygon(i) );
- for( sal_uInt32 k(0), nVertices(rPoly.count());
- k<nVertices;
- ++k )
- {
- const basegfx::B2DPoint& rP1( rPoly.getB2DPoint(k) );
- const basegfx::B2DPoint& rP2( rPoly.getB2DPoint( (k + 1) % nVertices ) );
-
- const sal_Int32 nVertexYP1( basegfx::fround(rP1.getY()) );
- const sal_Int32 nVertexYP2( basegfx::fround(rP2.getY()) );
-
- // insert only vertices which are not strictly
- // horizontal. Strictly horizontal vertices don't add
- // any information that is not already present - due
- // to their adjacent vertices.
- if(nVertexYP1 != nVertexYP2)
- {
- if( nVertexYP2 < nVertexYP1 )
- {
- const sal_Int32 nStartScanline(nVertexYP2 - nMinY);
-
- // edge direction is upwards - add with swapped vertices
- if( nStartScanline < nNumScanlines )
- rGET[ nStartScanline ].push_back( Vertex(rP2, rP1, false) );
- }
- else
- {
- const sal_Int32 nStartScanline(nVertexYP1 - nMinY);
-
- if( nStartScanline < nNumScanlines )
- rGET[ nStartScanline ].push_back( Vertex(rP1, rP2, true) );
- }
- }
- }
- }
-
- // now sort all scanlines individually, with increasing x
- // coordinates
- VectorOfVectorOfVertices::iterator aIter( rGET.begin() );
- const VectorOfVectorOfVertices::iterator aEnd( rGET.end() );
- sal_uInt32 nVertexCount(0);
- RasterConvertVertexComparator aComp;
- while( aIter != aEnd )
- {
- std::sort( aIter->begin(),
- aIter->end(),
- aComp );
- nVertexCount += aIter->size();
-
- ++aIter;
- }
-
- return nVertexCount;
- }
-
- void sortAET( VectorOfVertexPtr& rAETSrc,
- VectorOfVertexPtr& rAETDest )
- {
- static RasterConvertVertexComparator aComp;
-
- rAETDest.clear();
-
- // prune AET from ended edges
- VectorOfVertexPtr::iterator iter( rAETSrc.begin() );
- VectorOfVertexPtr::iterator const end( rAETSrc.end() );
- while( iter != end )
- {
- if( (*iter)->mnYCounter > 0 )
- rAETDest.push_back( *iter );
- ++iter;
- }
-
- // stable sort is necessary, to avoid segment crossing where
- // none was intended.
- std::stable_sort( rAETDest.begin(), rAETDest.end(), aComp );
- }
-
-} // namespace detail
-} // namespace basebmp
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basebmp/test/bmpmasktest.cxx b/basebmp/test/bmpmasktest.cxx
deleted file mode 100644
index a0a22be..0000000
--- a/basebmp/test/bmpmasktest.cxx
+++ /dev/null
@@ -1,213 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cppunit/TestAssert.h>
-#include <cppunit/TestFixture.h>
-#include <cppunit/extensions/HelperMacros.h>
-
-#include <basegfx/vector/b2isize.hxx>
-#include <basegfx/range/b2ibox.hxx>
-#include <basegfx/point/b2ipoint.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-
-#include <basebmp/color.hxx>
-#include <basebmp/scanlineformats.hxx>
-#include <basebmp/bitmapdevice.hxx>
-#include "tools.hxx"
-
-using namespace ::basebmp;
-
-namespace
-{
-class BmpMaskTest : public CppUnit::TestFixture
-{
-private:
- BitmapDeviceSharedPtr mpDevice1bpp;
- BitmapDeviceSharedPtr mpMaskBmp1bpp;
- BitmapDeviceSharedPtr mpBmp1bpp;
- BitmapDeviceSharedPtr mpDevice32bpp;
- BitmapDeviceSharedPtr mpBmp32bpp;
-
- void implTestBmpBasics(const BitmapDeviceSharedPtr& rDevice,
- const BitmapDeviceSharedPtr& rBmp)
- {
- rDevice->clear(Color(0));
- const Color aCol(0xFFFFFFFF);
-
- const basegfx::B2IBox aSourceRect(0,0,10,10);
- const basegfx::B2IBox aDestAll(0,0,10,10);
-
- rDevice->drawMaskedBitmap(
- rBmp,
- mpMaskBmp1bpp,
- aSourceRect,
- aDestAll);
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 30",
- countPixel( rDevice, aCol ) == 30);
- }
-
- void implTestBmpScaledClip(const BitmapDeviceSharedPtr& rDevice,
- const BitmapDeviceSharedPtr& rBmp)
- {
- rDevice->clear(Color(0));
- const Color aCol(0xFFFFFFFF);
-
- const basegfx::B2IBox aSourceRect(0,0,10,10);
- const basegfx::B2IBox aDestLeftTop(0,0,6,6);
-
- rDevice->drawMaskedBitmap(
- rBmp,
- mpMaskBmp1bpp,
- aSourceRect,
- aDestLeftTop );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 12",
- countPixel( rDevice, aCol ) == 12);
- }
-
-public:
- void setUp() override
- {
- const basegfx::B2ISize aSize(10,10);
- mpDevice1bpp = createBitmapDevice( aSize,
- true,
- Format::OneBitMsbPal );
- mpDevice32bpp = createBitmapDevice( aSize,
- true,
- Format::ThirtyTwoBitTcMaskBGRA );
-
- mpMaskBmp1bpp = createBitmapDevice( aSize,
- true,
- Format::OneBitMsbGrey );
-
- mpBmp1bpp = createBitmapDevice( aSize,
- true,
- Format::OneBitMsbPal );
- mpBmp32bpp = createBitmapDevice( aSize,
- true,
- Format::ThirtyTwoBitTcMaskBGRA );
-
- OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
-
- basegfx::B2DPolyPolygon aPoly;
- basegfx::tools::importFromSvgD( aPoly, aSvg, false, nullptr );
- const Color aColWhite(0xFFFFFFFF);
- const Color aColBlack(0);
- mpBmp1bpp->fillPolyPolygon(
- aPoly,
- aColWhite );
- mpBmp32bpp->fillPolyPolygon(
- aPoly,
- aColWhite );
-
- aSvg = "m 0 0 h6 v10 h-6z" ;
-
- aPoly.clear();
- basegfx::tools::importFromSvgD( aPoly, aSvg, false, nullptr );
- mpMaskBmp1bpp->clear(aColWhite);
- mpMaskBmp1bpp->fillPolyPolygon(
- aPoly,
- aColBlack );
- }
-
- void testBmpBasics()
- {
- // mpDevice1bpp has a black rect. 0x0 -> 6x10
- implTestBmpBasics( mpDevice1bpp, mpBmp1bpp );
- implTestBmpBasics( mpDevice32bpp, mpBmp32bpp );
- }
-
- void testBmpClip()
- {
- implTestBmpScaledClip( mpDevice1bpp, mpBmp1bpp );
- implTestBmpScaledClip( mpDevice32bpp, mpBmp32bpp );
- }
-
- void testMasking()
- {
- BitmapDeviceSharedPtr xOutput;
- BitmapDeviceSharedPtr xBitmap;
- BitmapDeviceSharedPtr xMask;
-
- { // mpMask & mpBitmap
- const basegfx::B2ISize aSize(5, 5);
- std::vector< basebmp::Color > aDevPal;
- aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
- aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
-
- basebmp::Format nFormat;
-
- nFormat = Format::OneBitMsbPal;
-// nFormat = Format::OneBitMsbGrey; // FIXME - un-comment me to crash hard.
- xMask = createBitmapDevice( aSize, false /* bTopDown */,
- nFormat,
- PaletteMemorySharedVector(
- new std::vector< basebmp::Color >(aDevPal) ) );
- // wipe to copy everything.
- xMask->clear( basebmp::Color( 0x00, 0x00, 0x00 ) );
-
- // punch out another piece not to copy
- basegfx::B2DPolyPolygon aPoly;
- basegfx::tools::importFromSvgD( aPoly, "m 2 2 h4 v8 h-4z",
- false, nullptr );
- xMask->fillPolyPolygon( aPoly, basebmp::Color( 0xff, 0xff, 0xff ) );
-
- xBitmap = createBitmapDevice( aSize, false,
- Format::ThirtyTwoBitTcMaskBGRA );
- xBitmap->clear(Color(0x80808080));
- }
- { // mpOutput & mpBitmap
- const basegfx::B2ISize aSize(9, 9);
- xOutput = createBitmapDevice( aSize, false,
- Format::ThirtyTwoBitTcMaskBGRA );
- xOutput->clear(Color(0xffffffff));
- }
-
- const basegfx::B2IBox aSourceRect(0,0,4,4);
- const basegfx::B2IBox aDestAll(2,2,7,7);
-
- xOutput->drawMaskedBitmap(
- xBitmap, xMask,
- aSourceRect, aDestAll );
-
- CPPUNIT_ASSERT_MESSAGE( "output not cleared to white",
- xOutput->getPixel( basegfx::B2IPoint( 0, 0 ) ) == Color(0xffffff) );
- CPPUNIT_ASSERT_MESSAGE( "bitmap not drawn",
- xOutput->getPixel( basegfx::B2IPoint( 2, 2 ) ) == Color(0x808080) );
- CPPUNIT_ASSERT_MESSAGE( "mask not applied",
- xOutput->getPixel( basegfx::B2IPoint( 6, 6 ) ) == Color(0xffffff) );
- }
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(BmpMaskTest);
- CPPUNIT_TEST(testMasking);
- CPPUNIT_TEST(testBmpBasics);
- CPPUNIT_TEST(testBmpClip);
- CPPUNIT_TEST_SUITE_END();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(BmpMaskTest);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basebmp/test/bmptest.cxx b/basebmp/test/bmptest.cxx
deleted file mode 100644
index c2f078b..0000000
--- a/basebmp/test/bmptest.cxx
+++ /dev/null
@@ -1,195 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cppunit/TestAssert.h>
-#include <cppunit/TestFixture.h>
-#include <cppunit/extensions/HelperMacros.h>
-
-#include <basegfx/vector/b2isize.hxx>
-#include <basegfx/range/b2ibox.hxx>
-#include <basegfx/point/b2ipoint.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-
-#include <basebmp/color.hxx>
-#include <basebmp/scanlineformats.hxx>
-#include <basebmp/bitmapdevice.hxx>
-#include "tools.hxx"
-
-using namespace ::basebmp;
-
-namespace
-{
-class BmpTest : public CppUnit::TestFixture
-{
-private:
- BitmapDeviceSharedPtr mpDevice1bpp;
- BitmapDeviceSharedPtr mpBmp1bpp;
- BitmapDeviceSharedPtr mpDevice32bpp;
- BitmapDeviceSharedPtr mpBmp32bpp;
-
- void implTestBmpBasics(const BitmapDeviceSharedPtr& rDevice,
- const BitmapDeviceSharedPtr& rBmp)
- {
- rDevice->clear(Color(0));
- const Color aCol(0xFFFFFFFF);
-
- const basegfx::B2IBox aSourceRect(0,0,10,10);
- const basegfx::B2IBox aDestLeftTop(0,0,4,4);
- const basegfx::B2IBox aDestRightTop(6,0,10,4);
- const basegfx::B2IBox aDestLeftBottom(0,6,4,10);
- const basegfx::B2IBox aDestRightBottom(6,6,10,10);
-
- rDevice->drawBitmap(
- rBmp,
- aSourceRect,
- aDestLeftTop );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 8",
- countPixel( rDevice, aCol ) == 8);
-
- rDevice->drawBitmap(
- rBmp,
- aSourceRect,
- aDestRightTop );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 16",
- countPixel( rDevice, aCol ) == 16);
-
- rDevice->drawBitmap(
- rBmp,
- aSourceRect,
- aDestLeftBottom );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 24",
- countPixel( rDevice, aCol ) == 24);
-
- rDevice->drawBitmap(
- rBmp,
- aSourceRect,
- aDestRightBottom );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 32",
- countPixel( rDevice, aCol ) == 32);
-
- BitmapDeviceSharedPtr pClone = subsetBitmapDevice(
- rBmp, aSourceRect );
-
- // two overlapping areas within the same memory block, check
- // if we clobber the mem or properly detect the case
- const basegfx::B2IBox aSourceOverlap(0,0,6,10);
- const basegfx::B2IBox aDestOverlap(3,0,9,10);
- rBmp->drawBitmap(
- pClone,
- aSourceOverlap,
- aDestOverlap );
- CPPUNIT_ASSERT_MESSAGE("clobbertest - number of set pixel is not 50",
- countPixel( rBmp, aCol ) == 50);
-
- }
-
- void implTestBmpClip(const BitmapDeviceSharedPtr& rDevice,
- const BitmapDeviceSharedPtr& rBmp)
- {
- rDevice->clear(Color(0));
- const Color aCol(0xFFFFFFFF);
-
- const basegfx::B2IBox aSourceRect(0,0,10,10);
- const basegfx::B2IBox aDestLeftTop(-2,-2,2,2);
- const basegfx::B2IBox aDestRightTop(8,-2,12,2);
- const basegfx::B2IBox aDestLeftBottom(-2,8,2,12);
- const basegfx::B2IBox aDestRightBottom(8,8,12,12);
-
- rDevice->drawBitmap(
- rBmp,
- aSourceRect,
- aDestLeftTop );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 4",
- countPixel( rDevice, aCol ) == 4);
-
- rDevice->drawBitmap(
- rBmp,
- aSourceRect,
- aDestLeftBottom );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 4(c)",
- countPixel( rDevice, aCol ) == 4);
-
- rDevice->drawBitmap(
- rBmp,
- aSourceRect,
- aDestRightBottom );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 8",
- countPixel( rDevice, aCol ) == 8);
- }
-
-public:
- void setUp() override
- {
- const basegfx::B2ISize aSize(10,10);
- mpDevice1bpp = createBitmapDevice( aSize,
- true,
- Format::OneBitMsbPal );
- mpDevice32bpp = createBitmapDevice( aSize,
- true,
- Format::ThirtyTwoBitTcMaskBGRA );
-
- mpBmp1bpp = createBitmapDevice( aSize,
- true,
- Format::OneBitMsbPal );
- mpBmp32bpp = createBitmapDevice( aSize,
- true,
- Format::ThirtyTwoBitTcMaskBGRA );
-
- OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
-
- basegfx::B2DPolyPolygon aPoly;
- basegfx::tools::importFromSvgD( aPoly, aSvg, false, nullptr );
- const Color aCol(0xFFFFFFFF);
- mpBmp1bpp->fillPolyPolygon(
- aPoly,
- aCol );
- mpBmp32bpp->fillPolyPolygon(
- aPoly,
- aCol );
- }
-
- void testBmpBasics()
- {
- implTestBmpBasics( mpDevice1bpp, mpBmp1bpp );
- implTestBmpBasics( mpDevice32bpp, mpBmp32bpp );
- }
-
- void testBmpClip()
- {
- implTestBmpClip( mpDevice1bpp, mpBmp1bpp );
- implTestBmpClip( mpDevice32bpp, mpBmp32bpp );
- }
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(BmpTest);
- CPPUNIT_TEST(testBmpBasics);
- CPPUNIT_TEST(testBmpClip);
- CPPUNIT_TEST_SUITE_END();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(BmpTest);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basebmp/test/cliptest.cxx b/basebmp/test/cliptest.cxx
deleted file mode 100644
index eaa643f..0000000
--- a/basebmp/test/cliptest.cxx
+++ /dev/null
@@ -1,239 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cppunit/TestAssert.h>
-#include <cppunit/TestFixture.h>
-#include <cppunit/extensions/HelperMacros.h>
-
-#include <basegfx/vector/b2isize.hxx>
-#include <basegfx/point/b2ipoint.hxx>
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/range/b2ibox.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-
-#include <basebmp/color.hxx>
-#include <basebmp/scanlineformats.hxx>
-#include <basebmp/bitmapdevice.hxx>
-#include "tools.hxx"
-
-using namespace ::basebmp;
-
-namespace
-{
-class ClipTest : public CppUnit::TestFixture
-{
-private:
- BitmapDeviceSharedPtr mpClipMask;
- BitmapDeviceSharedPtr mpDevice1bpp;
- BitmapDeviceSharedPtr mpDevice32bpp;
-
- void implTestPixelClip(const BitmapDeviceSharedPtr& rDevice)
- {
- const Color aBgCol(0);
- rDevice->clear(aBgCol);
-
- const basegfx::B2IPoint aPt(0,0);
- const Color aCol(0xFFFFFFFF);
- rDevice->setPixel( aPt, aCol, mpClipMask );
- CPPUNIT_ASSERT_MESSAGE("get/setPixel clip #1",
- rDevice->getPixel(aPt) == aBgCol);
-
- const basegfx::B2IPoint aPt2(10,10);
- rDevice->setPixel( aPt2, aCol, mpClipMask );
- CPPUNIT_ASSERT_MESSAGE("get/setPixel clip #2",
- rDevice->getPixel(aPt2) == aBgCol);
-
- const basegfx::B2IPoint aPt1(10,0);
- rDevice->setPixel( aPt1, aCol, mpClipMask );
- CPPUNIT_ASSERT_MESSAGE("get/setPixel clip #3",
- rDevice->getPixel(aPt1) != aBgCol);
-
- const basegfx::B2IPoint aPt3(0,10);
- rDevice->setPixel( aPt3, aCol, mpClipMask );
- CPPUNIT_ASSERT_MESSAGE("get/setPixel clip #4",
- rDevice->getPixel(aPt3) != aBgCol);
- }
-
- void implTestLineClip(const BitmapDeviceSharedPtr& rDevice)
- {
- const Color aBgCol(0);
- rDevice->clear(aBgCol);
-
- const basegfx::B2IPoint aPt1(0,0);
- const basegfx::B2IPoint aPt2(1,9);
- const Color aCol(0xFFFFFFFF);
- rDevice->drawLine( aPt1, aPt2, aCol, mpClipMask );
-
- const basegfx::B2IPoint aPt3(1,5);
- CPPUNIT_ASSERT_MESSAGE("get line pixel",
- rDevice->getPixel(aPt3) != aBgCol);
- CPPUNIT_ASSERT_MESSAGE("number of rendered line pixel is not 4",
- countPixel( rDevice,
- rDevice->getPixel(aPt3) ) == 4);
- }
-
- void implTestFillClip(const BitmapDeviceSharedPtr& rDevice)
- {
- rDevice->clear(Color(0));
-
- const basegfx::B2DRange aAllOver(-10,-10,20,20);
- const Color aCol(0xFFFFFFFF);
- rDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(
- basegfx::tools::createPolygonFromRect(aAllOver)),
- aCol,
- mpClipMask );
- const basegfx::B2IPoint aPt(0,10);
- CPPUNIT_ASSERT_MESSAGE("number of clipped pixel is not 30",
- countPixel( rDevice, rDevice->getPixel(aPt) ) == 121-30);
-
- rDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(
- basegfx::tools::createPolygonFromRect(aAllOver)),
- aCol );
- CPPUNIT_ASSERT_MESSAGE("number of filled pixel is not 121",
- countPixel( rDevice, rDevice->getPixel(aPt) ) == 121);
- }
-
- void implTestBmpClip(const BitmapDeviceSharedPtr& rDevice)
- {
- BitmapDeviceSharedPtr pBmp( cloneBitmapDevice(
- basegfx::B2IVector(3,3),
- rDevice ));
- Color aCol1(0);
- Color aCol2(0xFFFFFFFF);
- pBmp->clear(aCol1);
- pBmp->setPixel(basegfx::B2IPoint(0,0),aCol2);
- pBmp->setPixel(basegfx::B2IPoint(1,1),aCol2);
- pBmp->setPixel(basegfx::B2IPoint(2,2),aCol2);
-
- rDevice->clear(aCol1);
- rDevice->drawBitmap(pBmp,
- basegfx::B2IBox(0,0,3,3),
- basegfx::B2IBox(-1,-1,4,4),
- mpClipMask);
-
- const basegfx::B2IPoint aPt(1,1);
- CPPUNIT_ASSERT_MESSAGE("number of clipped pixel is not 5",
- countPixel( rDevice,
- rDevice->getPixel(aPt) ) == 5);
- }
-
- void implTestMaskColorClip(const BitmapDeviceSharedPtr& rDevice)
- {
- BitmapDeviceSharedPtr pBmp( createBitmapDevice( rDevice->getSize(),
- true,
- Format::EightBitGrey ));
-
- OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
-
- basegfx::B2DPolyPolygon aPoly;
- basegfx::tools::importFromSvgD( aPoly, aSvg, false, nullptr );
- const basebmp::Color aCol(0xFF);
- pBmp->clear( basebmp::Color(0) );
- pBmp->fillPolyPolygon(
- aPoly,
- aCol );
-
- const basegfx::B2IBox aSourceRect(0,0,10,10);
- const basegfx::B2IPoint aDestLeftTop(0,0);
- const Color aCol2(0xF0F0F0F0);
- rDevice->drawMaskedColor(
- aCol2,
- pBmp,
- aSourceRect,
- aDestLeftTop,
- mpClipMask );
- const basegfx::B2IPoint aPt(1,1);
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 41",
- countPixel( rDevice, rDevice->getPixel(aPt) ) == 41);
-
- }
-
-public:
- void setUp() override
- {
- const basegfx::B2ISize aSize(11,11);
- mpClipMask = createBitmapDevice( aSize,
- true,
- Format::OneBitMsbGrey );
- mpDevice1bpp = createBitmapDevice( aSize,
- true,
- Format::OneBitMsbPal );
- mpDevice32bpp = createBitmapDevice( aSize,
- true,
- Format::ThirtyTwoBitTcMaskBGRA );
-
- OUString aSvg( "m 0 0 h5 l5 5 v5 h-5 l-5-5 z" );
- basegfx::B2DPolyPolygon aPoly;
- basegfx::tools::importFromSvgD( aPoly, aSvg, false, nullptr );
- mpClipMask->clear(Color(0));
- mpClipMask->drawPolygon(
- aPoly.getB2DPolygon(0),
- Color(0xFFFFFFFF) );
- }
-
- void testPixelClip()
- {
- implTestPixelClip( mpDevice1bpp );
- implTestPixelClip( mpDevice32bpp );
- }
-
- void testLineClip()
- {
- implTestLineClip( mpDevice1bpp );
- implTestLineClip( mpDevice32bpp );
- }
-
- void testFillClip()
- {
- implTestFillClip( mpDevice1bpp );
- implTestFillClip( mpDevice32bpp );
- }
-
- void testBmpClip()
- {
- implTestBmpClip( mpDevice1bpp );
- implTestBmpClip( mpDevice32bpp );
- }
-
- void testMaskColorClip()
- {
- implTestMaskColorClip( mpDevice1bpp );
- implTestMaskColorClip( mpDevice32bpp );
- }
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(ClipTest);
- CPPUNIT_TEST(testPixelClip);
- CPPUNIT_TEST(testLineClip);
- CPPUNIT_TEST(testFillClip);
- CPPUNIT_TEST(testBmpClip);
- CPPUNIT_TEST(testMaskColorClip);
- CPPUNIT_TEST_SUITE_END();
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ClipTest);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basebmp/test/filltest.cxx b/basebmp/test/filltest.cxx
deleted file mode 100644
index 5807c35..0000000
--- a/basebmp/test/filltest.cxx
+++ /dev/null
@@ -1,239 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cppunit/TestAssert.h>
-#include <cppunit/TestFixture.h>
-#include <cppunit/extensions/HelperMacros.h>
-
-#include <basegfx/vector/b2isize.hxx>
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/point/b2ipoint.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-
-#include <basebmp/color.hxx>
-#include <basebmp/scanlineformats.hxx>
-#include <basebmp/bitmapdevice.hxx>
-#include "tools.hxx"
-
-using namespace ::basebmp;
-
-namespace
-{
-class FillTest : public CppUnit::TestFixture
-{
-private:
- BitmapDeviceSharedPtr mpDevice1bpp;
- BitmapDeviceSharedPtr mpDevice32bpp;
-
- void implTestRectFill(const BitmapDeviceSharedPtr& rDevice)
- {
- rDevice->clear(Color(0));
-
- const basegfx::B2DRange aRect(1,1,10,10);
-
- const Color aCol(0xFFFFFFFF);
- rDevice->fillPolyPolygon(
- basegfx::B2DPolyPolygon(
- basegfx::tools::createPolygonFromRect( aRect )),
- aCol );
-
- const basegfx::B2IPoint aPt1(1,1);
- CPPUNIT_ASSERT_MESSAGE("first pixel set",
- rDevice->getPixel(aPt1) == aCol);
- const basegfx::B2IPoint aPt2(9,9);
- CPPUNIT_ASSERT_MESSAGE("last pixel set",
- rDevice->getPixel(aPt2) == aCol);
- const basegfx::B2IPoint aPt3(0,0);
- CPPUNIT_ASSERT_MESSAGE("topmost pixel not set",
- rDevice->getPixel(aPt3) != aCol);
- const basegfx::B2IPoint aPt4(10,10);
- CPPUNIT_ASSERT_MESSAGE("bottommost pixel not set",
- rDevice->getPixel(aPt4) != aCol);
-
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 81",
- countPixel( rDevice, aCol ) == 81);
- }
-
- void implTestCornerCases(const BitmapDeviceSharedPtr& rDevice)
- {
- rDevice->clear(Color(0));
-
- const basegfx::B2DRange aEmpty1(0,0,0,11);
- const basegfx::B2DRange aEmpty2(0,0,11,0);
- const basegfx::B2DRange aVertLineLeft(0,0,1,11);
- const basegfx::B2DRange aVertLineRight(10,0,11,11);
- const basegfx::B2DRange aHorzLineTop(0,0,11,1);
- const basegfx::B2DRange aHorzLineBottom(0,10,11,11);
-
- const Color aCol(0xFFFFFFFF);
- rDevice->fillPolyPolygon(
- basegfx::B2DPolyPolygon(
- basegfx::tools::createPolygonFromRect( aEmpty1 )),
- aCol );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 0",
- countPixel( rDevice, aCol ) == 0);
-
- rDevice->fillPolyPolygon(
- basegfx::B2DPolyPolygon(
- basegfx::tools::createPolygonFromRect( aEmpty2 )),
- aCol );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 0",
- countPixel( rDevice, aCol ) == 0);
-
- rDevice->fillPolyPolygon(
- basegfx::B2DPolyPolygon(
- basegfx::tools::createPolygonFromRect( aVertLineLeft )),
- aCol );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 11",
- countPixel( rDevice, aCol ) == 11);
- const basegfx::B2IPoint aPt1(0,0);
- CPPUNIT_ASSERT_MESSAGE("first pixel set",
- rDevice->getPixel(aPt1) == aCol);
-
- rDevice->fillPolyPolygon(
- basegfx::B2DPolyPolygon(
- basegfx::tools::createPolygonFromRect( aVertLineRight )),
- aCol );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 22",
- countPixel( rDevice, aCol ) == 22);
- const basegfx::B2IPoint aPt2(10,10);
- CPPUNIT_ASSERT_MESSAGE("last pixel set",
- rDevice->getPixel(aPt2) == aCol);
-
- rDevice->fillPolyPolygon(
- basegfx::B2DPolyPolygon(
- basegfx::tools::createPolygonFromRect( aHorzLineTop )),
- aCol );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 31",
- countPixel( rDevice, aCol ) == 31);
- const basegfx::B2IPoint aPt3(5,0);
- CPPUNIT_ASSERT_MESSAGE("top-middle pixel set",
- rDevice->getPixel(aPt3) == aCol);
-
- rDevice->fillPolyPolygon(
- basegfx::B2DPolyPolygon(
- basegfx::tools::createPolygonFromRect( aHorzLineBottom )),
- aCol );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 40",
- countPixel( rDevice, aCol ) == 40);
- const basegfx::B2IPoint aPt4(5,10);
- CPPUNIT_ASSERT_MESSAGE("bottom-middle pixel set",
- rDevice->getPixel(aPt4) == aCol);
-
- OUString aSvg( "m 0 0l7 7h-1z" );
-
- basegfx::B2DPolyPolygon aPoly;
- basegfx::tools::importFromSvgD( aPoly, aSvg, false, nullptr );
- rDevice->fillPolyPolygon(
- aPoly,
- aCol );
- CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 43",
- countPixel( rDevice, aCol ) == 43);
- }
-
- void implTestClipping(const BitmapDeviceSharedPtr& rDevice)
- {
- rDevice->clear(Color(0));
-
- const basegfx::B2DRange aLeftTop(-10,-10,1,1);
- const basegfx::B2DRange aRightTop(10,-10,20,1);
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list