1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // autogenerated file with codegen.pl 25 26 #include "preextstl.h" 27 #include "gtest/gtest.h" 28 #include "postextstl.h" 29 30 #include <basegfx/vector/b2isize.hxx> 31 #include <basegfx/range/b2irange.hxx> 32 #include <basegfx/point/b2ipoint.hxx> 33 #include <basegfx/polygon/b2dpolygon.hxx> 34 #include <basegfx/polygon/b2dpolygontools.hxx> 35 #include <basegfx/polygon/b2dpolypolygon.hxx> 36 #include <basegfx/polygon/b2dpolypolygontools.hxx> 37 38 #include <basebmp/color.hxx> 39 #include <basebmp/scanlineformats.hxx> 40 #include <basebmp/bitmapdevice.hxx> 41 #include <basebmp/debug.hxx> 42 #include "tools.hxx" 43 44 #include <iostream> 45 #include <fstream> 46 47 using namespace ::basebmp; 48 49 namespace 50 { 51 /* 52 std::ofstream output("32bpp_test.dump"); 53 debugDump( rDevice, output ); 54 std::ofstream output2("32bpp_bmp.dump"); 55 debugDump( rBmp, output2 ); 56 */ 57 58 class MaskTest : public ::testing::Test 59 { 60 protected: 61 BitmapDeviceSharedPtr mpDevice1bpp; 62 BitmapDeviceSharedPtr mpDevice32bpp; 63 BitmapDeviceSharedPtr mpMask; 64 65 void implTestMaskBasics(const BitmapDeviceSharedPtr& rDevice, 66 const BitmapDeviceSharedPtr& rBmp) 67 { 68 const Color aCol(0); 69 const Color aCol2(0xF0F0F0F0); 70 71 const basegfx::B2IRange aSourceRect(0,0,10,10); 72 const basegfx::B2IPoint aDestLeftTop(0,0); 73 const basegfx::B2IPoint aDestRightTop(5,0); 74 const basegfx::B2IPoint aDestLeftBottom(0,5); 75 const basegfx::B2IPoint aDestRightBottom(5,5); 76 77 rDevice->clear(aCol); 78 rDevice->setPixel( 79 basegfx::B2IPoint(1,1), 80 aCol2, 81 DrawMode_PAINT); 82 rDevice->drawMaskedColor( 83 aCol2, 84 rBmp, 85 aSourceRect, 86 aDestLeftTop ); 87 ASSERT_TRUE(countPixel( rDevice, aCol ) == 100-50) << "number of rendered pixel is not 50"; 88 89 rDevice->clear(aCol); 90 rDevice->drawMaskedColor( 91 aCol2, 92 rBmp, 93 aSourceRect, 94 aDestRightTop ); 95 ASSERT_TRUE(countPixel( rDevice, aCol ) == 100-25) << "number of rendered pixel is not 25"; 96 97 rDevice->clear(aCol); 98 rDevice->drawMaskedColor( 99 aCol2, 100 rBmp, 101 aSourceRect, 102 aDestLeftBottom ); 103 ASSERT_TRUE(countPixel( rDevice, aCol ) == 100-25) << "number of rendered pixel is not 25(b)"; 104 105 rDevice->clear(aCol); 106 rDevice->drawMaskedColor( 107 aCol2, 108 rBmp, 109 aSourceRect, 110 aDestRightBottom ); 111 ASSERT_TRUE(countPixel( rDevice, aCol ) == 100-25) << "number of rendered pixel is not 25(c)"; 112 } 113 114 public: 115 virtual void SetUp() 116 { 117 const basegfx::B2ISize aSize(10,10); 118 mpDevice1bpp = createBitmapDevice( aSize, 119 true, 120 Format::ONE_BIT_MSB_PAL ); 121 mpDevice32bpp = createBitmapDevice( aSize, 122 true, 123 Format::THIRTYTWO_BIT_TC_MASK ); 124 125 mpMask = createBitmapDevice( aSize, 126 true, 127 Format::EIGHT_BIT_GREY ); 128 129 ::rtl::OUString aSvg = ::rtl::OUString::createFromAscii( 130 "m 0 0h5v10h5v-5h-10z" ); 131 132 basegfx::B2DPolyPolygon aPoly; 133 basegfx::tools::importFromSvgD( aPoly, aSvg, false, NULL ); 134 const Color aCol(0xFF); 135 mpMask->fillPolyPolygon( 136 aPoly, 137 aCol, 138 DrawMode_PAINT ); 139 } 140 }; 141 142 TEST_F(MaskTest, testMaskBasics) 143 { 144 implTestMaskBasics( mpDevice32bpp, mpMask ); 145 implTestMaskBasics( mpDevice1bpp, mpMask ); 146 } 147 148 TEST_F(MaskTest, testMaskClip) 149 { 150 } 151 152 153 } 154