bump product version to 4.1.6.2
[LibreOffice.git] / vcl / inc / impoct.hxx
blob81431c0b233659e8aa84d81fac1dbd3149ffee7f
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 _SV_IMPOCT_HXX
21 #define _SV_IMPOCT_HXX
23 #include <vcl/octree.hxx>
25 // ----------------
26 // - ImpErrorQuad -
27 // ----------------
29 class ImpErrorQuad
31 long nRed;
32 long nGreen;
33 long nBlue;
35 public:
37 inline ImpErrorQuad() {}
38 inline ImpErrorQuad( const BitmapColor& rColor ) :
39 nRed ( (long) rColor.GetRed() << 5L ),
40 nGreen ( (long) rColor.GetGreen() << 5L ),
41 nBlue ( (long) rColor.GetBlue() << 5L ) {}
43 inline void operator=( const BitmapColor& rColor );
44 inline ImpErrorQuad& operator-=( const BitmapColor& rColor );
46 inline void ImplAddColorError1( const ImpErrorQuad& rErrQuad );
47 inline void ImplAddColorError3( const ImpErrorQuad& rErrQuad );
48 inline void ImplAddColorError5( const ImpErrorQuad& rErrQuad );
49 inline void ImplAddColorError7( const ImpErrorQuad& rErrQuad );
51 inline BitmapColor ImplGetColor();
54 // ------------------------------------------------------------------------
56 inline void ImpErrorQuad::operator=( const BitmapColor& rColor )
58 nRed = (long) rColor.GetRed() << 5L;
59 nGreen = (long) rColor.GetGreen() << 5L;
60 nBlue = (long) rColor.GetBlue() << 5L;
63 // ------------------------------------------------------------------------
65 inline ImpErrorQuad& ImpErrorQuad::operator-=( const BitmapColor& rColor )
67 nRed -= ( (long) rColor.GetRed() << 5L );
68 nGreen -= ( (long) rColor.GetGreen() << 5L );
69 nBlue -= ( (long) rColor.GetBlue() << 5L );
71 return *this;
74 // ------------------------------------------------------------------------
76 inline void ImpErrorQuad::ImplAddColorError1( const ImpErrorQuad& rErrQuad )
78 nRed += ( rErrQuad.nRed >> 4L );
79 nGreen += ( rErrQuad.nGreen >> 4L );
80 nBlue += ( rErrQuad.nBlue >> 4L );
83 // ------------------------------------------------------------------------
85 inline void ImpErrorQuad::ImplAddColorError3( const ImpErrorQuad& rErrQuad )
87 nRed += ( rErrQuad.nRed * 3L >> 4L );
88 nGreen += ( rErrQuad.nGreen * 3L >> 4L );
89 nBlue += ( rErrQuad.nBlue * 3L >> 4L );
92 // ------------------------------------------------------------------------
94 inline void ImpErrorQuad::ImplAddColorError5( const ImpErrorQuad& rErrQuad )
96 nRed += ( rErrQuad.nRed * 5L >> 4L );
97 nGreen += ( rErrQuad.nGreen * 5L >> 4L );
98 nBlue += ( rErrQuad.nBlue * 5L >> 4L );
101 // ------------------------------------------------------------------------
103 inline void ImpErrorQuad::ImplAddColorError7( const ImpErrorQuad& rErrQuad )
105 nRed += ( rErrQuad.nRed * 7L >> 4L );
106 nGreen += ( rErrQuad.nGreen * 7L >> 4L );
107 nBlue += ( rErrQuad.nBlue *7L >> 4L );
110 // ------------------------------------------------------------------------
112 inline BitmapColor ImpErrorQuad::ImplGetColor()
114 return BitmapColor( (sal_uInt8) ( ( nRed < 0L ? 0L : nRed > 8160L ? 8160L : nRed ) >> 5L ),
115 (sal_uInt8) ( ( nGreen < 0L ? 0L : nGreen > 8160L ? 8160L : nGreen ) >> 5L ),
116 (sal_uInt8) ( ( nBlue < 0L ? 0L : nBlue > 8160L ? 8160L : nBlue ) >> 5L ) );
119 // -------------
120 // - NodeCache -
121 // -------------
123 class ImpNodeCache
125 OctreeNode* pActNode;
127 public:
129 ImpNodeCache( const sal_uLong nInitSize );
130 ~ImpNodeCache();
132 inline OctreeNode* ImplGetFreeNode();
133 inline void ImplReleaseNode( OctreeNode* pNode );
136 // ------------------------------------------------------------------------
138 inline OctreeNode* ImpNodeCache::ImplGetFreeNode()
140 OctreeNode* pNode;
142 if ( !pActNode )
144 pActNode = new NODE;
145 pActNode->pNextInCache = NULL;
148 pNode = pActNode;
149 pActNode = pNode->pNextInCache;
150 memset( pNode, 0, sizeof( NODE ) );
152 return pNode;
155 // ------------------------------------------------------------------------
157 inline void ImpNodeCache::ImplReleaseNode( OctreeNode* pNode )
159 pNode->pNextInCache = pActNode;
160 pActNode = pNode;
163 #endif // _SV_IMPOCT_HXX
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */