1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // autogenerated file with codegen.pl 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include "preextstl.h" 31*cdf0e10cSrcweir #include "cppunit/TestAssert.h" 32*cdf0e10cSrcweir #include "cppunit/TestFixture.h" 33*cdf0e10cSrcweir #include "cppunit/extensions/HelperMacros.h" 34*cdf0e10cSrcweir #include "postextstl.h" 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <basegfx/vector/b2isize.hxx> 37*cdf0e10cSrcweir #include <basegfx/range/b2irange.hxx> 38*cdf0e10cSrcweir #include <basegfx/point/b2ipoint.hxx> 39*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 40*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 41*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygon.hxx> 42*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <basebmp/color.hxx> 45*cdf0e10cSrcweir #include <basebmp/scanlineformats.hxx> 46*cdf0e10cSrcweir #include <basebmp/bitmapdevice.hxx> 47*cdf0e10cSrcweir #include <basebmp/debug.hxx> 48*cdf0e10cSrcweir #include "tools.hxx" 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include <iostream> 51*cdf0e10cSrcweir #include <fstream> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir using namespace ::basebmp; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir namespace 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir /* 58*cdf0e10cSrcweir std::ofstream output("32bpp_test.dump"); 59*cdf0e10cSrcweir debugDump( rDevice, output ); 60*cdf0e10cSrcweir std::ofstream output2("32bpp_bmp.dump"); 61*cdf0e10cSrcweir debugDump( rBmp, output2 ); 62*cdf0e10cSrcweir */ 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir class MaskTest : public CppUnit::TestFixture 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir private: 67*cdf0e10cSrcweir BitmapDeviceSharedPtr mpDevice1bpp; 68*cdf0e10cSrcweir BitmapDeviceSharedPtr mpDevice32bpp; 69*cdf0e10cSrcweir BitmapDeviceSharedPtr mpMask; 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir void implTestMaskBasics(const BitmapDeviceSharedPtr& rDevice, 72*cdf0e10cSrcweir const BitmapDeviceSharedPtr& rBmp) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir const Color aCol(0); 75*cdf0e10cSrcweir const Color aCol2(0xF0F0F0F0); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir const basegfx::B2IRange aSourceRect(0,0,10,10); 78*cdf0e10cSrcweir const basegfx::B2IPoint aDestLeftTop(0,0); 79*cdf0e10cSrcweir const basegfx::B2IPoint aDestRightTop(5,0); 80*cdf0e10cSrcweir const basegfx::B2IPoint aDestLeftBottom(0,5); 81*cdf0e10cSrcweir const basegfx::B2IPoint aDestRightBottom(5,5); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir rDevice->clear(aCol); 84*cdf0e10cSrcweir rDevice->setPixel( 85*cdf0e10cSrcweir basegfx::B2IPoint(1,1), 86*cdf0e10cSrcweir aCol2, 87*cdf0e10cSrcweir DrawMode_PAINT); 88*cdf0e10cSrcweir rDevice->drawMaskedColor( 89*cdf0e10cSrcweir aCol2, 90*cdf0e10cSrcweir rBmp, 91*cdf0e10cSrcweir aSourceRect, 92*cdf0e10cSrcweir aDestLeftTop ); 93*cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 50", 94*cdf0e10cSrcweir countPixel( rDevice, aCol ) == 100-50); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir rDevice->clear(aCol); 97*cdf0e10cSrcweir rDevice->drawMaskedColor( 98*cdf0e10cSrcweir aCol2, 99*cdf0e10cSrcweir rBmp, 100*cdf0e10cSrcweir aSourceRect, 101*cdf0e10cSrcweir aDestRightTop ); 102*cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 25", 103*cdf0e10cSrcweir countPixel( rDevice, aCol ) == 100-25); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir rDevice->clear(aCol); 106*cdf0e10cSrcweir rDevice->drawMaskedColor( 107*cdf0e10cSrcweir aCol2, 108*cdf0e10cSrcweir rBmp, 109*cdf0e10cSrcweir aSourceRect, 110*cdf0e10cSrcweir aDestLeftBottom ); 111*cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 25(b)", 112*cdf0e10cSrcweir countPixel( rDevice, aCol ) == 100-25); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir rDevice->clear(aCol); 115*cdf0e10cSrcweir rDevice->drawMaskedColor( 116*cdf0e10cSrcweir aCol2, 117*cdf0e10cSrcweir rBmp, 118*cdf0e10cSrcweir aSourceRect, 119*cdf0e10cSrcweir aDestRightBottom ); 120*cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 25(c)", 121*cdf0e10cSrcweir countPixel( rDevice, aCol ) == 100-25); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir public: 125*cdf0e10cSrcweir void setUp() 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir const basegfx::B2ISize aSize(10,10); 128*cdf0e10cSrcweir mpDevice1bpp = createBitmapDevice( aSize, 129*cdf0e10cSrcweir true, 130*cdf0e10cSrcweir Format::ONE_BIT_MSB_PAL ); 131*cdf0e10cSrcweir mpDevice32bpp = createBitmapDevice( aSize, 132*cdf0e10cSrcweir true, 133*cdf0e10cSrcweir Format::THIRTYTWO_BIT_TC_MASK ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir mpMask = createBitmapDevice( aSize, 136*cdf0e10cSrcweir true, 137*cdf0e10cSrcweir Format::EIGHT_BIT_GREY ); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir ::rtl::OUString aSvg = ::rtl::OUString::createFromAscii( 140*cdf0e10cSrcweir "m 0 0h5v10h5v-5h-10z" ); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir basegfx::B2DPolyPolygon aPoly; 143*cdf0e10cSrcweir basegfx::tools::importFromSvgD( aPoly, aSvg ); 144*cdf0e10cSrcweir const Color aCol(0xFF); 145*cdf0e10cSrcweir mpMask->fillPolyPolygon( 146*cdf0e10cSrcweir aPoly, 147*cdf0e10cSrcweir aCol, 148*cdf0e10cSrcweir DrawMode_PAINT ); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir void testMaskBasics() 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir implTestMaskBasics( mpDevice32bpp, mpMask ); 154*cdf0e10cSrcweir implTestMaskBasics( mpDevice1bpp, mpMask ); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir void testMaskClip() 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir // Change the following lines only, if you add, remove or rename 162*cdf0e10cSrcweir // member functions of the current class, 163*cdf0e10cSrcweir // because these macros are need by auto register mechanism. 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir CPPUNIT_TEST_SUITE(MaskTest); 166*cdf0e10cSrcweir CPPUNIT_TEST(testMaskBasics); 167*cdf0e10cSrcweir CPPUNIT_TEST(testMaskClip); 168*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_END(); 169*cdf0e10cSrcweir }; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 172*cdf0e10cSrcweir CPPUNIT_TEST_SUITE_REGISTRATION(MaskTest); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir // this macro creates an empty function, which will called by the RegisterAllFunctions() 179*cdf0e10cSrcweir // to let the user the possibility to also register some functions by hand. 180*cdf0e10cSrcweir //NOADDITIONAL; 181*cdf0e10cSrcweir 182