1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _BGFX_RASTER_BZPIXELRASTER_HXX
29 #define _BGFX_RASTER_BZPIXELRASTER_HXX
30 
31 #include <basegfx/raster/bpixelraster.hxx>
32 #include <rtl/memory.h>
33 
34 //////////////////////////////////////////////////////////////////////////////
35 // predeclarations
36 
37 //////////////////////////////////////////////////////////////////////////////
38 
39 namespace basegfx
40 {
41 	class BZPixelRaster : public BPixelRaster
42 	{
43 	protected:
44 		// additionally, host a ZBuffer
45 		sal_uInt16*					mpZBuffer;
46 
47 	public:
48 		// reset
49 		void resetZ()
50 		{
51 			reset();
52             rtl_zeroMemory(mpZBuffer, sizeof(sal_uInt16) * mnCount);
53 		}
54 
55 		// constructor/destructor
56 		BZPixelRaster(sal_uInt32 nWidth, sal_uInt32 nHeight)
57 		:	BPixelRaster(nWidth, nHeight),
58 			mpZBuffer(new sal_uInt16[mnCount])
59 		{
60             rtl_zeroMemory(mpZBuffer, sizeof(sal_uInt16) * mnCount);
61 		}
62 
63 		~BZPixelRaster()
64 		{
65 			delete [] mpZBuffer;
66 		}
67 
68 		// data access read only
69 		const sal_uInt16& getZ(sal_uInt32 nIndex) const
70 		{
71 #ifdef DBG_UTIL
72 			if(nIndex >= mnCount)
73 			{
74 				OSL_ENSURE(false, "getZ: Access out of range (!)");
75 				return mpZBuffer[0L];
76 			}
77 #endif
78 			return mpZBuffer[nIndex];
79 		}
80 
81 		// data access read/write
82 		sal_uInt16& getZ(sal_uInt32 nIndex)
83 		{
84 #ifdef DBG_UTIL
85 			if(nIndex >= mnCount)
86 			{
87 				OSL_ENSURE(false, "getZ: Access out of range (!)");
88 				return mpZBuffer[0L];
89 			}
90 #endif
91 			return mpZBuffer[nIndex];
92 		}
93 	};
94 } // end of namespace basegfx
95 
96 #endif /* _BGFX_RASTER_BZPIXELRASTER_HXX */
97