LCOV - code coverage report
Current view: top level - basebmp/test - bmpmasktest.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 58 58 100.0 %
Date: 2015-06-13 12:38:46 Functions: 16 16 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : // autogenerated file with codegen.pl
      21             : 
      22             : #include <cppunit/TestAssert.h>
      23             : #include <cppunit/TestFixture.h>
      24             : #include <cppunit/extensions/HelperMacros.h>
      25             : 
      26             : #include <basegfx/vector/b2isize.hxx>
      27             : #include <basegfx/range/b2ibox.hxx>
      28             : #include <basegfx/point/b2ipoint.hxx>
      29             : #include <basegfx/polygon/b2dpolygon.hxx>
      30             : #include <basegfx/polygon/b2dpolygontools.hxx>
      31             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      32             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      33             : 
      34             : #include <basebmp/color.hxx>
      35             : #include <basebmp/scanlineformats.hxx>
      36             : #include <basebmp/bitmapdevice.hxx>
      37             : #include "tools.hxx"
      38             : 
      39             : using namespace ::basebmp;
      40             : 
      41             : namespace
      42             : {
      43           6 : class BmpMaskTest : public CppUnit::TestFixture
      44             : {
      45             : private:
      46             :     BitmapDeviceSharedPtr mpDevice1bpp;
      47             :     BitmapDeviceSharedPtr mpMaskBmp1bpp;
      48             :     BitmapDeviceSharedPtr mpBmp1bpp;
      49             :     BitmapDeviceSharedPtr mpDevice32bpp;
      50             :     BitmapDeviceSharedPtr mpBmp32bpp;
      51             : 
      52           2 :     void implTestBmpBasics(const BitmapDeviceSharedPtr& rDevice,
      53             :                            const BitmapDeviceSharedPtr& rBmp)
      54             :     {
      55           2 :         rDevice->clear(Color(0));
      56           2 :         const Color aCol(0xFFFFFFFF);
      57             : 
      58           2 :         const basegfx::B2IBox aSourceRect(0,0,10,10);
      59           2 :         const basegfx::B2IBox aDestAll(0,0,10,10);
      60             : 
      61             :         rDevice->drawMaskedBitmap(
      62             :             rBmp,
      63             :             mpMaskBmp1bpp,
      64             :             aSourceRect,
      65             :             aDestAll,
      66           2 :             DrawMode::Paint );
      67           4 :         CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 30",
      68           2 :                                countPixel( rDevice, aCol ) == 30);
      69           2 :     }
      70             : 
      71           2 :     void implTestBmpScaledClip(const BitmapDeviceSharedPtr& rDevice,
      72             :                                const BitmapDeviceSharedPtr& rBmp)
      73             :     {
      74           2 :         rDevice->clear(Color(0));
      75           2 :         const Color aCol(0xFFFFFFFF);
      76             : 
      77           2 :         const basegfx::B2IBox aSourceRect(0,0,10,10);
      78           2 :         const basegfx::B2IBox aDestLeftTop(0,0,6,6);
      79             : 
      80             :         rDevice->drawMaskedBitmap(
      81             :             rBmp,
      82             :             mpMaskBmp1bpp,
      83             :             aSourceRect,
      84             :             aDestLeftTop,
      85           2 :             DrawMode::Paint );
      86           4 :         CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 12",
      87           2 :                                countPixel( rDevice, aCol ) == 12);
      88           2 :     }
      89             : 
      90             : public:
      91           2 :     void setUp() SAL_OVERRIDE
      92             :     {
      93           2 :         const basegfx::B2ISize aSize(10,10);
      94           4 :         mpDevice1bpp = createBitmapDevice( aSize,
      95             :                                            true,
      96             :                                            Format::OneBitMsbPal,
      97           2 :                                            basebmp::getBitmapDeviceStrideForWidth(Format::OneBitMsbPal, aSize.getX()));
      98           4 :         mpDevice32bpp = createBitmapDevice( aSize,
      99             :                                             true,
     100             :                                             Format::ThirtyTwoBitTcMaskBGRA,
     101           2 :                                             basebmp::getBitmapDeviceStrideForWidth(Format::ThirtyTwoBitTcMaskBGRA, aSize.getX()));
     102             : 
     103           4 :         mpMaskBmp1bpp = createBitmapDevice( aSize,
     104             :                                             true,
     105             :                                             Format::OneBitMsbGrey,
     106           2 :                                             basebmp::getBitmapDeviceStrideForWidth(Format::OneBitMsbGrey, aSize.getX()));
     107             : 
     108           4 :         mpBmp1bpp = createBitmapDevice( aSize,
     109             :                                         true,
     110             :                                         Format::OneBitMsbPal,
     111           2 :                                         basebmp::getBitmapDeviceStrideForWidth(Format::OneBitMsbPal, aSize.getX()));
     112           4 :         mpBmp32bpp = createBitmapDevice( aSize,
     113             :                                          true,
     114             :                                          Format::ThirtyTwoBitTcMaskBGRA,
     115           2 :                                          basebmp::getBitmapDeviceStrideForWidth(Format::ThirtyTwoBitTcMaskBGRA, aSize.getX()));
     116             : 
     117           4 :         OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
     118             : 
     119           4 :         basegfx::B2DPolyPolygon aPoly;
     120           2 :         basegfx::tools::importFromSvgD( aPoly, aSvg, false, NULL );
     121           2 :         const Color aColWhite(0xFFFFFFFF);
     122           2 :         const Color aColBlack(0);
     123             :         mpBmp1bpp->fillPolyPolygon(
     124             :             aPoly,
     125             :             aColWhite,
     126           2 :             DrawMode::Paint );
     127             :         mpBmp32bpp->fillPolyPolygon(
     128             :             aPoly,
     129             :             aColWhite,
     130           2 :             DrawMode::Paint );
     131             : 
     132           2 :         aSvg = "m 0 0 h6 v10 h-6z" ;
     133             : 
     134           2 :         aPoly.clear();
     135           2 :         basegfx::tools::importFromSvgD( aPoly, aSvg, false, NULL );
     136           2 :         mpMaskBmp1bpp->clear(aColWhite);
     137             :         mpMaskBmp1bpp->fillPolyPolygon(
     138             :             aPoly,
     139             :             aColBlack,
     140           4 :             DrawMode::Paint );
     141           2 :     }
     142             : 
     143           1 :     void testBmpBasics()
     144             :     {
     145           1 :         implTestBmpBasics( mpDevice1bpp, mpBmp1bpp );
     146           1 :         implTestBmpBasics( mpDevice32bpp, mpBmp32bpp );
     147           1 :     }
     148             : 
     149           1 :     void testBmpClip()
     150             :     {
     151           1 :         implTestBmpScaledClip( mpDevice1bpp, mpBmp1bpp );
     152           1 :         implTestBmpScaledClip( mpDevice32bpp, mpBmp32bpp );
     153           1 :     }
     154             : 
     155             :     // Change the following lines only, if you add, remove or rename
     156             :     // member functions of the current class,
     157             :     // because these macros are need by auto register mechanism.
     158             : 
     159           2 :     CPPUNIT_TEST_SUITE(BmpMaskTest);
     160           1 :     CPPUNIT_TEST(testBmpBasics);
     161           1 :     CPPUNIT_TEST(testBmpClip);
     162           5 :     CPPUNIT_TEST_SUITE_END();
     163             : };
     164             : 
     165           1 : CPPUNIT_TEST_SUITE_REGISTRATION(BmpMaskTest);
     166           3 : }
     167             : 
     168             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11