aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/fasthls__modifier_8cpp-source.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/fasthls__modifier_8cpp-source.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to '')
-rw-r--r--docs/doxygen/nel/fasthls__modifier_8cpp-source.html519
1 files changed, 519 insertions, 0 deletions
diff --git a/docs/doxygen/nel/fasthls__modifier_8cpp-source.html b/docs/doxygen/nel/fasthls__modifier_8cpp-source.html
new file mode 100644
index 00000000..0dd1acfd
--- /dev/null
+++ b/docs/doxygen/nel/fasthls__modifier_8cpp-source.html
@@ -0,0 +1,519 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>fasthls_modifier.cpp</h1><a href="fasthls__modifier_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2000-2002 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026
+00027 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
+00028 <font class="preprocessor">#include "<a class="code" href="fasthls__modifier_8h.html">3d/fasthls_modifier.h</a>"</font>
+00029 <font class="preprocessor">#include "<a class="code" href="fast__floor_8h.html">3d/fast_floor.h</a>"</font>
+00030 <font class="preprocessor">#include "<a class="code" href="bitmap_8h.html">nel/misc/bitmap.h</a>"</font>
+00031 <font class="preprocessor">#include "<a class="code" href="system__info_8h.html">nel/misc/system_info.h</a>"</font>
+00032 <font class="preprocessor">#include "<a class="code" href="algo_8h.html">nel/misc/algo.h</a>"</font>
+00033
+00034
+00035 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00036 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00037
+00038
+00039 <font class="keyword">namespace </font>NL3D
+00040 {
+00041
+00042 <font class="comment">// ***************************************************************************</font>
+<a name="l00043"></a><a class="code" href="classNL3D_1_1CFastHLSModifier.html#r0">00043</a> CFastHLSModifier *CFastHLSModifier::_Instance= NULL;
+00044
+00045
+00046 <font class="comment">// ***************************************************************************</font>
+<a name="l00047"></a><a class="code" href="classNL3D_1_1CFastHLSModifier.html#c0">00047</a> CFastHLSModifier::CFastHLSModifier()
+00048 {
+00049 uint i;
+00050 <font class="comment">// build the HueTable.</font>
+00051 <font class="keywordflow">for</font>(i=0;i&lt;<a class="code" href="classNL3D_1_1CFastHLSModifier.html#u1u0">HueTableSize</a>;i++)
+00052 {
+00053 <a class="code" href="classNL3D_1_1CFastHLSModifier.html#o0">_HueTable</a>[i].buildFromHLS(360.0f*i/<a class="code" href="classNL3D_1_1CFastHLSModifier.html#u1u0">HueTableSize</a>, 0.5f, 1);
+00054 }
+00055 <font class="comment">// build conversion from uint16 to HLS.</font>
+00056 <font class="keywordflow">for</font>(i=0;i&lt;65536;i++)
+00057 {
+00058 CRGBA col;
+00059 col.set565(i);
+00060 <font class="keywordtype">float</font> h,<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00061 col.convertToHLS(h,<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>);
+00062 h= (float)floor(255*(h/360.f)+0.5f);
+00063 <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>= (float)floor(255*<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>+0.5f);
+00064 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>= (float)floor(255*<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>+0.5f);
+00065 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(h,0,255);
+00066 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>,0,255);
+00067 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>,0,255);
+00068 <a class="code" href="classNL3D_1_1CFastHLSModifier.html#o1">_Color16ToHLS</a>[i].<a class="code" href="structNL3D_1_1CFastHLSModifier_1_1CHLSA.html#m0">H</a>= (uint8)h;
+00069 <a class="code" href="classNL3D_1_1CFastHLSModifier.html#o1">_Color16ToHLS</a>[i].<a class="code" href="structNL3D_1_1CFastHLSModifier_1_1CHLSA.html#m1">L</a>= (uint8)<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>;
+00070 <a class="code" href="classNL3D_1_1CFastHLSModifier.html#o1">_Color16ToHLS</a>[i].<a class="code" href="structNL3D_1_1CFastHLSModifier_1_1CHLSA.html#m2">S</a>= (uint8)<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00071 <a class="code" href="classNL3D_1_1CFastHLSModifier.html#o1">_Color16ToHLS</a>[i].<a class="code" href="structNL3D_1_1CFastHLSModifier_1_1CHLSA.html#m3">A</a>= 255;
+00072 }
+00073 }
+00074
+00075
+00076 <font class="comment">// ***************************************************************************</font>
+<a name="l00077"></a><a class="code" href="classNL3D_1_1CFastHLSModifier.html#d0">00077</a> CFastHLSModifier &amp;CFastHLSModifier::getInstance()
+00078 {
+00079 <font class="keywordflow">if</font>(!<a class="code" href="classNL3D_1_1CFastHLSModifier.html#r0">_Instance</a>)
+00080 <a class="code" href="classNL3D_1_1CFastHLSModifier.html#r0">_Instance</a>= <font class="keyword">new</font> <a class="code" href="classNL3D_1_1CFastHLSModifier.html#c0">CFastHLSModifier</a>;
+00081 <font class="keywordflow">return</font> *<a class="code" href="classNL3D_1_1CFastHLSModifier.html#r0">_Instance</a>;
+00082 }
+00083
+00084
+00085 <font class="comment">// ***************************************************************************</font>
+<a name="l00086"></a><a class="code" href="classNL3D_1_1CFastHLSModifier.html#a0">00086</a> CRGBA CFastHLSModifier::convert(uint H, uint L, uint S)
+00087 {
+00088 <font class="keyword">static</font> CRGBA gray(128,128,128);
+00089 L+= L&gt;&gt;7;
+00090 S+= S&gt;&gt;7;
+00091 <font class="comment">// H.</font>
+00092 CRGBA col= <a class="code" href="classNL3D_1_1CFastHLSModifier.html#o0">_HueTable</a>[H];
+00093 <font class="comment">// S.</font>
+00094 col.blendFromuiRGBOnly(gray, col, S);
+00095 <font class="comment">// L.</font>
+00096 <font class="keywordflow">if</font>(L&lt;=128)
+00097 {
+00098 col.modulateFromuiRGBOnly(col, L*2);
+00099 }
+00100 <font class="keywordflow">else</font>
+00101 {
+00102 col.blendFromuiRGBOnly(col, CRGBA::White, (L-128)*2 );
+00103 }
+00104
+00105 <font class="keywordflow">return</font> col;
+00106 }
+00107
+00108
+00109 <font class="comment">// ***************************************************************************</font>
+<a name="l00110"></a><a class="code" href="classNL3D_1_1CFastHLSModifier.html#a3">00110</a> uint16 CFastHLSModifier::applyHLSMod(uint16 colorIn, uint8 dHue, uint dLum, uint dSat)
+00111 {
+00112 <font class="keyword">static</font> uint64 mmBlank = 0;
+00113 <font class="keyword">static</font> uint64 mmOne = 0x00FF00FF00FF00FF;
+00114 <font class="keyword">static</font> uint64 mmGray = 0x0080008000800080;
+00115 <font class="keyword">static</font> uint64 mmInterpBufer[4]= {0,0,0,0x00FF00FF00FF00FF};
+00116
+00117 <font class="comment">/*</font>
+00118 <font class="comment"> dLum is actually 0xFFFFFF00 + realDLum</font>
+00119 <font class="comment"> dSat is actually 0xFFFFFF00 + realDSat</font>
+00120 <font class="comment"> */</font>
+00121
+00122 uint16 retVal;
+00123
+00124 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00125 <font class="preprocessor"></font> <font class="keywordflow">if</font>(CSystemInfo::hasMMX())
+00126 {
+00127 __asm
+00128 {
+00129 mov edi, <a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> mmInterpBufer
+00130 mov ecx, <font class="keyword">this</font>
+00131
+00132 <font class="comment">// get HLS in edx.</font>
+00133 mov eax, 0
+00134 mov ebx, 0
+00135 lea esi, [ecx]<font class="keyword">this</font>._Color16ToHLS
+00136 mov ax, colorIn
+00137 mov edx, [esi+ eax*4]
+00138
+00139 <font class="comment">// apply dh to H (ie dl!). Auto-wrap.</font>
+00140 add dl, dHue
+00141 <font class="comment">// get the color into mm0</font>
+00142 mov bl, dl
+00143 lea esi, [ecx]<font class="keyword">this</font>._HueTable
+00144 movd mm0, [esi+ ebx*4]
+00145 punpcklbw mm0, mmBlank
+00146
+00147 <font class="comment">// get L into eax and S into ebx</font>
+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 <font class="comment">// add dLum/dSat and clamp to 1.</font>
+00155 add eax, dLum
+00156 sbb ecx, ecx <font class="comment">// ecx= FFFFFFFF if carry.</font>
+00157 add ebx, dSat
+00158 sbb edx, edx
+00159 or eax, ecx <font class="comment">// eax= FFFFFFFF if carry was set</font>
+00160 or ebx, edx
+00161 <font class="comment">// add Magic delta, and clamp to 0.</font>
+00162 add eax, 256
+00163 sbb ecx, ecx <font class="comment">// ecx= 0 if carry not set =&gt; result below 0.</font>
+00164 add ebx, 256
+00165 sbb edx, edx
+00166 and eax, ecx <font class="comment">// eax= 0 if result was below 0</font>
+00167 and ebx, edx
+00168
+00169 <font class="comment">// Load Sat/(1-Sat) into MMX</font>
+00170 movd mm2, ebx
+00171 movq mm3, mmOne
+00172 punpckldq mm2, mm2 <font class="comment">// mm2= 0000 00AA 0000 00AA</font>
+00173 packssdw mm2, mm2 <font class="comment">// mm2= 00AA 00AA 00AA 00AA</font>
+00174 movq mm1, mmGray
+00175 psubusw mm3, mm2 <font class="comment">// mm3= 1-sat.</font>
+00176 <font class="comment">// combine Color and Sat</font>
+00177 pmullw mm0, mm2 <font class="comment">// mm0= color*sat</font>
+00178 pmullw mm1, mm3 <font class="comment">// mm1= gray*(1-sat)</font>
+00179 paddusw mm0, mm1 <font class="comment">// mm0= color saturated</font>
+00180 <font class="comment">// shift and store into the buffer for Luminance interpolation</font>
+00181 psrlw mm0, 8
+00182 movq [edi+ 8], mm0
+00183 movq [edi+ 16], mm0
+00184
+00185 <font class="comment">// use edx as index for luminance: 0: L=0 to 127. 1: L=128 to 255.</font>
+00186 mov edx, eax
+00187 shl eax, 1
+00188 shr edx, 7
+00189 and eax, 255 <font class="comment">// 0-127 and 128-255 transform auto to 0-254</font>
+00190 <font class="comment">// expand 0-254 to 0-255</font>
+00191 mov ecx, eax
+00192 shl edx, 4
+00193 shr ecx, 7
+00194 add eax, ecx
+00195
+00196 <font class="comment">// Combine color and Luminance into MMX. interpolate 0-&gt;col or col-&gt;white according to edx.</font>
+00197 <font class="comment">// Load Lum/(1-Lum) into MMX</font>
+00198 movd mm2, eax
+00199 movq mm3, mmOne
+00200 punpckldq mm2, mm2 <font class="comment">// mm2= 0000 00AA 0000 00AA</font>
+00201 packssdw mm2, mm2 <font class="comment">// mm2= 00AA 00AA 00AA 00AA</font>
+00202 psubusw mm3, mm2 <font class="comment">// mm3= 1-lum.</font>
+00203 <font class="comment">// Combine color and Sat into MMX</font>
+00204 movq mm0, [edi+ edx]
+00205 movq mm1, [edi+ edx + 8]
+00206 pmullw mm0, mm3 <font class="comment">// mm0= color0*(1-lum)</font>
+00207 pmullw mm1, mm2 <font class="comment">// mm1= color1*lum</font>
+00208 paddusw mm0, mm1 <font class="comment">// mm0= final color</font>
+00209
+00210 <font class="comment">// shift and unpack</font>
+00211 psrlw mm0, 8
+00212 packuswb mm0, mm0
+00213 movd eax, mm0
+00214
+00215 <font class="comment">// pack to 16bits.</font>
+00216 mov ebx, eax
+00217 mov ecx, eax
+00218 shl eax, 8 <font class="comment">// Red</font>
+00219 shr ebx, 5 <font class="comment">// Green</font>
+00220 shr ecx, 19 <font class="comment">// Blue</font>
+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 <font class="keywordflow">else</font>
+00231 <font class="preprocessor">#endif // NL_OS_WINDOWS</font>
+00232 <font class="preprocessor"></font> {
+00233 CHLSA hls= <a class="code" href="classNL3D_1_1CFastHLSModifier.html#o1">_Color16ToHLS</a>[colorIn];
+00234 <font class="comment">// apply (C version) Dhue, dLum and dSat</font>
+00235 hls.<a class="code" href="structNL3D_1_1CFastHLSModifier_1_1CHLSA.html#m0">H</a>= (uint8)(hls.H + dHue);
+00236 sint <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (sint)hls.L + (sint)(dLum-0xFFFFFF00);
+00237 fastClamp8(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
+00238 hls.L= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+00239 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>= (sint)hls.S + (sint)(dSat-0xFFFFFF00);
+00240 fastClamp8(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
+00241 hls.S= <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
+00242
+00243 CRGBA ret= <a class="code" href="classNL3D_1_1CFastHLSModifier.html#a0">convert</a>(hls.H, hls.L, hls.S);
+00244 retVal= ret.get565();
+00245 }
+00246
+00247 <font class="keywordflow">return</font> retVal;
+00248 }
+00249
+00250
+00251 <font class="comment">// ***************************************************************************</font>
+<a name="l00252"></a><a class="code" href="classNL3D_1_1CFastHLSModifier.html#c1">00252</a> <font class="keywordtype">void</font> CFastHLSModifier::convertDDSBitmapDXTC1Or1A(CBitmap &amp;dst, <font class="keyword">const</font> CBitmap &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, uint8 dh, uint dLum, uint dSat)
+00253 {
+00254 uint W= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getWidth();
+00255 uint H= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getHeight();
+00256
+00257 <font class="keyword">const</font> uint8 *srcPix= &amp;(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getPixels()[0]);
+00258 uint8 *dstPix= &amp;(dst.getPixels()[0]);
+00259 uint numBlock= (W*H)/16;
+00260
+00261 <font class="comment">/*</font>
+00262 <font class="comment"> need to swap color and bits for DXTC1 or DXTC1A.</font>
+00263 <font class="comment"> */</font>
+00264
+00265 <font class="keyword">static</font> uint32 bitLUT[8]= {
+00266 1,0,3,2, <font class="comment">// reverse std order</font>
+00267 1,0,2,3, <font class="comment">// reverse order for "special 0/black packing"</font>
+00268 };
+00269
+00270 <font class="comment">// Do not use alpha mask for now.</font>
+00271 <font class="keywordflow">for</font>(;numBlock&gt;0;numBlock--)
+00272 {
+00273 uint16 srcCol0= ((uint16*)srcPix)[0];
+00274 uint16 srcCol1= ((uint16*)srcPix)[1];
+00275 <font class="keywordtype">bool</font> srcSign= srcCol0&gt;srcCol1;
+00276 <font class="comment">// apply modifiers for 2 colors.</font>
+00277 uint16 dstCol0= <a class="code" href="classNL3D_1_1CFastHLSModifier.html#a3">applyHLSMod</a>(srcCol0, dh,dLum,dSat);
+00278 uint16 dstCol1= <a class="code" href="classNL3D_1_1CFastHLSModifier.html#a3">applyHLSMod</a>(srcCol1, dh,dLum,dSat);
+00279 <font class="keywordtype">bool</font> dstSign= dstCol0&gt;dstCol1;
+00280 <font class="keywordflow">if</font>((uint)dstSign!=(uint)srcSign)
+00281 {
+00282 swap(dstCol0,dstCol1);
+00283 <font class="comment">// must change bits too!</font>
+00284 uint32 srcBits= ((uint32*)srcPix)[1];
+00285 uint32 dstBits= 0;
+00286 <font class="comment">// take correct lut according to original sign</font>
+00287 uint32 *lut;
+00288 <font class="keywordflow">if</font>(srcCol0&gt;srcCol1)
+00289 lut= bitLUT;
+00290 <font class="keywordflow">else</font>
+00291 lut= bitLUT+4;
+00292
+00293 <font class="comment">// for all bits, transpose with lut.</font>
+00294 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00295 <font class="preprocessor"></font> __asm
+00296 {
+00297 mov eax, srcBits
+00298 mov esi, lut
+00299 mov edx, 0
+00300 mov ecx, 16
+00301 <font class="comment">// prepare 1st.</font>
+00302 rol eax, 2
+00303 mov ebx, eax
+00304 and ebx, 2
+00305 <font class="comment">// do it 16 times.</font>
+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 <font class="preprocessor">#else</font>
+00319 <font class="preprocessor"></font> <font class="keywordflow">for</font>(uint n=16;n&gt;0;n--)
+00320 {
+00321 <font class="comment">// transform the id.</font>
+00322 uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= srcBits&amp;3;
+00323 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>= lut[<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>];
+00324 <font class="comment">// write.</font>
+00325 dstBits|= <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>&lt;&lt;30;
+00326 <font class="comment">// don't decal last</font>
+00327 <font class="keywordflow">if</font>(n&gt;1)
+00328 dstBits&gt;&gt;=2;
+00329 }
+00330 <font class="preprocessor">#endif</font>
+00331 <font class="preprocessor"></font>
+00332 <font class="comment">// store </font>
+00333 ((uint32*)dstPix)[1]= dstBits;
+00334 }
+00335 <font class="keywordflow">else</font>
+00336 <font class="comment">// just copy bits</font>
+00337 ((uint32*)dstPix)[1]= ((uint32*)srcPix)[3];
+00338 ((uint16*)dstPix)[0]= dstCol0;
+00339 ((uint16*)dstPix)[1]= dstCol1;
+00340 <font class="comment">// skip.</font>
+00341 srcPix+= 8;
+00342 dstPix+= 8;
+00343 }
+00344
+00345 <font class="comment">// Must end MMX, for applyHLSMod()</font>
+00346 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00347 <font class="preprocessor"></font> <font class="keywordflow">if</font>(CSystemInfo::hasMMX())
+00348 _asm emms;
+00349 <font class="preprocessor">#endif</font>
+00350 <font class="preprocessor"></font>
+00351 }
+00352
+00353 <font class="comment">// ***************************************************************************</font>
+<a name="l00354"></a><a class="code" href="classNL3D_1_1CFastHLSModifier.html#c2">00354</a> <font class="keywordtype">void</font> CFastHLSModifier::convertDDSBitmapDXTC3Or5(CBitmap &amp;dst, <font class="keyword">const</font> CBitmap &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, uint8 dh, uint dLum, uint dSat)
+00355 {
+00356 uint W= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getWidth();
+00357 uint H= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getHeight();
+00358
+00359 <font class="keyword">const</font> uint8 *srcPix= &amp;(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getPixels()[0]);
+00360 uint8 *dstPix= &amp;(dst.getPixels()[0]);
+00361 uint numBlock= (W*H)/16;
+00362
+00363 <font class="comment">/*</font>
+00364 <font class="comment"> NB: don't need to swap color and bits for DXTC3 or DXTC5.</font>
+00365 <font class="comment"> */</font>
+00366
+00367 <font class="comment">// Do not use alpha mask for now.</font>
+00368 <font class="keywordflow">for</font>(;numBlock&gt;0;numBlock--)
+00369 {
+00370 uint16 srcCol0= ((uint16*)srcPix)[4];
+00371 uint16 srcCol1= ((uint16*)srcPix)[5];
+00372 <font class="comment">// apply modifiers for 2 colors.</font>
+00373 ((uint16*)dstPix)[4]= <a class="code" href="classNL3D_1_1CFastHLSModifier.html#a3">applyHLSMod</a>(srcCol0, dh,dLum,dSat);
+00374 ((uint16*)dstPix)[5]= <a class="code" href="classNL3D_1_1CFastHLSModifier.html#a3">applyHLSMod</a>(srcCol1, dh,dLum,dSat);
+00375 <font class="comment">// just copy bits</font>
+00376 ((uint32*)dstPix)[3]= ((uint32*)srcPix)[3];
+00377 <font class="comment">// copy alpha part.</font>
+00378 ((uint32*)dstPix)[0]= ((uint32*)srcPix)[0];
+00379 ((uint32*)dstPix)[1]= ((uint32*)srcPix)[1];
+00380 <font class="comment">// skip bits and alpha part.</font>
+00381 srcPix+= 16;
+00382 dstPix+= 16;
+00383 }
+00384
+00385 <font class="comment">// Must end MMX, for applyHLSMod()</font>
+00386 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00387 <font class="preprocessor"></font> <font class="keywordflow">if</font>(CSystemInfo::hasMMX())
+00388 _asm emms;
+00389 <font class="preprocessor">#endif</font>
+00390 <font class="preprocessor"></font>}
+00391
+00392 <font class="comment">// ***************************************************************************</font>
+<a name="l00393"></a><a class="code" href="classNL3D_1_1CFastHLSModifier.html#a2">00393</a> <font class="keywordtype">void</font> CFastHLSModifier::convertDDSBitmap(CBitmap &amp;dst, <font class="keyword">const</font> CBitmap &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, uint8 dh, sint dl, sint ds)
+00394 {
+00395 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getPixelFormat()==dst.getPixelFormat());
+00396 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getWidth()==dst.getWidth() &amp;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getHeight()==dst.getHeight());
+00397
+00398 <font class="comment">// Magic add clamp.</font>
+00399 uint dLum= 0xFFFFFF00 + dl;
+00400 uint dSat= 0xFFFFFF00 + ds;
+00401
+00402 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getPixelFormat()==CBitmap::DXTC1 || <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getPixelFormat()==CBitmap::DXTC1Alpha)
+00403 <a class="code" href="classNL3D_1_1CFastHLSModifier.html#c1">convertDDSBitmapDXTC1Or1A</a>(dst, <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, dh, dLum, dSat);
+00404 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getPixelFormat()==CBitmap::DXTC3 || <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getPixelFormat()==CBitmap::DXTC5)
+00405 <a class="code" href="classNL3D_1_1CFastHLSModifier.html#c2">convertDDSBitmapDXTC3Or5</a>(dst, <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, dh, dLum, dSat);
+00406 <font class="keywordflow">else</font>
+00407 {
+00408 <a class="code" href="debug_8h.html#a12">nlstop</a>;
+00409 }
+00410 }
+00411
+00412
+00413 <font class="comment">// ***************************************************************************</font>
+<a name="l00414"></a><a class="code" href="classNL3D_1_1CFastHLSModifier.html#a1">00414</a> <font class="keywordtype">void</font> CFastHLSModifier::convertRGBABitmap(CBitmap &amp;dst, <font class="keyword">const</font> CBitmap &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, uint8 dh, sint dl, sint ds)
+00415 {
+00416 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getPixelFormat()==dst.getPixelFormat());
+00417 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getPixelFormat()==CBitmap::RGBA);
+00418
+00419 uint W= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getWidth();
+00420 uint H= <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getHeight();
+00421
+00422 <font class="keyword">const</font> CRGBA *srcPix= (<font class="keyword">const</font> CRGBA*)&amp;(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>.getPixels()[0]);
+00423 CRGBA *dstPix= (CRGBA*)&amp;(dst.getPixels()[0]);
+00424 uint numPix= W*H;
+00425
+00426 <font class="comment">// Do not use alpha mask for now.</font>
+00427 <font class="keywordflow">for</font>(;numPix&gt;0;numPix--)
+00428 {
+00429 <font class="keywordtype">float</font> H,L,S;
+00430 srcPix-&gt;convertToHLS(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="namespaceNLMISC.html#a215">clamp</a>(H, 0, 255);
+00438 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(L, 0, 255);
+00439 <a class="code" href="namespaceNLMISC.html#a215">clamp</a>(S, 0, 255);
+00440 uint8 H8= (uint8)<a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(H);
+00441 uint8 L8= (uint8)<a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(L);
+00442 uint8 S8= (uint8)<a class="code" href="namespaceNL3D.html#a362">OptFastFloor</a>(S);
+00443 *dstPix= <a class="code" href="classNL3D_1_1CFastHLSModifier.html#a0">convert</a>(H8, L8, S8);
+00444 srcPix++;
+00445 dstPix++;
+00446 }
+00447 }
+00448
+00449
+00450 } <font class="comment">// NL3D</font>
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>