aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a05706.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/a05706.html')
-rw-r--r--docs/doxygen/nel/a05706.html459
1 files changed, 459 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a05706.html b/docs/doxygen/nel/a05706.html
new file mode 100644
index 00000000..29b47a66
--- /dev/null
+++ b/docs/doxygen/nel/a05706.html
@@ -0,0 +1,459 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+<title>NeL: fasthls_modifier.cpp Source File</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.3.6 -->
+<div class="qindex"> <form class="search" action="search.php" method="get">
+<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a> | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
+<h1>fasthls_modifier.cpp</h1><a href="a04283.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <span class="comment">/* Copyright, 2000-2002 Nevrax Ltd.</span>
+00008 <span class="comment"> *</span>
+00009 <span class="comment"> * This file is part of NEVRAX NEL.</span>
+00010 <span class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</span>
+00011 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
+00012 <span class="comment"> * the Free Software Foundation; either version 2, or (at your option)</span>
+00013 <span class="comment"> * any later version.</span>
+00014 <span class="comment"></span>
+00015 <span class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</span>
+00016 <span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span>
+00017 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
+00018 <span class="comment"> * General Public License for more details.</span>
+00019 <span class="comment"></span>
+00020 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
+00021 <span class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</span>
+00022 <span class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</span>
+00023 <span class="comment"> * MA 02111-1307, USA.</span>
+00024 <span class="comment"> */</span>
+00025
+00026
+00027 <span class="preprocessor">#include "<a class="code" href="a05015.html">std3d.h</a>"</span>
+00028 <span class="preprocessor">#include "<a class="code" href="a04284.html">3d/fasthls_modifier.h</a>"</span>
+00029 <span class="preprocessor">#include "<a class="code" href="a04278.html">nel/misc/fast_floor.h</a>"</span>
+00030 <span class="preprocessor">#include "<a class="code" href="a04064.html">nel/misc/bitmap.h</a>"</span>
+00031 <span class="preprocessor">#include "<a class="code" href="a05057.html">nel/misc/system_info.h</a>"</span>
+00032 <span class="preprocessor">#include "<a class="code" href="a04003.html">nel/misc/algo.h</a>"</span>
+00033
+00034
+00035 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
+00036 <span class="keyword">using</span> <span class="keyword">namespace </span>NLMISC;
+00037
+00038
+00039 <span class="keyword">namespace </span>NL3D
+00040 {
+00041
+00042 <span class="comment">// ***************************************************************************</span>
+<a name="l00043"></a><a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierv0">00043</a> <a class="code" href="a02513.html">CFastHLSModifier</a> *CFastHLSModifier::_Instance= NULL;
+00044
+00045
+00046 <span class="comment">// ***************************************************************************</span>
+<a name="l00047"></a><a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierd0">00047</a> CFastHLSModifier::CFastHLSModifier()
+00048 {
+00049 <a class="code" href="a04558.html#a15">uint</a> i;
+00050 <span class="comment">// build the HueTable.</span>
+00051 <span class="keywordflow">for</span>(i=0;i&lt;<a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiery0NL3D_1_1CFastHLSModifiery1">HueTableSize</a>;i++)
+00052 {
+00053 <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierr1">_HueTable</a>[i].<a class="code" href="a03337.html#NLMISC_1_1CRGBAz2026_0">buildFromHLS</a>(360.0f*i/HueTableSize, 0.5f, 1);
+00054 }
+00055 <span class="comment">// build conversion from uint16 to HLS.</span>
+00056 <span class="keywordflow">for</span>(i=0;i&lt;65536;i++)
+00057 {
+00058 <a class="code" href="a03337.html">CRGBA</a> col;
+00059 col.<a class="code" href="a03337.html#NLMISC_1_1CRGBAa15">set565</a>(i);
+00060 <span class="keywordtype">float</span> h,l,<a class="code" href="a04223.html#a626">s</a>;
+00061 col.<a class="code" href="a03337.html#NLMISC_1_1CRGBAz2026_1">convertToHLS</a>(h,l,<a class="code" href="a04223.html#a626">s</a>);
+00062 h= (<span class="keywordtype">float</span>)floor(255*(h/360.f)+0.5f);
+00063 l= (<span class="keywordtype">float</span>)floor(255*l+0.5f);
+00064 <a class="code" href="a04223.html#a626">s</a>= (<span class="keywordtype">float</span>)floor(255*<a class="code" href="a04223.html#a626">s</a>+0.5f);
+00065 <a class="code" href="a05378.html#a374">clamp</a>(h,0,255);
+00066 <a class="code" href="a05378.html#a374">clamp</a>(l,0,255);
+00067 <a class="code" href="a05378.html#a374">clamp</a>(<a class="code" href="a04223.html#a626">s</a>,0,255);
+00068 <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierr0">_Color16ToHLS</a>[i].<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo1">H</a>= (<a class="code" href="a04558.html#a7">uint8</a>)h;
+00069 <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierr0">_Color16ToHLS</a>[i].<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo2">L</a>= (<a class="code" href="a04558.html#a7">uint8</a>)l;
+00070 <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierr0">_Color16ToHLS</a>[i].<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo3">S</a>= (<a class="code" href="a04558.html#a7">uint8</a>)<a class="code" href="a04223.html#a626">s</a>;
+00071 <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierr0">_Color16ToHLS</a>[i].<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo0">A</a>= 255;
+00072 }
+00073 }
+00074
+00075
+00076 <span class="comment">// ***************************************************************************</span>
+<a name="l00077"></a><a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiere0">00077</a> <a class="code" href="a02513.html">CFastHLSModifier</a> &amp;CFastHLSModifier::getInstance()
+00078 {
+00079 <span class="keywordflow">if</span>(!<a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierv0">_Instance</a>)
+00080 <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierv0">_Instance</a>= <span class="keyword">new</span> <a class="code" href="a02513.html">CFastHLSModifier</a>;
+00081 <span class="keywordflow">return</span> *<a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierv0">_Instance</a>;
+00082 }
+00083
+00084
+00085 <span class="comment">// ***************************************************************************</span>
+<a name="l00086"></a><a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiera1">00086</a> <a class="code" href="a03337.html">CRGBA</a> CFastHLSModifier::convert(<a class="code" href="a04558.html#a15">uint</a> H, <a class="code" href="a04558.html#a15">uint</a> L, <a class="code" href="a04558.html#a15">uint</a> S)
+00087 {
+00088 <span class="keyword">static</span> <a class="code" href="a03337.html">CRGBA</a> gray(128,128,128);
+00089 L+= L&gt;&gt;7;
+00090 S+= S&gt;&gt;7;
+00091 <span class="comment">// H.</span>
+00092 <a class="code" href="a03337.html">CRGBA</a> col= <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierr1">_HueTable</a>[H];
+00093 <span class="comment">// S.</span>
+00094 col.<a class="code" href="a03337.html#NLMISC_1_1CRGBAz2022_3">blendFromuiRGBOnly</a>(gray, col, S);
+00095 <span class="comment">// L.</span>
+00096 <span class="keywordflow">if</span>(L&lt;=128)
+00097 {
+00098 col.<a class="code" href="a03337.html#NLMISC_1_1CRGBAz2022_5">modulateFromuiRGBOnly</a>(col, L*2);
+00099 }
+00100 <span class="keywordflow">else</span>
+00101 {
+00102 col.<a class="code" href="a03337.html#NLMISC_1_1CRGBAz2022_3">blendFromuiRGBOnly</a>(col, CRGBA::White, (L-128)*2 );
+00103 }
+00104
+00105 <span class="keywordflow">return</span> col;
+00106 }
+00107
+00108
+00109 <span class="comment">// ***************************************************************************</span>
+<a name="l00110"></a><a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiera0">00110</a> <a class="code" href="a04558.html#a9">uint16</a> CFastHLSModifier::applyHLSMod(<a class="code" href="a04558.html#a9">uint16</a> colorIn, <a class="code" href="a04558.html#a7">uint8</a> dHue, <a class="code" href="a04558.html#a15">uint</a> dLum, <a class="code" href="a04558.html#a15">uint</a> dSat)
+00111 {
+00112 <span class="keyword">static</span> <a class="code" href="a04558.html#a13">uint64</a> mmBlank = 0;
+00113 <span class="keyword">static</span> <a class="code" href="a04558.html#a13">uint64</a> mmOne = <a class="code" href="a05167.html#a5">INT64_CONSTANT</a>(0x00FF00FF00FF00FF);
+00114 <span class="keyword">static</span> <a class="code" href="a04558.html#a13">uint64</a> mmGray = <a class="code" href="a05167.html#a5">INT64_CONSTANT</a>(0x0080008000800080);
+00115 <span class="keyword">static</span> <a class="code" href="a04558.html#a13">uint64</a> mmInterpBufer[4]= {0,0,0,<a class="code" href="a05167.html#a5">INT64_CONSTANT</a>(0x00FF00FF00FF00FF)};
+00116
+00117 <span class="comment">/*</span>
+00118 <span class="comment"> dLum is actually 0xFFFFFF00 + realDLum</span>
+00119 <span class="comment"> dSat is actually 0xFFFFFF00 + realDSat</span>
+00120 <span class="comment"> */</span>
+00121
+00122 <a class="code" href="a04558.html#a9">uint16</a> retVal;
+00123
+00124 <span class="preprocessor">#ifdef NL_OS_WINDOWS</span>
+00125 <span class="preprocessor"></span> <span class="keywordflow">if</span>(CSystemInfo::hasMMX())
+00126 {
+00127 __asm
+00128 {
+00129 mov edi, <a class="code" href="a04223.html#a586">offset</a> mmInterpBufer
+00130 mov ecx, <span class="keyword">this</span>
+00131
+00132 <span class="comment">// get HLS in edx.</span>
+00133 mov eax, 0
+00134 mov ebx, 0
+00135 lea esi, [ecx]<span class="keyword">this</span>._Color16ToHLS
+00136 mov ax, colorIn
+00137 mov edx, [esi+ eax*4]
+00138
+00139 <span class="comment">// apply dh to H (ie dl!). Auto-wrap.</span>
+00140 add dl, dHue
+00141 <span class="comment">// get the color into mm0</span>
+00142 mov bl, dl
+00143 lea esi, [ecx]<span class="keyword">this</span>._HueTable
+00144 movd mm0, [esi+ ebx*4]
+00145 punpcklbw mm0, mmBlank
+00146
+00147 <span class="comment">// get L into eax and S into ebx</span>
+00148 mov eax, edx
+00149 mov ebx, edx
+00150 shr eax, 8
+00151 shr ebx, 16
+00152 and eax, 255
+00153 and ebx, 255
+00154 <span class="comment">// add dLum/dSat and clamp to 1.</span>
+00155 add eax, dLum
+00156 sbb ecx, ecx <span class="comment">// ecx= FFFFFFFF if carry.</span>
+00157 add ebx, dSat
+00158 sbb edx, edx
+00159 or eax, ecx <span class="comment">// eax= FFFFFFFF if carry was set</span>
+00160 or ebx, edx
+00161 <span class="comment">// add Magic delta, and clamp to 0.</span>
+00162 add eax, 256
+00163 sbb ecx, ecx <span class="comment">// ecx= 0 if carry not set =&gt; result below 0.</span>
+00164 add ebx, 256
+00165 sbb edx, edx
+00166 and eax, ecx <span class="comment">// eax= 0 if result was below 0</span>
+00167 and ebx, edx
+00168
+00169 <span class="comment">// Load Sat/(1-Sat) into MMX</span>
+00170 movd mm2, ebx
+00171 movq mm3, mmOne
+00172 punpckldq mm2, mm2 <span class="comment">// mm2= 0000 00AA 0000 00AA</span>
+00173 packssdw mm2, mm2 <span class="comment">// mm2= 00AA 00AA 00AA 00AA</span>
+00174 movq mm1, mmGray
+00175 psubusw mm3, mm2 <span class="comment">// mm3= 1-sat.</span>
+00176 <span class="comment">// combine Color and Sat</span>
+00177 pmullw mm0, mm2 <span class="comment">// mm0= color*sat</span>
+00178 pmullw mm1, mm3 <span class="comment">// mm1= gray*(1-sat)</span>
+00179 paddusw mm0, mm1 <span class="comment">// mm0= color saturated</span>
+00180 <span class="comment">// shift and store into the buffer for Luminance interpolation</span>
+00181 psrlw mm0, 8
+00182 movq [edi+ 8], mm0
+00183 movq [edi+ 16], mm0
+00184
+00185 <span class="comment">// use edx as index for luminance: 0: L=0 to 127. 1: L=128 to 255.</span>
+00186 mov edx, eax
+00187 shl eax, 1
+00188 shr edx, 7
+00189 and eax, 255 <span class="comment">// 0-127 and 128-255 transform auto to 0-254</span>
+00190 <span class="comment">// expand 0-254 to 0-255</span>
+00191 mov ecx, eax
+00192 shl edx, 4
+00193 shr ecx, 7
+00194 add eax, ecx
+00195
+00196 <span class="comment">// Combine color and Luminance into MMX. interpolate 0-&gt;col or col-&gt;white according to edx.</span>
+00197 <span class="comment">// Load Lum/(1-Lum) into MMX</span>
+00198 movd mm2, eax
+00199 movq mm3, mmOne
+00200 punpckldq mm2, mm2 <span class="comment">// mm2= 0000 00AA 0000 00AA</span>
+00201 packssdw mm2, mm2 <span class="comment">// mm2= 00AA 00AA 00AA 00AA</span>
+00202 psubusw mm3, mm2 <span class="comment">// mm3= 1-lum.</span>
+00203 <span class="comment">// Combine color and Sat into MMX</span>
+00204 movq mm0, [edi+ edx]
+00205 movq mm1, [edi+ edx + 8]
+00206 pmullw mm0, mm3 <span class="comment">// mm0= color0*(1-lum)</span>
+00207 pmullw mm1, mm2 <span class="comment">// mm1= color1*lum</span>
+00208 paddusw mm0, mm1 <span class="comment">// mm0= final color</span>
+00209
+00210 <span class="comment">// shift and unpack</span>
+00211 psrlw mm0, 8
+00212 packuswb mm0, mm0
+00213 movd eax, mm0
+00214
+00215 <span class="comment">// pack to 16bits.</span>
+00216 mov ebx, eax
+00217 mov ecx, eax
+00218 shl eax, 8 <span class="comment">// Red</span>
+00219 shr ebx, 5 <span class="comment">// Green</span>
+00220 shr ecx, 19 <span class="comment">// Blue</span>
+00221 and eax, 0xF800
+00222 and ebx, 0x07E0
+00223 and ecx, 0x001F
+00224 or eax, ebx
+00225 or eax, ecx
+00226
+00227 mov retVal, ax
+00228 }
+00229 }
+00230 <span class="keywordflow">else</span>
+00231 <span class="preprocessor">#endif // NL_OS_WINDOWS</span>
+00232 <span class="preprocessor"></span> {
+00233 <a class="code" href="a02514.html">CHLSA</a> hls= <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierr0">_Color16ToHLS</a>[colorIn];
+00234 <span class="comment">// apply (C version) Dhue, dLum and dSat</span>
+00235 hls.<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo1">H</a>= (<a class="code" href="a04558.html#a7">uint8</a>)(hls.<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo1">H</a> + dHue);
+00236 <a class="code" href="a04558.html#a14">sint</a> <a class="code" href="a04223.html#a576">v</a>= (<a class="code" href="a04558.html#a14">sint</a>)hls.<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo2">L</a> + (<a class="code" href="a04558.html#a14">sint</a>)(dLum-0xFFFFFF00);
+00237 fastClamp8(<a class="code" href="a04223.html#a576">v</a>);
+00238 hls.<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo2">L</a>= <a class="code" href="a04223.html#a576">v</a>;
+00239 <a class="code" href="a04223.html#a576">v</a>= (<a class="code" href="a04558.html#a14">sint</a>)hls.<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo3">S</a> + (<a class="code" href="a04558.html#a14">sint</a>)(dSat-0xFFFFFF00);
+00240 fastClamp8(<a class="code" href="a04223.html#a576">v</a>);
+00241 hls.<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo3">S</a>= <a class="code" href="a04223.html#a576">v</a>;
+00242
+00243 <a class="code" href="a03337.html">CRGBA</a> ret= <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiera1">convert</a>(hls.<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo1">H</a>, hls.<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo2">L</a>, hls.<a class="code" href="a02514.html#NL3D_1_1CFastHLSModifier_1_1CHLSAo3">S</a>);
+00244 retVal= ret.<a class="code" href="a03337.html#NLMISC_1_1CRGBAa6">get565</a>();
+00245 }
+00246
+00247 <span class="keywordflow">return</span> retVal;
+00248 }
+00249
+00250
+00251 <span class="comment">// ***************************************************************************</span>
+<a name="l00252"></a><a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierd1">00252</a> <span class="keywordtype">void</span> CFastHLSModifier::convertDDSBitmapDXTC1Or1A(<a class="code" href="a02268.html">CBitmap</a> &amp;dst, <span class="keyword">const</span> <a class="code" href="a02268.html">CBitmap</a> &amp;<a class="code" href="a04223.html#a652">src</a>, <a class="code" href="a04558.html#a7">uint8</a> dh, <a class="code" href="a04558.html#a15">uint</a> dLum, <a class="code" href="a04558.html#a15">uint</a> dSat)
+00253 {
+00254 <a class="code" href="a04558.html#a15">uint</a> W= <a class="code" href="a04223.html#a652">src</a>.getWidth();
+00255 <a class="code" href="a04558.html#a15">uint</a> H= <a class="code" href="a04223.html#a652">src</a>.getHeight();
+00256
+00257 <span class="keyword">const</span> <a class="code" href="a04558.html#a7">uint8</a> *srcPix= &amp;(<a class="code" href="a04223.html#a652">src</a>.getPixels()[0]);
+00258 <a class="code" href="a04558.html#a7">uint8</a> *dstPix= &amp;(dst.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]);
+00259 <a class="code" href="a04558.html#a15">uint</a> numBlock= (W*H)/16;
+00260
+00261 <span class="comment">/*</span>
+00262 <span class="comment"> need to swap color and bits for DXTC1 or DXTC1A.</span>
+00263 <span class="comment"> */</span>
+00264
+00265 <span class="keyword">static</span> <a class="code" href="a04558.html#a11">uint32</a> bitLUT[8]= {
+00266 1,0,3,2, <span class="comment">// reverse std order</span>
+00267 1,0,2,3, <span class="comment">// reverse order for "special 0/black packing"</span>
+00268 };
+00269
+00270 <span class="comment">// Do not use alpha mask for now.</span>
+00271 <span class="keywordflow">for</span>(;numBlock&gt;0;numBlock--)
+00272 {
+00273 <a class="code" href="a04558.html#a9">uint16</a> srcCol0= ((<a class="code" href="a04558.html#a9">uint16</a>*)srcPix)[0];
+00274 <a class="code" href="a04558.html#a9">uint16</a> srcCol1= ((<a class="code" href="a04558.html#a9">uint16</a>*)srcPix)[1];
+00275 <span class="keywordtype">bool</span> srcSign= srcCol0&gt;srcCol1;
+00276 <span class="comment">// apply modifiers for 2 colors.</span>
+00277 <a class="code" href="a04558.html#a9">uint16</a> dstCol0= <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiera0">applyHLSMod</a>(srcCol0, dh,dLum,dSat);
+00278 <a class="code" href="a04558.html#a9">uint16</a> dstCol1= <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiera0">applyHLSMod</a>(srcCol1, dh,dLum,dSat);
+00279 <span class="keywordtype">bool</span> dstSign= dstCol0&gt;dstCol1;
+00280 <span class="keywordflow">if</span>((<a class="code" href="a04558.html#a15">uint</a>)dstSign!=(<a class="code" href="a04558.html#a15">uint</a>)srcSign)
+00281 {
+00282 swap(dstCol0,dstCol1);
+00283 <span class="comment">// must change bits too!</span>
+00284 <a class="code" href="a04558.html#a11">uint32</a> srcBits= ((<a class="code" href="a04558.html#a11">uint32</a>*)srcPix)[1];
+00285 <a class="code" href="a04558.html#a11">uint32</a> dstBits= 0;
+00286 <span class="comment">// take correct lut according to original sign</span>
+00287 <a class="code" href="a04558.html#a11">uint32</a> *lut;
+00288 <span class="keywordflow">if</span>(srcCol0&gt;srcCol1)
+00289 lut= bitLUT;
+00290 <span class="keywordflow">else</span>
+00291 lut= bitLUT+4;
+00292
+00293 <span class="comment">// for all bits, transpose with lut.</span>
+00294 <span class="preprocessor">#ifdef NL_OS_WINDOWS</span>
+00295 <span class="preprocessor"></span> __asm
+00296 {
+00297 mov eax, srcBits
+00298 mov esi, lut
+00299 mov edx, 0
+00300 mov ecx, 16
+00301 <span class="comment">// prepare 1st.</span>
+00302 rol eax, 2
+00303 mov ebx, eax
+00304 and ebx, 2
+00305 <span class="comment">// do it 16 times.</span>
+00306 myLoop:
+00307 or edx, [esi+ebx*4]
+00308 rol eax, 2
+00309 rol edx, 2
+00310 mov ebx, eax
+00311 and ebx, 2
+00312 dec ecx
+00313 jnz myLoop
+00314
+00315 ror edx, 2
+00316 mov dstBits, edx
+00317 }
+00318 <span class="preprocessor">#else</span>
+00319 <span class="preprocessor"></span> <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a15">uint</a> n=16;n&gt;0;n--)
+00320 {
+00321 <span class="comment">// transform the id.</span>
+00322 <a class="code" href="a04558.html#a15">uint</a> <span class="keywordtype">id</span>= srcBits&amp;3;
+00323 <span class="keywordtype">id</span>= lut[<span class="keywordtype">id</span>];
+00324 <span class="comment">// write.</span>
+00325 dstBits|= <span class="keywordtype">id</span>&lt;&lt;30;
+00326 <span class="comment">// don't decal last</span>
+00327 <span class="keywordflow">if</span>(n&gt;1)
+00328 dstBits&gt;&gt;=2;
+00329 }
+00330 <span class="preprocessor">#endif</span>
+00331 <span class="preprocessor"></span>
+00332 <span class="comment">// store </span>
+00333 ((<a class="code" href="a04558.html#a11">uint32</a>*)dstPix)[1]= dstBits;
+00334 }
+00335 <span class="keywordflow">else</span>
+00336 <span class="comment">// just copy bits</span>
+00337 ((<a class="code" href="a04558.html#a11">uint32</a>*)dstPix)[1]= ((<a class="code" href="a04558.html#a11">uint32</a>*)srcPix)[3];
+00338 ((<a class="code" href="a04558.html#a9">uint16</a>*)dstPix)[0]= dstCol0;
+00339 ((<a class="code" href="a04558.html#a9">uint16</a>*)dstPix)[1]= dstCol1;
+00340 <span class="comment">// skip.</span>
+00341 srcPix+= 8;
+00342 dstPix+= 8;
+00343 }
+00344
+00345 <span class="comment">// Must end MMX, for applyHLSMod()</span>
+00346 <span class="preprocessor">#ifdef NL_OS_WINDOWS</span>
+00347 <span class="preprocessor"></span> <span class="keywordflow">if</span>(CSystemInfo::hasMMX())
+00348 _asm emms;
+00349 <span class="preprocessor">#endif</span>
+00350 <span class="preprocessor"></span>
+00351 }
+00352
+00353 <span class="comment">// ***************************************************************************</span>
+<a name="l00354"></a><a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierd2">00354</a> <span class="keywordtype">void</span> CFastHLSModifier::convertDDSBitmapDXTC3Or5(<a class="code" href="a02268.html">CBitmap</a> &amp;dst, <span class="keyword">const</span> <a class="code" href="a02268.html">CBitmap</a> &amp;<a class="code" href="a04223.html#a652">src</a>, <a class="code" href="a04558.html#a7">uint8</a> dh, <a class="code" href="a04558.html#a15">uint</a> dLum, <a class="code" href="a04558.html#a15">uint</a> dSat)
+00355 {
+00356 <a class="code" href="a04558.html#a15">uint</a> W= <a class="code" href="a04223.html#a652">src</a>.getWidth();
+00357 <a class="code" href="a04558.html#a15">uint</a> H= <a class="code" href="a04223.html#a652">src</a>.getHeight();
+00358
+00359 <span class="keyword">const</span> <a class="code" href="a04558.html#a7">uint8</a> *srcPix= &amp;(<a class="code" href="a04223.html#a652">src</a>.getPixels()[0]);
+00360 <a class="code" href="a04558.html#a7">uint8</a> *dstPix= &amp;(dst.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]);
+00361 <a class="code" href="a04558.html#a15">uint</a> numBlock= (W*H)/16;
+00362
+00363 <span class="comment">/*</span>
+00364 <span class="comment"> NB: don't need to swap color and bits for DXTC3 or DXTC5.</span>
+00365 <span class="comment"> */</span>
+00366
+00367 <span class="comment">// Do not use alpha mask for now.</span>
+00368 <span class="keywordflow">for</span>(;numBlock&gt;0;numBlock--)
+00369 {
+00370 <a class="code" href="a04558.html#a9">uint16</a> srcCol0= ((<a class="code" href="a04558.html#a9">uint16</a>*)srcPix)[4];
+00371 <a class="code" href="a04558.html#a9">uint16</a> srcCol1= ((<a class="code" href="a04558.html#a9">uint16</a>*)srcPix)[5];
+00372 <span class="comment">// apply modifiers for 2 colors.</span>
+00373 ((<a class="code" href="a04558.html#a9">uint16</a>*)dstPix)[4]= <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiera0">applyHLSMod</a>(srcCol0, dh,dLum,dSat);
+00374 ((<a class="code" href="a04558.html#a9">uint16</a>*)dstPix)[5]= <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiera0">applyHLSMod</a>(srcCol1, dh,dLum,dSat);
+00375 <span class="comment">// just copy bits</span>
+00376 ((<a class="code" href="a04558.html#a11">uint32</a>*)dstPix)[3]= ((<a class="code" href="a04558.html#a11">uint32</a>*)srcPix)[3];
+00377 <span class="comment">// copy alpha part.</span>
+00378 ((<a class="code" href="a04558.html#a11">uint32</a>*)dstPix)[0]= ((<a class="code" href="a04558.html#a11">uint32</a>*)srcPix)[0];
+00379 ((<a class="code" href="a04558.html#a11">uint32</a>*)dstPix)[1]= ((<a class="code" href="a04558.html#a11">uint32</a>*)srcPix)[1];
+00380 <span class="comment">// skip bits and alpha part.</span>
+00381 srcPix+= 16;
+00382 dstPix+= 16;
+00383 }
+00384
+00385 <span class="comment">// Must end MMX, for applyHLSMod()</span>
+00386 <span class="preprocessor">#ifdef NL_OS_WINDOWS</span>
+00387 <span class="preprocessor"></span> <span class="keywordflow">if</span>(CSystemInfo::hasMMX())
+00388 _asm emms;
+00389 <span class="preprocessor">#endif</span>
+00390 <span class="preprocessor"></span>}
+00391
+00392 <span class="comment">// ***************************************************************************</span>
+<a name="l00393"></a><a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiera2">00393</a> <span class="keywordtype">void</span> CFastHLSModifier::convertDDSBitmap(<a class="code" href="a02268.html">CBitmap</a> &amp;dst, <span class="keyword">const</span> <a class="code" href="a02268.html">CBitmap</a> &amp;<a class="code" href="a04223.html#a652">src</a>, <a class="code" href="a04558.html#a7">uint8</a> dh, <a class="code" href="a04558.html#a14">sint</a> dl, <a class="code" href="a04558.html#a14">sint</a> ds)
+00394 {
+00395 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a652">src</a>.getPixelFormat()==dst.<a class="code" href="a02268.html#NL3D_1_1ITexturea15">getPixelFormat</a>());
+00396 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a652">src</a>.getWidth()==dst.<a class="code" href="a02268.html#NL3D_1_1ITexturea20">getWidth</a>() &amp;&amp; <a class="code" href="a04223.html#a652">src</a>.getHeight()==dst.<a class="code" href="a02268.html#NL3D_1_1ITexturea12">getHeight</a>());
+00397
+00398 <span class="comment">// Magic add clamp.</span>
+00399 <a class="code" href="a04558.html#a15">uint</a> dLum= 0xFFFFFF00 + dl;
+00400 <a class="code" href="a04558.html#a15">uint</a> dSat= 0xFFFFFF00 + ds;
+00401
+00402 <span class="keywordflow">if</span>(<a class="code" href="a04223.html#a652">src</a>.getPixelFormat()==CBitmap::DXTC1 || <a class="code" href="a04223.html#a652">src</a>.getPixelFormat()==CBitmap::DXTC1Alpha)
+00403 <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierd1">convertDDSBitmapDXTC1Or1A</a>(dst, <a class="code" href="a04223.html#a652">src</a>, dh, dLum, dSat);
+00404 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="a04223.html#a652">src</a>.getPixelFormat()==CBitmap::DXTC3 || <a class="code" href="a04223.html#a652">src</a>.getPixelFormat()==CBitmap::DXTC5)
+00405 <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifierd2">convertDDSBitmapDXTC3Or5</a>(dst, <a class="code" href="a04223.html#a652">src</a>, dh, dLum, dSat);
+00406 <span class="keywordflow">else</span>
+00407 {
+00408 <a class="code" href="a04199.html#a12">nlstop</a>;
+00409 }
+00410 }
+00411
+00412
+00413 <span class="comment">// ***************************************************************************</span>
+<a name="l00414"></a><a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiera3">00414</a> <span class="keywordtype">void</span> CFastHLSModifier::convertRGBABitmap(<a class="code" href="a02268.html">CBitmap</a> &amp;dst, <span class="keyword">const</span> <a class="code" href="a02268.html">CBitmap</a> &amp;<a class="code" href="a04223.html#a652">src</a>, <a class="code" href="a04558.html#a7">uint8</a> dh, <a class="code" href="a04558.html#a14">sint</a> dl, <a class="code" href="a04558.html#a14">sint</a> ds)
+00415 {
+00416 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a652">src</a>.getPixelFormat()==dst.<a class="code" href="a02268.html#NL3D_1_1ITexturea15">getPixelFormat</a>());
+00417 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a652">src</a>.getPixelFormat()==CBitmap::RGBA);
+00418
+00419 <a class="code" href="a04558.html#a15">uint</a> W= <a class="code" href="a04223.html#a652">src</a>.getWidth();
+00420 <a class="code" href="a04558.html#a15">uint</a> H= <a class="code" href="a04223.html#a652">src</a>.getHeight();
+00421
+00422 <span class="keyword">const</span> <a class="code" href="a03337.html">CRGBA</a> *srcPix= (<span class="keyword">const</span> <a class="code" href="a03337.html">CRGBA</a>*)&amp;(<a class="code" href="a04223.html#a652">src</a>.getPixels()[0]);
+00423 <a class="code" href="a03337.html">CRGBA</a> *dstPix= (<a class="code" href="a03337.html">CRGBA</a>*)&amp;(dst.<a class="code" href="a02268.html#NL3D_1_1ITexturez1927_1">getPixels</a>()[0]);
+00424 <a class="code" href="a04558.html#a15">uint</a> numPix= W*H;
+00425
+00426 <span class="comment">// Do not use alpha mask for now.</span>
+00427 <span class="keywordflow">for</span>(;numPix&gt;0;numPix--)
+00428 {
+00429 <span class="keywordtype">float</span> H,L,S;
+00430 srcPix-&gt;<a class="code" href="a03337.html#NLMISC_1_1CRGBAz2026_1">convertToHLS</a>(H,L,S);
+00431 H*= 256.f/360.f;
+00432 L*= 255.f;
+00433 S*= 255.f;
+00434 H+= dh+0.5f;
+00435 L+= dl+0.5f;
+00436 S+= ds+0.5f;
+00437 <a class="code" href="a05378.html#a374">clamp</a>(H, 0, 255);
+00438 <a class="code" href="a05378.html#a374">clamp</a>(L, 0, 255);
+00439 <a class="code" href="a05378.html#a374">clamp</a>(S, 0, 255);
+00440 <a class="code" href="a04558.html#a7">uint8</a> H8= (<a class="code" href="a04558.html#a7">uint8</a>)<a class="code" href="a05378.html#a397">NLMISC::OptFastFloor</a>(H);
+00441 <a class="code" href="a04558.html#a7">uint8</a> L8= (<a class="code" href="a04558.html#a7">uint8</a>)<a class="code" href="a05378.html#a397">NLMISC::OptFastFloor</a>(L);
+00442 <a class="code" href="a04558.html#a7">uint8</a> S8= (<a class="code" href="a04558.html#a7">uint8</a>)<a class="code" href="a05378.html#a397">NLMISC::OptFastFloor</a>(S);
+00443 *dstPix= <a class="code" href="a02513.html#NL3D_1_1CFastHLSModifiera1">convert</a>(H8, L8, S8);
+00444 srcPix++;
+00445 dstPix++;
+00446 }
+00447 }
+00448
+00449
+00450 } <span class="comment">// NL3D</span>
+</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 06:24:57 2004 for NeL by
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
+</a>1.3.6 </small></address>
+</body>
+</html>