LCOV - code coverage report
Current view: top level - basebmp/test - bmpmasktest.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 58 58 100.0 %
Date: 2014-11-03 Functions: 13 13 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          12 : 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           4 :     void implTestBmpBasics(const BitmapDeviceSharedPtr& rDevice,
      53             :                            const BitmapDeviceSharedPtr& rBmp)
      54             :     {
      55           4 :         rDevice->clear(Color(0));
      56           4 :         const Color aCol(0xFFFFFFFF);
      57             : 
      58           4 :         const basegfx::B2IBox aSourceRect(0,0,10,10);
      59           4 :         const basegfx::B2IBox aDestAll(0,0,10,10);
      60             : 
      61             :         rDevice->drawMaskedBitmap(
      62             :             rBmp,
      63             :             mpMaskBmp1bpp,
      64             :             aSourceRect,
      65             :             aDestAll,
      66           4 :             DrawMode_PAINT );
      67           8 :         CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 30",
      68           4 :                                countPixel( rDevice, aCol ) == 30);
      69           4 :     }
      70             : 
      71           4 :     void implTestBmpScaledClip(const BitmapDeviceSharedPtr& rDevice,
      72             :                                const BitmapDeviceSharedPtr& rBmp)
      73             :     {
      74           4 :         rDevice->clear(Color(0));
      75           4 :         const Color aCol(0xFFFFFFFF);
      76             : 
      77           4 :         const basegfx::B2IBox aSourceRect(0,0,10,10);
      78           4 :         const basegfx::B2IBox aDestLeftTop(0,0,6,6);
      79             : 
      80             :         rDevice->drawMaskedBitmap(
      81             :             rBmp,
      82             :             mpMaskBmp1bpp,
      83             :             aSourceRect,
      84             :             aDestLeftTop,
      85           4 :             DrawMode_PAINT );
      86           8 :         CPPUNIT_ASSERT_MESSAGE("number of rendered pixel is not 12",
      87           4 :                                countPixel( rDevice, aCol ) == 12);
      88           4 :     }
      89             : 
      90             : public:
      91           4 :     void setUp() SAL_OVERRIDE
      92             :     {
      93           4 :         const basegfx::B2ISize aSize(10,10);
      94           8 :         mpDevice1bpp = createBitmapDevice( aSize,
      95             :                                            true,
      96           4 :                                            FORMAT_ONE_BIT_MSB_PAL );
      97           8 :         mpDevice32bpp = createBitmapDevice( aSize,
      98             :                                             true,
      99           4 :                                             FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
     100             : 
     101           8 :         mpMaskBmp1bpp = createBitmapDevice( aSize,
     102             :                                             true,
     103           4 :                                             FORMAT_ONE_BIT_MSB_GREY );
     104             : 
     105           8 :         mpBmp1bpp = createBitmapDevice( aSize,
     106             :                                         true,
     107           4 :                                         FORMAT_ONE_BIT_MSB_PAL );
     108           8 :         mpBmp32bpp = createBitmapDevice( aSize,
     109             :                                          true,
     110           4 :                                          FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA );
     111             : 
     112           8 :         OUString aSvg( "m 0 0h5v10h5v-5h-10z" );
     113             : 
     114           8 :         basegfx::B2DPolyPolygon aPoly;
     115           4 :         basegfx::tools::importFromSvgD( aPoly, aSvg, false, NULL );
     116           4 :         const Color aColWhite(0xFFFFFFFF);
     117           4 :         const Color aColBlack(0);
     118             :         mpBmp1bpp->fillPolyPolygon(
     119             :             aPoly,
     120             :             aColWhite,
     121           4 :             DrawMode_PAINT );
     122             :         mpBmp32bpp->fillPolyPolygon(
     123             :             aPoly,
     124             :             aColWhite,
     125           4 :             DrawMode_PAINT );
     126             : 
     127           4 :         aSvg = "m 0 0 h6 v10 h-6z" ;
     128             : 
     129           4 :         aPoly.clear();
     130           4 :         basegfx::tools::importFromSvgD( aPoly, aSvg, false, NULL );
     131           4 :         mpMaskBmp1bpp->clear(aColWhite);
     132             :         mpMaskBmp1bpp->fillPolyPolygon(
     133             :             aPoly,
     134             :             aColBlack,
     135           8 :             DrawMode_PAINT );
     136           4 :     }
     137             : 
     138           2 :     void testBmpBasics()
     139             :     {
     140           2 :         implTestBmpBasics( mpDevice1bpp, mpBmp1bpp );
     141           2 :         implTestBmpBasics( mpDevice32bpp, mpBmp32bpp );
     142           2 :     }
     143             : 
     144           2 :     void testBmpClip()
     145             :     {
     146           2 :         implTestBmpScaledClip( mpDevice1bpp, mpBmp1bpp );
     147           2 :         implTestBmpScaledClip( mpDevice32bpp, mpBmp32bpp );
     148           2 :     }
     149             : 
     150             :     // Change the following lines only, if you add, remove or rename
     151             :     // member functions of the current class,
     152             :     // because these macros are need by auto register mechanism.
     153             : 
     154           4 :     CPPUNIT_TEST_SUITE(BmpMaskTest);
     155           2 :     CPPUNIT_TEST(testBmpBasics);
     156           2 :     CPPUNIT_TEST(testBmpClip);
     157           4 :     CPPUNIT_TEST_SUITE_END();
     158             : };
     159             : 
     160           2 : CPPUNIT_TEST_SUITE_REGISTRATION(BmpMaskTest);
     161           6 : }
     162             : 
     163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10