mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
Optimise DrawNoise in launcher by removing function calls in the inner loop (which can be called millions of time when launcher is full screen).
This commit is contained in:
parent
eb081bca76
commit
15d73ab7ac
@ -55,14 +55,19 @@ namespace Launcher {
|
|||||||
if( !CheckCoords( dst, dstRect, out dstX, out dstY, out dstWidth, out dstHeight ) )
|
if( !CheckCoords( dst, dstRect, out dstX, out dstY, out dstWidth, out dstHeight ) )
|
||||||
return;
|
return;
|
||||||
const int alpha = 255 << 24;
|
const int alpha = 255 << 24;
|
||||||
|
|
||||||
for( int yy = 0; yy < dstHeight; yy++ ) {
|
for( int yy = 0; yy < dstHeight; yy++ ) {
|
||||||
int* row = dst.GetRowPtr( dstY + yy );
|
int* row = dst.GetRowPtr( dstY + yy );
|
||||||
for( int xx = 0; xx < dstWidth; xx++ ) {
|
for( int xx = 0; xx < dstWidth; xx++ ) {
|
||||||
float n = Noise( dstX + xx, dstY + yy );
|
int n = (dstX + xx) + (dstY + yy) * 57;
|
||||||
int r = col.R + (int)(n * variation); Utils.Clamp( ref r, 0, 255 );
|
n = (n << 13) ^ n;
|
||||||
int g = col.G + (int)(n * variation); Utils.Clamp( ref g, 0, 255 );
|
float noise = 1f - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824f;
|
||||||
int b = col.B + (int)(n * variation); Utils.Clamp( ref b, 0, 255 );
|
|
||||||
|
int r = col.R + (int)(noise * variation);
|
||||||
|
r = r < 0 ? 0 : (r > 255 ? 255 : r);
|
||||||
|
int g = col.G + (int)(noise * variation);
|
||||||
|
g = g < 0 ? 0 : (g > 255 ? 255 : g);
|
||||||
|
int b = col.B + (int)(noise * variation);
|
||||||
|
b = b < 0 ? 0 : (b > 255 ? 255 : b);
|
||||||
row[dstX + xx] = alpha | (r << 16) | (g << 8) | b;
|
row[dstX + xx] = alpha | (r << 16) | (g << 8) | b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user