Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / vcl / inc / impoct.hxx
blob4183fc7fb5bc6156ec869bc25dccef97222ede71
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_IMPOCT_HXX
21 #define INCLUDED_VCL_INC_IMPOCT_HXX
23 #include "octree.hxx"
25 // - ImpErrorQuad -
27 class ImpErrorQuad
29 long nRed;
30 long nGreen;
31 long nBlue;
33 public:
35 ImpErrorQuad()
36 : nRed(0)
37 , nGreen(0)
38 , nBlue(0)
42 ImpErrorQuad( const BitmapColor& rColor )
43 : nRed( (long) rColor.GetRed() << 5L )
44 , nGreen( (long) rColor.GetGreen() << 5L )
45 , nBlue( (long) rColor.GetBlue() << 5L )
49 inline void operator=( const BitmapColor& rColor );
50 inline ImpErrorQuad& operator-=( const BitmapColor& rColor );
52 inline void ImplAddColorError1( const ImpErrorQuad& rErrQuad );
53 inline void ImplAddColorError3( const ImpErrorQuad& rErrQuad );
54 inline void ImplAddColorError5( const ImpErrorQuad& rErrQuad );
55 inline void ImplAddColorError7( const ImpErrorQuad& rErrQuad );
57 inline BitmapColor ImplGetColor();
60 inline void ImpErrorQuad::operator=( const BitmapColor& rColor )
62 nRed = (long) rColor.GetRed() << 5L;
63 nGreen = (long) rColor.GetGreen() << 5L;
64 nBlue = (long) rColor.GetBlue() << 5L;
67 inline ImpErrorQuad& ImpErrorQuad::operator-=( const BitmapColor& rColor )
69 nRed -= ( (long) rColor.GetRed() << 5L );
70 nGreen -= ( (long) rColor.GetGreen() << 5L );
71 nBlue -= ( (long) rColor.GetBlue() << 5L );
73 return *this;
76 inline void ImpErrorQuad::ImplAddColorError1( const ImpErrorQuad& rErrQuad )
78 nRed += ( rErrQuad.nRed >> 4L );
79 nGreen += ( rErrQuad.nGreen >> 4L );
80 nBlue += ( rErrQuad.nBlue >> 4L );
83 inline void ImpErrorQuad::ImplAddColorError3( const ImpErrorQuad& rErrQuad )
85 nRed += ( rErrQuad.nRed * 3L >> 4L );
86 nGreen += ( rErrQuad.nGreen * 3L >> 4L );
87 nBlue += ( rErrQuad.nBlue * 3L >> 4L );
90 inline void ImpErrorQuad::ImplAddColorError5( const ImpErrorQuad& rErrQuad )
92 nRed += ( rErrQuad.nRed * 5L >> 4L );
93 nGreen += ( rErrQuad.nGreen * 5L >> 4L );
94 nBlue += ( rErrQuad.nBlue * 5L >> 4L );
97 inline void ImpErrorQuad::ImplAddColorError7( const ImpErrorQuad& rErrQuad )
99 nRed += ( rErrQuad.nRed * 7L >> 4L );
100 nGreen += ( rErrQuad.nGreen * 7L >> 4L );
101 nBlue += ( rErrQuad.nBlue *7L >> 4L );
104 inline BitmapColor ImpErrorQuad::ImplGetColor()
106 return BitmapColor( (sal_uInt8) ( ( nRed < 0L ? 0L : nRed > 8160L ? 8160L : nRed ) >> 5L ),
107 (sal_uInt8) ( ( nGreen < 0L ? 0L : nGreen > 8160L ? 8160L : nGreen ) >> 5L ),
108 (sal_uInt8) ( ( nBlue < 0L ? 0L : nBlue > 8160L ? 8160L : nBlue ) >> 5L ) );
111 // - NodeCache -
113 class ImpNodeCache
115 OctreeNode* pActNode;
117 public:
119 ImpNodeCache( const sal_uLong nInitSize );
120 ~ImpNodeCache();
122 inline OctreeNode* ImplGetFreeNode();
123 inline void ImplReleaseNode( OctreeNode* pNode );
126 inline OctreeNode* ImpNodeCache::ImplGetFreeNode()
128 OctreeNode* pNode;
130 if ( !pActNode )
132 pActNode = new NODE;
133 pActNode->pNextInCache = NULL;
136 pNode = pActNode;
137 pActNode = pNode->pNextInCache;
138 memset( pNode, 0, sizeof( NODE ) );
140 return pNode;
143 inline void ImpNodeCache::ImplReleaseNode( OctreeNode* pNode )
145 pNode->pNextInCache = pActNode;
146 pActNode = pNode;
149 #endif // INCLUDED_VCL_INC_IMPOCT_HXX
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */