Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / vcl / inc / impoctree.hxx
blob073720a9e319d06f9547d8056298d58e01b12583
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_VCL_INC_IMPOCTREE_HXX
21 #define INCLUDED_VCL_INC_IMPOCTREE_HXX
23 #include "octree.hxx"
25 class ImpErrorQuad
27 long nRed;
28 long nGreen;
29 long nBlue;
31 public:
33 ImpErrorQuad()
34 : nRed(0)
35 , nGreen(0)
36 , nBlue(0)
40 ImpErrorQuad( const BitmapColor& rColor )
41 : nRed( static_cast<long>(rColor.GetRed()) << 5 )
42 , nGreen( static_cast<long>(rColor.GetGreen()) << 5 )
43 , nBlue( static_cast<long>(rColor.GetBlue()) << 5 )
47 inline void operator=( const BitmapColor& rColor );
48 inline ImpErrorQuad& operator-=( const BitmapColor& rColor );
50 inline void ImplAddColorError1( const ImpErrorQuad& rErrQuad );
51 inline void ImplAddColorError3( const ImpErrorQuad& rErrQuad );
52 inline void ImplAddColorError5( const ImpErrorQuad& rErrQuad );
53 inline void ImplAddColorError7( const ImpErrorQuad& rErrQuad );
55 inline BitmapColor ImplGetColor();
58 inline void ImpErrorQuad::operator=( const BitmapColor& rColor )
60 nRed = static_cast<long>(rColor.GetRed()) << 5;
61 nGreen = static_cast<long>(rColor.GetGreen()) << 5;
62 nBlue = static_cast<long>(rColor.GetBlue()) << 5;
65 inline ImpErrorQuad& ImpErrorQuad::operator-=( const BitmapColor& rColor )
67 nRed -= ( static_cast<long>(rColor.GetRed()) << 5 );
68 nGreen -= ( static_cast<long>(rColor.GetGreen()) << 5 );
69 nBlue -= ( static_cast<long>(rColor.GetBlue()) << 5 );
71 return *this;
74 inline void ImpErrorQuad::ImplAddColorError1( const ImpErrorQuad& rErrQuad )
76 nRed += ( rErrQuad.nRed >> 4 );
77 nGreen += ( rErrQuad.nGreen >> 4 );
78 nBlue += ( rErrQuad.nBlue >> 4 );
81 inline void ImpErrorQuad::ImplAddColorError3( const ImpErrorQuad& rErrQuad )
83 nRed += ( rErrQuad.nRed * 3L >> 4 );
84 nGreen += ( rErrQuad.nGreen * 3L >> 4 );
85 nBlue += ( rErrQuad.nBlue * 3L >> 4 );
88 inline void ImpErrorQuad::ImplAddColorError5( const ImpErrorQuad& rErrQuad )
90 nRed += ( rErrQuad.nRed * 5L >> 4 );
91 nGreen += ( rErrQuad.nGreen * 5L >> 4 );
92 nBlue += ( rErrQuad.nBlue * 5L >> 4 );
95 inline void ImpErrorQuad::ImplAddColorError7( const ImpErrorQuad& rErrQuad )
97 nRed += ( rErrQuad.nRed * 7L >> 4 );
98 nGreen += ( rErrQuad.nGreen * 7L >> 4 );
99 nBlue += ( rErrQuad.nBlue *7L >> 4 );
102 inline BitmapColor ImpErrorQuad::ImplGetColor()
104 return BitmapColor( static_cast<sal_uInt8>( ( nRed < 0 ? 0L : nRed > 8160 ? 8160L : nRed ) >> 5 ),
105 static_cast<sal_uInt8>( ( nGreen < 0 ? 0L : nGreen > 8160 ? 8160L : nGreen ) >> 5 ),
106 static_cast<sal_uInt8>( ( nBlue < 0 ? 0L : nBlue > 8160 ? 8160L : nBlue ) >> 5 ) );
109 class ImpNodeCache
111 OctreeNode* pActNode;
113 public:
115 ImpNodeCache( const sal_uLong nInitSize );
116 ~ImpNodeCache();
118 inline OctreeNode* ImplGetFreeNode();
119 inline void ImplReleaseNode( OctreeNode* pNode );
122 inline OctreeNode* ImpNodeCache::ImplGetFreeNode()
124 OctreeNode* pNode;
126 if ( !pActNode )
128 pActNode = new NODE;
129 pActNode->pNextInCache = nullptr;
132 pNode = pActNode;
133 pActNode = pNode->pNextInCache;
134 memset( pNode, 0, sizeof( NODE ) );
136 return pNode;
139 inline void ImpNodeCache::ImplReleaseNode( OctreeNode* pNode )
141 pNode->pNextInCache = pActNode;
142 pActNode = pNode;
145 #endif // INCLUDED_VCL_INC_IMPOCTREE_HXX
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */