#include <rgba.h>
Nevrax France
Definition at line 44 of file rgba.h.
Public Member Functions | |
| void | add (CRGBA c0, CRGBA c1) |
| void | avg2 (CRGBA a, CRGBA b) |
| void | avg4 (CRGBA a, CRGBA b, CRGBA c, CRGBA d) |
| void | blendFromui (CRGBA c0, CRGBA c1, uint coef) |
| CRGBA (uint8 r, uint8 g, uint8 b, uint8 a=255) | |
| CRGBA () | |
| Default constructor. do nothing. | |
| uint16 | get565 () const |
| uint | getPacked () const |
| void | modulateFromColor (CRGBA c0, CRGBA c1) |
| void | modulateFromui (CRGBA c0, uint a) |
| bool | operator!= (CRGBA c) const |
| bool | operator< (CRGBA c) const |
| bool | operator== (CRGBA c) const |
| void | serial (class NLMISC::IStream &f) |
| void | set (uint8 r, uint8 g, uint8 b, uint8 a=255) |
| void | set565 (uint16 col) |
| void | setPacked (uint packed) |
| void | sub (CRGBA c0, CRGBA c1) |
RGBOnly methods. Same f() as their homonym, but don't modify A component. | |
| void | addRGBOnly (CRGBA c0, CRGBA c1) |
| see add() | |
| void | avg2RGBOnly (CRGBA a, CRGBA b) |
| see avg2() | |
| void | avg4RGBOnly (CRGBA a, CRGBA b, CRGBA c, CRGBA d) |
| see avg4() | |
| void | blendFromuiRGBOnly (CRGBA c0, CRGBA c1, uint coef) |
| see blendFromui() | |
| void | modulateFromColorRGBOnly (CRGBA c0, CRGBA c1) |
| see modulateFromColor() | |
| void | modulateFromuiRGBOnly (CRGBA c0, uint a) |
| see modulateFromui() | |
| void | subRGBOnly (CRGBA c0, CRGBA c1) |
| see sub() | |
Color space conversions RGB only | |
| void | buildFromHLS (float h, float l, float s) |
| bool | convertToHLS (float &h, float &l, float &S) const |
Static Public Member Functions | |
Color group manipulation | |
| void | addColors (CRGBA *dest, const CRGBA *src1, const CRGBA *src2, uint numColors, uint srcStride=sizeof(CRGBA), uint destStride=sizeof(CRGBA), uint dup=1) |
| void | modulateColors (CRGBA *dest, const CRGBA *src1, const CRGBA *src2, uint numColors, uint srcStride=sizeof(CRGBA), uint destStride=sizeof(CRGBA), uint dup=1) |
| void | subtractColors (CRGBA *dest, const CRGBA *src1, const CRGBA *src2, uint numColors, uint srcStride=sizeof(CRGBA), uint destStride=sizeof(CRGBA), uint dup=1) |
Data Fields | |
| uint8 | A |
| Alpha componant. | |
| uint8 | B |
| Blue componant. | |
| uint8 | G |
| Green componant. | |
| uint8 | R |
| Red componant. | |
Static Public Attributes | |
| const CRGBA | Black |
| some colors | |
| const CRGBA | Blue |
| const CRGBA | Cyan |
| const CRGBA | Green |
| const CRGBA | Magenta |
| const CRGBA | Red |
| const CRGBA | White |
| const CRGBA | Yellow |
|
|
Default constructor. do nothing.
Definition at line 49 of file rgba.h.
00049 {};
|
|
||||||||||||||||||||
|
Constructor.
Definition at line 58 of file rgba.h.
|
|
||||||||||||
|
Do the sum of 2 rgba, clamp, and store in this Definition at line 201 of file rgba.h. References A, B, G, min, R, r, uint, and uint8. Referenced by addColors(), NL3D::CTextureEmboss::doGenerate(), and NL3D::CParticleSystemModel::traverseRender().
|
|
||||||||||||||||||||||||||||||||
|
Add a group of colors with saturation, using mmx instructions when present. dest The destination color buffer, encoded as CRGBA's. src1 The first source color buffer, encoded as CRGBA's. src2 The second source color buffer, encoded as CRGBA's. numColors The number of colors to compute Stride between each source color. Stride between each destination color. Dup the number of time the result must be duplicated in the destination. Definition at line 79 of file rgba.cpp. References add(), offset, sub(), uint, and uint8. Referenced by NL3D::Make4Private(), NL3D::MakeNPrivate(), and NL3D::MakePrivate().
00080 {
00081 if (numColors == 0) return;
00082 #if defined(NL_OS_WINDOWS) && !defined(DISABLE_MMX_OPTIM)
00083 if (!CSystemInfo::hasMMX())
00084 #endif
00085 { // unoptimized version
00086 if (dup == 1)
00087 {
00088 while (numColors--)
00089 {
00090 dest->add(*src1, *src2);
00091 dest = (CRGBA *) ((uint8 *) dest + destStride);
00092 src1 = (CRGBA *) ((uint8 *) src1 + srcStride);
00093 src2 = (CRGBA *) ((uint8 *) src2 + srcStride);
00094 }
00095 }
00096 else
00097 {
00098 if (dup == 4) // optimisation for the 4 case
00099 {
00100 while (numColors--)
00101 {
00102 dest->add(*src1, *src2);
00103 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00104 dest = (CRGBA *) ((uint8 *) dest + destStride);
00105 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00106 dest = (CRGBA *) ((uint8 *) dest + destStride);
00107 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00108 dest = (CRGBA *) ((uint8 *) dest + (destStride << 1));
00109
00110 src1 = (CRGBA *) ((uint8 *) src1 + srcStride);
00111 src2 = (CRGBA *) ((uint8 *) src2 + srcStride);
00112 }
00113 }
00114 else
00115 {
00116 while (numColors--)
00117 {
00118 dest->add(*src1, *src2);
00119
00120 uint k = dup - 1;
00121 do
00122 {
00123 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00124 dest = (CRGBA *) ((uint8 *) dest + destStride);
00125 }
00126 while (--k);
00127
00128 dest = (CRGBA *) ((uint8 *) dest + destStride);
00129 src1 = (CRGBA *) ((uint8 *) src1 + srcStride);
00130 src2 = (CRGBA *) ((uint8 *) src2 + srcStride);
00131 }
00132 }
00133 }
00134 }
00135 #if defined(NL_OS_WINDOWS) && !defined(DISABLE_MMX_OPTIM)
00136 else // optimized mmx version
00137 {
00139 if (dup == 1)
00140 {
00141 __asm
00142 {
00143 push ebp
00144 mov edi, dest
00145 mov esi, src1
00146 mov ebx, src2
00147 sub ebx, esi ; offset to source 2
00148 mov ecx, numColors
00149 mov edx, destStride
00150 mov ebp, srcStride
00151 sub edi, edx
00152 myLoop:
00153 movd mm0, [esi]
00154 add edi, edx
00155 movd mm1, [esi + ebx]
00156 paddusb mm0, mm1
00157 movd [edi], mm0
00158 add esi, ebp
00159 dec ecx
00160 jne myLoop
00161 pop ebp
00162 emms
00163 }
00164 }
00165 else
00166 {
00167 if (dup == 4)
00168 {
00169 __asm
00170 {
00171 push ebp
00172 mov edi, dest
00173 mov esi, src1
00174 mov ebx, src2
00175 sub ebx, esi ; offset to source 2
00176 mov ecx, numColors
00177 mov edx, destStride
00178 mov ebp, srcStride
00179 myLoop4:
00180 movd mm0, [esi]
00181 movd mm1, [esi + ebx]
00182 paddusb mm0, mm1
00183 movd eax, mm0
00184
00185 mov [edi], eax
00186 mov [edi + edx], eax
00187 mov [edi + 2 * edx], eax
00188 lea edi, [edi + edx * 2]
00189 mov [edi + edx], eax
00190 lea edi, [edi + edx * 2]
00191 add esi, ebp
00192
00193 dec ecx
00194 jne myLoop4
00195 pop ebp
00196 emms
00197 }
00198 }
00199 else
00200 {
00201 __asm
00202 {
00203 push ebp
00204 mov edi, dest
00205 mov esi, src1
00206 mov ebx, src2
00207 sub ebx, esi ; offset to source 2
00208 mov ecx, numColors
00209 mov edx, destStride
00210 mov eax, dup
00211 mov ebp, srcStride
00212 push eax
00213 myLoopN:
00214 movd mm0, [esi]
00215 movd mm1, [esi + ebx]
00216 push ecx
00217 paddusb mm0, mm1
00218 mov ecx, 4[esp]
00219 movd eax, mm0
00220 dupLoopN:
00221 mov [edi], eax
00222 dec ecx
00223 lea edi, [edi + edx]
00224 jne dupLoopN
00225 pop ecx ; get back the loop counter
00226 add esi, ebp
00227 dec ecx
00228 jne myLoopN
00229 pop eax
00230 pop ebp
00231 emms
00232 }
00233 }
00234 }
00235 }
00236 #endif
00237 }
|
|
||||||||||||
|
see add()
Definition at line 264 of file rgba.h. References B, G, min, R, r, uint, and uint8. Referenced by NL3D::CPatchDLMContext::addPointLightInfluence(), NL3D::CRenderTrav::changeLightSetup(), NL3D::CLightContribution::computeCurrentAmbient(), NL3D::computeVegetVertexLighting(), NL3D::computeVegetVertexLightingForceBestSided(), NL3D::CMeshMultiLodInstance::getCoarseMeshLighting(), and NL3D_expandLightmap().
|
|
||||||||||||
|
Compute in this the average of 2 RGBA. Definition at line 178 of file rgba.h. References A, B, G, R, and uint.
|
|
||||||||||||
|
see avg2()
Definition at line 250 of file rgba.h. Referenced by NL3D::CPatch::getCurrentTileTLIColors().
|
|
||||||||||||||||||||
|
Compute in this the average of 4 RGBA. The average is "correct": +1 is added to the four color, to make a "round" like average. Definition at line 190 of file rgba.h. References A, B, G, R, and uint.
|
|
||||||||||||||||||||
|
see avg4()
Definition at line 257 of file rgba.h.
|
|
||||||||||||||||
|
Blend two colors.
Definition at line 104 of file rgba.h. References A, B, G, R, and uint. Referenced by NL3D::CMeshMRMGeom::applyGeomorphWithVBHardPtr(), NL3D::CHLSColorTexture::compressBlockRGB(), NLMISC::CBitmap::decompressDXT1(), NLMISC::CBitmap::decompressDXT3(), NLMISC::CBitmap::decompressDXT5(), NLMISC::CBitmap::getDXTCColorFromBlock(), NL3D_expandLightmap(), NL3D::PSValueBlend(), and NL3D::CHLSColorTexture::uncompressBlockRGB().
|
|
||||||||||||||||
|
see blendFromui()
Definition at line 227 of file rgba.h. Referenced by NL3D::CPatchDLMContext::blendTileToTexture(), NL3D::CHLSColorTexture::buildColorVersion(), and NL3D::CFastHLSModifier::convert().
|
|
||||||||||||||||
|
Build from HLS valued Each component ranges from 0 to 1.f Definition at line 686 of file rgba.cpp. References NLMISC::clamp(), NLMISC::HLSValue(), s, uint8, and v. Referenced by NL3D::CFastHLSModifier::CFastHLSModifier().
00687 {
00688 clamp(l, 0, 1);
00689 clamp(s, 0, 1);
00690
00691 float v2 = (l <= 0.5f) ? (l * (1 + s)) : (l + s - l * s);
00692 float v1 = 2.f * l - v2;
00693
00694 if (s == 0) // achromatic ?
00695 {
00696 R = G = B = (uint8) (255.f * l);
00697 }
00698 else // chromatic case
00699 {
00700 float v;
00701 //
00702 v = HLSValue(h + 120.f, v1, v2);
00703 clamp(v, 0.f, 1.f);
00704 R = (uint8) (255.f * v);
00705 //
00706 v = HLSValue(h, v1, v2);
00707 clamp(v, 0.f, 1.f);
00708 G = (uint8) (255.f * v);
00709 //
00710 v = HLSValue(h - 120.f, v1, v2);
00711 clamp(v, 0.f, 1.f);
00712 B = (uint8) (255.f * v);
00713 }
00714 }
|
|
||||||||||||||||
|
Convert to HLS color space. Lightness and satuation ranges from 0 to 1 There's no range for hue, (all hues colors range from 0 to 360, from 360 to 720 and so on)
Definition at line 609 of file rgba.cpp. References NLMISC::maxof(), NLMISC::minof(), r, and s. Referenced by NL3D::CFastHLSModifier::CFastHLSModifier(), and NL3D::CFastHLSModifier::convertRGBABitmap().
00610 {
00611 float r = R / 255.f;
00612 float g = G / 255.f;
00613 float b = B / 255.f;
00614
00615 float maxV = NLMISC::maxof(r, g, b);
00616 float minV = NLMISC::minof(r, g, b);
00617
00619 l = 0.5f * (maxV + minV);
00620
00622 if (minV == maxV) // all composants are equals -> achromatique
00623 {
00624 s = 0;
00625 return true;
00626 }
00627 float diff = maxV - minV;
00629 s = l > 0.5f ? /*are we in the top of the double-hexcone ? */
00630 diff / (2.f - maxV - minV) :
00631 diff / (maxV + minV);
00632
00633 // Get hue
00634
00635 if (maxV == r)
00636 {
00637 h = (g - b) / diff;
00638 }
00639 else if (maxV == g)
00640 {
00641 h = 2.f + (b - r) / diff;
00642 }
00643 else
00644 {
00645 h = 4.f + (r - g) / diff;
00646 }
00647
00648 h *= 60.f; // scale to [0..360]
00649
00650 if (h < 0.f) h += 360.f;
00651
00652 return false;
00653 }
|
|
|
Get a 16 bits 565 pixel. Definition at line 154 of file rgba.h. References uint16. Referenced by NL3D::CFastHLSModifier::applyHLSMod(), and NL3D::CPatch::setupColorsFromTileFlags().
|
|
|
Return a packed pixel Definition at line 75 of file rgba.h. References uint. Referenced by NL3D::CRenderTrav::changeVPLightSetupMaterial(), operator<(), and NL3D::CDriverGL::setupMaterial().
|
|
||||||||||||||||||||||||||||||||
|
Modulate a group of colors with saturation, using mmx instructions when present. dest The destination color buffer, encoded as CRGBA's. src1 The first source color buffer, encoded as CRGBA's. src2 The second source color buffer, encoded as CRGBA's. numColors The number of colors to compute Stride between each color. It is the same for sources and destination. Definition at line 239 of file rgba.cpp. References modulateFromColor(), offset, sub(), uint, uint64, and uint8. Referenced by NL3D::CPSConstraintMesh::computeColors(), NL3D::Make4Private(), NL3D::MakeNPrivate(), and NL3D::MakePrivate().
00240 {
00241 #if defined(NL_OS_WINDOWS) && !defined(DISABLE_MMX_OPTIM)
00242 if (!CSystemInfo::hasMMX())
00243 #endif
00244 { // unoptimized version
00245 if (dup == 1)
00246 {
00247 while (numColors--)
00248 {
00249 dest->modulateFromColor(*src1, *src2);
00250 dest = (CRGBA *) ((uint8 *) dest + destStride);
00251 src1 = (CRGBA *) ((uint8 *) src1 + srcStride);
00252 src2 = (CRGBA *) ((uint8 *) src2 + srcStride);
00253 }
00254 }
00255 else
00256 {
00257 if (dup == 4) // optimisation for the 4 case
00258 {
00259 while (numColors--)
00260 {
00261 dest->modulateFromColor(*src1, *src2);
00262 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00263 dest = (CRGBA *) ((uint8 *) dest + destStride);
00264 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00265 dest = (CRGBA *) ((uint8 *) dest + destStride);
00266 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00267 dest = (CRGBA *) ((uint8 *) dest + (destStride << 1));
00268
00269 src1 = (CRGBA *) ((uint8 *) src1 + srcStride);
00270 src2 = (CRGBA *) ((uint8 *) src2 + srcStride);
00271 }
00272 }
00273 else
00274 {
00275 while (numColors--)
00276 {
00277 dest->modulateFromColor(*src1, *src2);
00278
00279 uint k = dup - 1;
00280 do
00281 {
00282 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00283 dest = (CRGBA *) ((uint8 *) dest + destStride);
00284 }
00285 while (--k);
00286
00287 dest = (CRGBA *) ((uint8 *) dest + destStride);
00288 src1 = (CRGBA *) ((uint8 *) src1 + srcStride);
00289 src2 = (CRGBA *) ((uint8 *) src2 + srcStride);
00290 }
00291 }
00292 }
00293 }
00294 #if defined(NL_OS_WINDOWS) && !defined(DISABLE_MMX_OPTIM)
00295 else // optimized mmx version
00296 {
00297 uint64 blank = 0;
00299 if (dup == 1)
00300 { __asm
00301 {
00302 push ebp
00303 movq mm2, blank
00304 mov edi, dest
00305 mov esi, src1
00306 mov ebx, src2
00307 sub ebx, esi ; offset to source 2
00308 mov ecx, numColors
00309 mov edx, destStride
00310 mov ebp, srcStride
00311 myLoop:
00312 movd mm0, [esi]
00313 movd mm1, [esi + ebx]
00314 punpcklbw mm0, mm2
00315 punpcklbw mm1, mm2
00316 pmullw mm0, mm1
00317 psrlw mm0, 8
00318 packuswb mm0, mm0
00319 movd [edi], mm0
00320 add edi, edx
00321 add esi, ebp
00322
00323 dec ecx
00324 jne myLoop
00325 pop ebp
00326 emms
00327 }
00328 }
00329 else
00330 {
00331 if (dup == 4)
00332 {
00333
00334 __asm
00335 {
00336 push ebp
00337 movq mm2, blank
00338 mov edi, dest
00339 mov esi, src1
00340 mov ebx, src2
00341 sub ebx, esi ; offset to source 2
00342 mov ecx, numColors
00343 mov edx, destStride
00344 mov ebp, srcStride
00345 myLoop4:
00346 movd mm0, [esi]
00347 movd mm1, [esi + ebx]
00348 punpcklbw mm0, mm2
00349 punpcklbw mm1, mm2
00350 pmullw mm0, mm1
00351 psrlw mm0, 8
00352 packuswb mm0, mm0
00353 movd eax, mm0
00354 ; duplicate the result 4 times
00355 mov [edi], eax
00356 mov [edi + edx], eax
00357 mov [edi + 2 * edx], eax
00358 lea edi, [edi + 2 * edx]
00359 mov [edi + edx], eax
00360 lea edi, [edi + 2 * edx]
00361 add esi, ebp
00362 dec ecx
00363 jne myLoop4
00364 pop ebp
00365 emms
00366 }
00367 }
00368 else
00369 {
00370 __asm
00371 {
00372 push ebp
00373 movq mm2, blank
00374 mov edi, dest
00375 mov esi, src1
00376 mov ebx, src2
00377 sub ebx, esi ; offset to source 2
00378 mov ecx, numColors
00379 mov edx, destStride
00380 mov eax, dup
00381 mov ebp, srcStride
00382 push eax
00383 myLoopN:
00384 movd mm0, [esi]
00385 movd mm1, [esi + ebx]
00386 punpcklbw mm0, mm2
00387 punpcklbw mm1, mm2
00388 pmullw mm0, mm1
00389 push ecx
00390 psrlw mm0, 8
00391 mov ecx, 4[esp]
00392 packuswb mm0, mm0
00393 movd eax, mm0
00394 dupLoopN:
00395 mov [edi], eax
00396 dec ecx
00397 lea edi, [edi + edx]
00398 jne dupLoopN
00399 pop ecx ; get back the loop counter
00400 add esi, ebp
00401 dec ecx
00402 jne myLoopN
00403 pop eax
00404 pop ebp
00405 emms
00406 }
00407 }
00408 }
00409 }
00410 #endif
00411 }
|
|
||||||||||||
|
Modulate colors with another color.
Definition at line 133 of file rgba.h. Referenced by NL3D::CPSShockWave::draw(), NL3D::CPSDot::draw(), NL3D::CZoneLighter::lightWater(), modulateColors(), NL3D::PSBinOpModulate(), NL3D::CPointLightNamed::setLightFactor(), NL3D::CPSTailDot::setupGlobalColor(), NL3D::CPSFanLight::setupMaterial(), NL3D::CPSRibbon::setupTexturedGlobalColor(), NL3D::CPSRibbon::setupUntexturedGlobalColor(), NL3D::CPSLight::step(), NL3D::CParticleSystem::updateColor(), and NL3D::CPSQuad::updateMatBeforeRendering().
|
|
||||||||||||
|
Definition at line 243 of file rgba.h. Referenced by NL3D::CVegetableManager::addInstance(), NL3D_expandLightmap(), and NL3D::CVegetableManager::updateInstanceLighting().
|
|
||||||||||||
|
Modulate colors with a constant.
Definition at line 119 of file rgba.h. References A, B, G, R, and uint. Referenced by NL3D::CVegetableLightEx::computeCurrentColors(), NL3D::CTextureEmboss::doGenerate(), NL3D::CParticleSystemModel::traverseRender(), and NL3D::CFlareModel::traverseRender().
|
|
||||||||||||
|
|
Comparison operator. Definition at line 84 of file rgba.h.
00084 {return !(*this==c);}
|
|
|
Comparison operator. Definition at line 80 of file rgba.h. References getPacked().
00080 {return getPacked()<c.getPacked();}
|
|
|
Equality operator. Definition at line 89 of file rgba.h.
|
|
|
Serialisation.
Definition at line 58 of file rgba.cpp.
00059 {
00060 f.serial (R);
00061 f.serial (G);
00062 f.serial (B);
00063 f.serial (A);
00064 }
|
|
||||||||||||||||||||
|
Set colors.
Definition at line 66 of file rgba.cpp. Referenced by NL3D::CIGSurfaceLightBuild::buildPLDebugMesh(), NL3D::CMesh::CCorner::CCorner(), NL3D::CRenderTrav::changeVPLightSetupMaterial(), NL3D::CLandscape::CLandscape(), NL3D::CMaterial::CLightMap::CLightMap(), NL3D::CMaterial::CMaterial(), NL3D::CLightingManager::computeModelLightContributions(), NL3D::CTransform::CTransform(), NL3D::CVegetableManager::CVegetableManager(), NLMISC::CBitmap::decompressDXT1(), NLMISC::CBitmap::getDXTCColorFromBlock(), NL3D::CVisualCollisionEntity::getStaticLightSetup(), NL3D::CIGSurfaceLight::getStaticLightSetup(), NLMISC::CBitmap::makeDummy(), NL3D::CRenderTrav::resetLightSetup(), NL3D::CMaterial::CTexEnv::setDefault(), NL3D::CDriverGL::setDisplay(), and NL3D::CDriverGL::swapBuffers().
|
|
|
Set the RGB fields with a 16 bits 565 pixel. Definition at line 162 of file rgba.h. References uint16. Referenced by NL3D::CFastHLSModifier::CFastHLSModifier(), NL3D::CHLSColorTexture::compressBlockRGB(), NL3D::CPatch::getTileTileColors(), NL3D_expandLightmap(), and NL3D::CHLSColorTexture::uncompressBlockRGB().
|
|
|
setup as a packed pixel Definition at line 64 of file rgba.h. References uint.
|
|
||||||||||||
|
Compute c0 - c1, and store in this Definition at line 213 of file rgba.h. References A, B, G, R, r, sint, and uint8. Referenced by addColors(), modulateColors(), and subtractColors().
|
|
||||||||||||
|
see sub()
Definition at line 272 of file rgba.h. References B, G, R, r, sint, and uint8.
|
|
||||||||||||||||||||||||||||||||
|
Subtract a group of colors with saturation (src1 - src2), using mmx instructions when present. dest The destination color buffer, encoded as CRGBA's. src1 The first source color buffer, encoded as CRGBA's. src2 The second source color buffer, encoded as CRGBA's. numColors The number of colors to compute Stride between each color. It is the same for sources and destination. Definition at line 413 of file rgba.cpp. References offset, sub(), uint, and uint8. Referenced by NL3D::Make4Private(), NL3D::MakeNPrivate(), and NL3D::MakePrivate().
00414 {
00415 if (numColors == 0) return;
00416 #if defined(NL_OS_WINDOWS) && !defined(DISABLE_MMX_OPTIM)
00417 if (!CSystemInfo::hasMMX())
00418 #endif
00419 { // unoptimized version
00420 if (dup == 1)
00421 {
00422 while (numColors--)
00423 {
00424 dest->sub(*src1, *src2);
00425 dest = (CRGBA *) ((uint8 *) dest + destStride);
00426 src1 = (CRGBA *) ((uint8 *) src1 + srcStride);
00427 src2 = (CRGBA *) ((uint8 *) src2 + srcStride);
00428 }
00429 }
00430 else
00431 {
00432 if (dup == 4) // optimisation for the 4 case
00433 {
00434 while (numColors--)
00435 {
00436 dest->sub(*src1, *src2);
00437 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00438 dest = (CRGBA *) ((uint8 *) dest + destStride);
00439 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00440 dest = (CRGBA *) ((uint8 *) dest + destStride);
00441 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00442 dest = (CRGBA *) ((uint8 *) dest + (destStride << 1));
00443
00444 src1 = (CRGBA *) ((uint8 *) src1 + srcStride);
00445 src2 = (CRGBA *) ((uint8 *) src2 + srcStride);
00446 }
00447 }
00448 else
00449 {
00450 while (numColors--)
00451 {
00452 dest->sub(*src1, *src2);
00453
00454 uint k = dup - 1;
00455 do
00456 {
00457 * (CRGBA *) ((uint8 *) dest + destStride) = *dest;
00458 dest = (CRGBA *) ((uint8 *) dest + destStride);
00459 }
00460 while (--k);
00461
00462 dest = (CRGBA *) ((uint8 *) dest + destStride);
00463 src1 = (CRGBA *) ((uint8 *) src1 + srcStride);
00464 src2 = (CRGBA *) ((uint8 *) src2 + srcStride);
00465 }
00466 }
00467 }
00468 }
00469 #if defined(NL_OS_WINDOWS) && !defined(DISABLE_MMX_OPTIM)
00470 else // optimized mmx version
00471 {
00473 if (dup == 1)
00474 {
00475 __asm
00476 {
00477 push ebp
00478 mov edi, dest
00479 mov esi, src1
00480 mov ebx, src2
00481 sub ebx, esi ; offset to source 2
00482 mov ecx, numColors
00483 mov edx, destStride
00484 mov ebp, srcStride
00485 sub edi, edx
00486 myLoop:
00487 movd mm0, [esi]
00488 add edi, edx
00489 movd mm1, [esi + ebx]
00490 psubusb mm0, mm1
00491 movd [edi], mm0
00492 add esi, ebp
00493 dec ecx
00494 jne myLoop
00495 pop ebp
00496 emms
00497 }
00498 }
00499 else
00500 {
00501 if (dup == 4)
00502 {
00503 __asm
00504 {
00505 push ebp
00506 mov edi, dest
00507 mov esi, src1
00508 mov ebx, src2
00509 sub ebx, esi ; offset to source 2
00510 mov ecx, numColors
00511 mov edx, destStride
00512 mov ebp, srcStride
00513 myLoop4:
00514 movd mm0, [esi]
00515 movd mm1, [esi + ebx]
00516 psubusb mm0, mm1
00517 movd eax, mm0
00518
00519 mov [edi], eax
00520 mov [edi + edx], eax
00521 mov [edi + 2 * edx], eax
00522 lea edi, [edi + edx * 2]
00523 mov [edi + edx], eax
00524 lea edi, [edi + edx * 2]
00525 add esi, ebp
00526
00527 dec ecx
00528 jne myLoop4
00529 pop ebp
00530 emms
00531 }
00532 }
00533 else
00534 {
00535 __asm
00536 {
00537 push ebp
00538 mov edi, dest
00539 mov esi, src1
00540 mov ebx, src2
00541 sub ebx, esi ; offset to source 2
00542 mov ecx, numColors
00543 mov edx, destStride
00544 mov eax, dup
00545 mov ebp, srcStride
00546 push eax
00547 myLoopN:
00548 movd mm0, [esi]
00549 movd mm1, [esi + ebx]
00550 push ecx
00551 psubusb mm0, mm1
00552 mov ecx, 4[esp]
00553 movd eax, mm0
00554 dupLoopN:
00555 mov [edi], eax
00556 dec ecx
00557 lea edi, [edi + edx]
00558 jne dupLoopN
00559 pop ecx ; get back the loop counter
00560 add esi, ebp
00561 dec ecx
00562 jne myLoopN
00563 pop eax
00564 pop ebp
00565 emms
00566 }
00567 }
00568 }
00569 }
00570 #endif
00571 }
|
|
|
|
|
some colors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.3.6