Kaydet (Commit) 0646821f authored tarafından Caolán McNamara's avatar Caolán McNamara

drop newly unused basebmp methods

Change-Id: Ifd9906e7288c613eb2ac6cde7ca8bc7607f349fa
üst 962e4113
......@@ -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 \
))
......
......@@ -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:
......@@ -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:
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
/* -*- 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);
const basegfx::B2DRange aLeftBottom(-10,10,1,20);
const basegfx::B2DRange aRightBottom(10,10,20,20);
const basegfx::B2DRange aAllOver(-10,-10,20,20);
const Color aCol(0xFFFFFFFF);
rDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(
basegfx::tools::createPolygonFromRect(aLeftTop)),
aCol );
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 1",
countPixel( rDevice, aCol ) == 1);
rDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(
basegfx::tools::createPolygonFromRect(aRightTop)),
aCol );
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 2",
countPixel( rDevice, aCol ) == 2);
rDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(
basegfx::tools::createPolygonFromRect(aLeftBottom)),
aCol );
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 3",
countPixel( rDevice, aCol ) == 3);
rDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(
basegfx::tools::createPolygonFromRect(aRightBottom)),
aCol );
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 4",
countPixel( rDevice, aCol ) == 4);
rDevice->fillPolyPolygon( basegfx::B2DPolyPolygon(
basegfx::tools::createPolygonFromRect(aAllOver)),
aCol );
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 121",
countPixel( rDevice, aCol ) == 121);
}
public:
void setUp() override
{
const basegfx::B2ISize aSize(11,11);
mpDevice1bpp = createBitmapDevice( aSize,
true,
Format::OneBitMsbPal );
mpDevice32bpp = createBitmapDevice( aSize,
true,
Format::ThirtyTwoBitTcMaskBGRA );
}
void testRectFill()
{
implTestRectFill( mpDevice1bpp );
implTestRectFill( mpDevice32bpp );
}
void testClipping()
{
implTestClipping( mpDevice1bpp );
implTestClipping( mpDevice32bpp );
}
void testCornerCases()
{
implTestCornerCases( mpDevice1bpp );
implTestCornerCases( 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(FillTest);
CPPUNIT_TEST(testRectFill);
CPPUNIT_TEST(testClipping);
CPPUNIT_TEST(testCornerCases);
CPPUNIT_TEST_SUITE_END();
};
CPPUNIT_TEST_SUITE_REGISTRATION(FillTest);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 <basebmp/color.hxx>
#include <basebmp/scanlineformats.hxx>
#include <basebmp/bitmapdevice.hxx>
#include "tools.hxx"
using namespace ::basebmp;
namespace
{
class LineTest : public CppUnit::TestFixture
{
private:
BitmapDeviceSharedPtr mpDevice1bpp;
BitmapDeviceSharedPtr mpDevice32bpp;
void implTestBasicDiagonalLines(const BitmapDeviceSharedPtr& rDevice)
{
rDevice->clear(Color(0));
const basegfx::B2IPoint aPt1(1,1);
const basegfx::B2IPoint aPt2(9,9);
const Color aCol(0xFFFFFFFF);
rDevice->drawLine( aPt1, aPt2, aCol );
CPPUNIT_ASSERT_MESSAGE("first pixel set",
rDevice->getPixel(aPt1) == aCol);
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 9",
countPixel( rDevice, aCol ) == 9);
rDevice->drawLine( aPt2, aPt1, aCol );
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel after "
"reversed paint is not 9",
countPixel( rDevice, aCol ) == 9);
}
void implTestBasicHorizontalLines(const BitmapDeviceSharedPtr& rDevice)
{
rDevice->clear(Color(0));
const basegfx::B2IPoint aPt1(10,10);
const basegfx::B2IPoint aPt2(0,10);
const Color aCol(0xFFFFFFFF);
rDevice->drawLine( aPt1, aPt2, aCol );
CPPUNIT_ASSERT_MESSAGE("first pixel set",
rDevice->getPixel(aPt1) == aCol);
CPPUNIT_ASSERT_MESSAGE("last pixel set",
rDevice->getPixel(aPt2) == aCol);
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 11",
countPixel( rDevice, aCol ) == 11);
rDevice->clear(Color(0));
rDevice->drawLine( aPt2, aPt1, aCol );
CPPUNIT_ASSERT_MESSAGE("first pixel set",
rDevice->getPixel(aPt1) == aCol);
CPPUNIT_ASSERT_MESSAGE("last pixel set",
rDevice->getPixel(aPt2) == aCol);
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 11",
countPixel( rDevice, aCol ) == 11);
}
void implTestBasicVerticalLines(const BitmapDeviceSharedPtr& rDevice)
{
rDevice->clear(Color(0));
const basegfx::B2IPoint aPt1(1,1);
const basegfx::B2IPoint aPt2(1,9);
const Color aCol(0xFFFFFFFF);
rDevice->drawLine( aPt1, aPt2, aCol );
CPPUNIT_ASSERT_MESSAGE("first pixel set",
rDevice->getPixel(aPt1) == aCol);
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(0,10);
CPPUNIT_ASSERT_MESSAGE("bottommost pixel not set",
rDevice->getPixel(aPt4) != aCol);
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 9",
countPixel( rDevice, aCol ) == 9);
}
// test pixel rounding (should always tend towards start point of
// the line)
void implTestTieBreaking(const BitmapDeviceSharedPtr& rDevice)
{
rDevice->clear(Color(0));
const basegfx::B2IPoint aPt1(1,1);
const basegfx::B2IPoint aPt2(3,2);
const Color aCol(0xFFFFFFFF);
rDevice->drawLine( aPt1, aPt2, aCol );
CPPUNIT_ASSERT_MESSAGE("first pixel set",
rDevice->getPixel(aPt1) == aCol);
CPPUNIT_ASSERT_MESSAGE("second pixel set",
rDevice->getPixel(basegfx::B2IPoint(2,1)) == aCol);
CPPUNIT_ASSERT_MESSAGE("last pixel set",
rDevice->getPixel(aPt2) == aCol);
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel after "
"reversed paint is not 3",
countPixel( rDevice, aCol ) == 3);
rDevice->drawLine( aPt2, aPt1, aCol );
CPPUNIT_ASSERT_MESSAGE("alternate second pixel set",
rDevice->getPixel(basegfx::B2IPoint(2,2)) == aCol);
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel after "
"reversed paint is not 4",
countPixel( rDevice, aCol ) == 4);
}
public:
void setUp() override
{
const basegfx::B2ISize aSize(11,11);
mpDevice1bpp = createBitmapDevice( aSize,
true,
Format::OneBitMsbPal );
mpDevice32bpp = createBitmapDevice( aSize,
true,
Format::ThirtyTwoBitTcMaskBGRA );
}
void testCornerCases()
{
const basegfx::B2ISize aSize(1,1);
BitmapDeviceSharedPtr pDevice = createBitmapDevice(
aSize,
true,
Format::OneBitMsbPal );
const basegfx::B2IPoint aPt1(0,0);
const basegfx::B2IPoint aPt2(10,10);
CPPUNIT_ASSERT_MESSAGE("only pixel cleared",
pDevice->getPixelData(aPt1) == 0);
const Color aCol(0xFFFFFFFF);
pDevice->drawLine( aPt1, aPt2, aCol );
CPPUNIT_ASSERT_MESSAGE("only pixel set",
pDevice->getPixelData(aPt1) == 1);
const basegfx::B2ISize aSize2(1,0);
pDevice = createBitmapDevice(
aSize2,
true,
Format::OneBitMsbPal );
CPPUNIT_ASSERT_MESSAGE("only pixel cleared",
pDevice->getPixelData(aPt1) == 0);
pDevice->drawLine( aPt1, aPt2, aCol );
CPPUNIT_ASSERT_MESSAGE("only pixel still cleared",
pDevice->getPixelData(aPt1) == 0);
}
void testBasicDiagonalLines()
{
implTestBasicDiagonalLines( mpDevice1bpp );
implTestBasicDiagonalLines( mpDevice32bpp );
}
void testBasicHorizontalLines()
{
implTestBasicHorizontalLines( mpDevice1bpp );
implTestBasicHorizontalLines( mpDevice32bpp );
}
void testBasicVerticalLines()
{
implTestBasicVerticalLines( mpDevice1bpp );
implTestBasicVerticalLines( mpDevice32bpp );
}
// test pixel rounding (should always tend towards start point of
// the line)
void testTieBreaking()
{
implTestTieBreaking( mpDevice1bpp );
implTestTieBreaking( 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(LineTest);
CPPUNIT_TEST(testCornerCases);
CPPUNIT_TEST(testBasicDiagonalLines);
CPPUNIT_TEST(testBasicHorizontalLines);
CPPUNIT_TEST(testBasicVerticalLines);
CPPUNIT_TEST(testTieBreaking);
CPPUNIT_TEST_SUITE_END();
};
CPPUNIT_TEST_SUITE_REGISTRATION(LineTest);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 MaskTest : public CppUnit::TestFixture
{
private:
BitmapDeviceSharedPtr mpDevice1bpp;
BitmapDeviceSharedPtr mpDevice32bpp;
BitmapDeviceSharedPtr mpMask;
void implTestMaskBasics(const BitmapDeviceSharedPtr& rDevice,
const BitmapDeviceSharedPtr& rBmp)
{
const Color aCol(0);
const Color aCol2(0xF0F0F0F0);
const basegfx::B2IBox aSourceRect(0,0,10,10);
const basegfx::B2IPoint aDestLeftTop(0,0);
const basegfx::B2IPoint aDestRightTop(5,0);
const basegfx::B2IPoint aDestLeftBottom(0,5);
const basegfx::B2IPoint aDestRightBottom(5,5);
rDevice->clear(aCol);
rDevice->setPixel(
basegfx::B2IPoint(1,1),
aCol2);
rDevice->drawMaskedColor(
aCol2,
rBmp,
aSourceRect,
aDestLeftTop );
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 50",
countPixel( rDevice, aCol ) == 100-50);
rDevice->clear(aCol);
rDevice->drawMaskedColor(
aCol2,
rBmp,
aSourceRect,
aDestRightTop );
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 25",
countPixel( rDevice, aCol ) == 100-25);
rDevice->clear(aCol);
rDevice->drawMaskedColor(
aCol2,
rBmp,
aSourceRect,
aDestLeftBottom );
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 25(b)",
countPixel( rDevice, aCol ) == 100-25);
rDevice->clear(aCol);
rDevice->drawMaskedColor(
aCol2,
rBmp,
aSourceRect,
aDestRightBottom );
CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 25(c)",
countPixel( rDevice, aCol ) == 100-25);
}
public:
void setUp() override
{
const basegfx::B2ISize aSize(10,10);
mpDevice1bpp = createBitmapDevice( aSize,
true,
Format::OneBitMsbPal );
mpDevice32bpp = createBitmapDevice( aSize,
true,
Format::ThirtyTwoBitTcMaskBGRA );
mpMask = createBitmapDevice( aSize,
true,
Format::EightBitGrey );
OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
basegfx::B2DPolyPolygon aPoly;
basegfx::tools::importFromSvgD( aPoly, aSvg, false, nullptr );
const Color aCol(0xFF);
mpMask->fillPolyPolygon(
aPoly,
aCol);
}
void testMaskBasics()
{
implTestMaskBasics( mpDevice32bpp, mpMask );
implTestMaskBasics( mpDevice1bpp, mpMask );
}
// 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(MaskTest);
CPPUNIT_TEST(testMaskBasics);
CPPUNIT_TEST_SUITE_END();
};
CPPUNIT_TEST_SUITE_REGISTRATION(MaskTest);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment