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