LibreOffice Module basegfx (master) 1
bzpixelraster.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
23#include <sal/types.h>
24#include <memory>
25#include <cassert>
26#include <string.h>
27
28namespace basegfx
29{
31 {
32 private:
33 BZPixelRaster(const BZPixelRaster&) = delete;
35
36 sal_uInt32 mnWidth;
37 sal_uInt32 mnHeight;
38 sal_uInt32 mnCount;
39 std::unique_ptr<BPixel[]> mpContent;
40 std::unique_ptr<sal_uInt16[]> mpZBuffer;
41
42 public:
43 // constructor/destructor
44 BZPixelRaster(sal_uInt32 nWidth, sal_uInt32 nHeight)
45 : mnWidth(nWidth),
46 mnHeight(nHeight),
47 mnCount(nWidth * nHeight),
49 mpZBuffer(new sal_uInt16[mnCount])
50 {
51 memset(mpZBuffer.get(), 0, sizeof(sal_uInt16) * mnCount);
52 }
53
54 // coordinate calcs between X/Y and span
55 sal_uInt32 getIndexFromXY(sal_uInt32 nX, sal_uInt32 nY) const { return (nX + (nY * mnWidth)); }
56
57 // data access read
58 sal_uInt32 getWidth() const { return mnWidth; }
59 sal_uInt32 getHeight() const { return mnHeight; }
60
61 // data access read only
62 const BPixel& getBPixel(sal_uInt32 nIndex) const
63 {
64 assert(nIndex < mnCount && "Access out of range");
65 return mpContent[nIndex];
66 }
67
68 // data access read/write
69 BPixel& getBPixel(sal_uInt32 nIndex)
70 {
71 assert(nIndex < mnCount && "Access out of range");
72 return mpContent[nIndex];
73 }
74
75 // data access read only
76 const sal_uInt16& getZ(sal_uInt32 nIndex) const
77 {
78 assert(nIndex < mnCount && "Access out of range");
79 return mpZBuffer[nIndex];
80 }
81
82 // data access read/write
83 sal_uInt16& getZ(sal_uInt32 nIndex)
84 {
85 assert(nIndex < mnCount && "Access out of range");
86 return mpZBuffer[nIndex];
87 }
88 };
89} // end of namespace basegfx
90
91/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
BPixel & getBPixel(sal_uInt32 nIndex)
BZPixelRaster(sal_uInt32 nWidth, sal_uInt32 nHeight)
sal_uInt16 & getZ(sal_uInt32 nIndex)
std::unique_ptr< sal_uInt16[]> mpZBuffer
sal_uInt32 getIndexFromXY(sal_uInt32 nX, sal_uInt32 nY) const
sal_uInt32 getWidth() const
sal_uInt32 getHeight() const
std::unique_ptr< BPixel[]> mpContent
const sal_uInt16 & getZ(sal_uInt32 nIndex) const
BZPixelRaster & operator=(const BZPixelRaster &)=delete
BZPixelRaster(const BZPixelRaster &)=delete
const BPixel & getBPixel(sal_uInt32 nIndex) const
sal_Int32 nIndex