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 #ifndef _BGFX_RASTER_BZPIXELRASTER_HXX
25 #define _BGFX_RASTER_BZPIXELRASTER_HXX
26 
27 #include <basegfx/raster/bpixelraster.hxx>
28 #include <rtl/memory.h>
29 
30 //////////////////////////////////////////////////////////////////////////////
31 // predeclarations
32 
33 //////////////////////////////////////////////////////////////////////////////
34 
35 namespace basegfx
36 {
37 	class BZPixelRaster : public BPixelRaster
38 	{
39 	protected:
40 		// additionally, host a ZBuffer
41 		sal_uInt16*					mpZBuffer;
42 
43 	public:
44 		// reset
resetZ()45 		void resetZ()
46 		{
47 			reset();
48             rtl_zeroMemory(mpZBuffer, sizeof(sal_uInt16) * mnCount);
49 		}
50 
51 		// constructor/destructor
BZPixelRaster(sal_uInt32 nWidth,sal_uInt32 nHeight)52 		BZPixelRaster(sal_uInt32 nWidth, sal_uInt32 nHeight)
53 		:	BPixelRaster(nWidth, nHeight),
54 			mpZBuffer(new sal_uInt16[mnCount])
55 		{
56             rtl_zeroMemory(mpZBuffer, sizeof(sal_uInt16) * mnCount);
57 		}
58 
~BZPixelRaster()59 		~BZPixelRaster()
60 		{
61 			delete [] mpZBuffer;
62 		}
63 
64 		// data access read only
getZ(sal_uInt32 nIndex) const65 		const sal_uInt16& getZ(sal_uInt32 nIndex) const
66 		{
67 #ifdef DBG_UTIL
68 			if(nIndex >= mnCount)
69 			{
70 				OSL_ENSURE(false, "getZ: Access out of range (!)");
71 				return mpZBuffer[0L];
72 			}
73 #endif
74 			return mpZBuffer[nIndex];
75 		}
76 
77 		// data access read/write
getZ(sal_uInt32 nIndex)78 		sal_uInt16& getZ(sal_uInt32 nIndex)
79 		{
80 #ifdef DBG_UTIL
81 			if(nIndex >= mnCount)
82 			{
83 				OSL_ENSURE(false, "getZ: Access out of range (!)");
84 				return mpZBuffer[0L];
85 			}
86 #endif
87 			return mpZBuffer[nIndex];
88 		}
89 	};
90 } // end of namespace basegfx
91 
92 #endif /* _BGFX_RASTER_BZPIXELRASTER_HXX */
93