1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <basegfx/pixel/bpixel.hxx>
23 #include <sal/types.h>
33 BZPixelRaster(const BZPixelRaster
&) = delete;
34 BZPixelRaster
& operator=(const BZPixelRaster
&) = delete;
39 std::unique_ptr
<BPixel
[]> mpContent
;
40 std::unique_ptr
<sal_uInt16
[]> mpZBuffer
;
43 // constructor/destructor
44 BZPixelRaster(sal_uInt32 nWidth
, sal_uInt32 nHeight
)
47 mnCount(nWidth
* nHeight
),
48 mpContent(new BPixel
[mnCount
]),
49 mpZBuffer(new sal_uInt16
[mnCount
])
51 memset(mpZBuffer
.get(), 0, sizeof(sal_uInt16
) * mnCount
);
54 // coordinate calcs between X/Y and span
55 sal_uInt32
getIndexFromXY(sal_uInt32 nX
, sal_uInt32 nY
) const { return (nX
+ (nY
* mnWidth
)); }
58 sal_uInt32
getWidth() const { return mnWidth
; }
59 sal_uInt32
getHeight() const { return mnHeight
; }
61 // data access read only
62 const BPixel
& getBPixel(sal_uInt32 nIndex
) const
64 assert(nIndex
< mnCount
&& "Access out of range");
65 return mpContent
[nIndex
];
68 // data access read/write
69 BPixel
& getBPixel(sal_uInt32 nIndex
)
71 assert(nIndex
< mnCount
&& "Access out of range");
72 return mpContent
[nIndex
];
75 // data access read only
76 const sal_uInt16
& getZ(sal_uInt32 nIndex
) const
78 assert(nIndex
< mnCount
&& "Access out of range");
79 return mpZBuffer
[nIndex
];
82 // data access read/write
83 sal_uInt16
& getZ(sal_uInt32 nIndex
)
85 assert(nIndex
< mnCount
&& "Access out of range");
86 return mpZBuffer
[nIndex
];
89 } // end of namespace basegfx
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */