1*ce9c7ef7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ce9c7ef7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ce9c7ef7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ce9c7ef7SAndrew Rist  * distributed with this work for additional information
6*ce9c7ef7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ce9c7ef7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ce9c7ef7SAndrew Rist  * "License"); you may not use this file except in compliance
9*ce9c7ef7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ce9c7ef7SAndrew Rist  *
11*ce9c7ef7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ce9c7ef7SAndrew Rist  *
13*ce9c7ef7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ce9c7ef7SAndrew Rist  * software distributed under the License is distributed on an
15*ce9c7ef7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ce9c7ef7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ce9c7ef7SAndrew Rist  * specific language governing permissions and limitations
18*ce9c7ef7SAndrew Rist  * under the License.
19*ce9c7ef7SAndrew Rist  *
20*ce9c7ef7SAndrew Rist  *************************************************************/
21*ce9c7ef7SAndrew Rist 
22*ce9c7ef7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _BGFX_RASTER_BZPIXELRASTER_HXX
25cdf0e10cSrcweir #define _BGFX_RASTER_BZPIXELRASTER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <basegfx/raster/bpixelraster.hxx>
28cdf0e10cSrcweir #include <rtl/memory.h>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
31cdf0e10cSrcweir // predeclarations
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace basegfx
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 	class BZPixelRaster : public BPixelRaster
38cdf0e10cSrcweir 	{
39cdf0e10cSrcweir 	protected:
40cdf0e10cSrcweir 		// additionally, host a ZBuffer
41cdf0e10cSrcweir 		sal_uInt16*					mpZBuffer;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 	public:
44cdf0e10cSrcweir 		// reset
resetZ()45cdf0e10cSrcweir 		void resetZ()
46cdf0e10cSrcweir 		{
47cdf0e10cSrcweir 			reset();
48cdf0e10cSrcweir             rtl_zeroMemory(mpZBuffer, sizeof(sal_uInt16) * mnCount);
49cdf0e10cSrcweir 		}
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 		// constructor/destructor
BZPixelRaster(sal_uInt32 nWidth,sal_uInt32 nHeight)52cdf0e10cSrcweir 		BZPixelRaster(sal_uInt32 nWidth, sal_uInt32 nHeight)
53cdf0e10cSrcweir 		:	BPixelRaster(nWidth, nHeight),
54cdf0e10cSrcweir 			mpZBuffer(new sal_uInt16[mnCount])
55cdf0e10cSrcweir 		{
56cdf0e10cSrcweir             rtl_zeroMemory(mpZBuffer, sizeof(sal_uInt16) * mnCount);
57cdf0e10cSrcweir 		}
58cdf0e10cSrcweir 
~BZPixelRaster()59cdf0e10cSrcweir 		~BZPixelRaster()
60cdf0e10cSrcweir 		{
61cdf0e10cSrcweir 			delete [] mpZBuffer;
62cdf0e10cSrcweir 		}
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 		// data access read only
getZ(sal_uInt32 nIndex) const65cdf0e10cSrcweir 		const sal_uInt16& getZ(sal_uInt32 nIndex) const
66cdf0e10cSrcweir 		{
67cdf0e10cSrcweir #ifdef DBG_UTIL
68cdf0e10cSrcweir 			if(nIndex >= mnCount)
69cdf0e10cSrcweir 			{
70cdf0e10cSrcweir 				OSL_ENSURE(false, "getZ: Access out of range (!)");
71cdf0e10cSrcweir 				return mpZBuffer[0L];
72cdf0e10cSrcweir 			}
73cdf0e10cSrcweir #endif
74cdf0e10cSrcweir 			return mpZBuffer[nIndex];
75cdf0e10cSrcweir 		}
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 		// data access read/write
getZ(sal_uInt32 nIndex)78cdf0e10cSrcweir 		sal_uInt16& getZ(sal_uInt32 nIndex)
79cdf0e10cSrcweir 		{
80cdf0e10cSrcweir #ifdef DBG_UTIL
81cdf0e10cSrcweir 			if(nIndex >= mnCount)
82cdf0e10cSrcweir 			{
83cdf0e10cSrcweir 				OSL_ENSURE(false, "getZ: Access out of range (!)");
84cdf0e10cSrcweir 				return mpZBuffer[0L];
85cdf0e10cSrcweir 			}
86cdf0e10cSrcweir #endif
87cdf0e10cSrcweir 			return mpZBuffer[nIndex];
88cdf0e10cSrcweir 		}
89cdf0e10cSrcweir 	};
90cdf0e10cSrcweir } // end of namespace basegfx
91cdf0e10cSrcweir 
92cdf0e10cSrcweir #endif /* _BGFX_RASTER_BZPIXELRASTER_HXX */
93