MOAR PERF
git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1929 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -27,6 +27,9 @@ namespace OpenRa.FileFormats
|
|||||||
|
|
||||||
bool ProcessSection( string line )
|
bool ProcessSection( string line )
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(line) || line.StartsWith(";"))
|
||||||
|
return false;
|
||||||
|
|
||||||
Match m = sectionPattern.Match( line );
|
Match m = sectionPattern.Match( line );
|
||||||
if( m == null || !m.Success )
|
if( m == null || !m.Success )
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -89,7 +89,10 @@ namespace OpenRa.Game
|
|||||||
var bitmap = dest.sheet.Bitmap;
|
var bitmap = dest.sheet.Bitmap;
|
||||||
BitmapData bits = null;
|
BitmapData bits = null;
|
||||||
uint[] channelMasks = { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
|
uint[] channelMasks = { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
|
||||||
|
int[] shifts = { 16, 8, 0, 24 };
|
||||||
|
|
||||||
uint mask = channelMasks[(int)dest.channel];
|
uint mask = channelMasks[(int)dest.channel];
|
||||||
|
int shift = shifts[(int)dest.channel];
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -98,13 +101,24 @@ namespace OpenRa.Game
|
|||||||
int width = dest.bounds.Width;
|
int width = dest.bounds.Width;
|
||||||
int height = dest.bounds.Height;
|
int height = dest.bounds.Height;
|
||||||
|
|
||||||
for (int j = 0; j < height; j++)
|
unsafe
|
||||||
{
|
{
|
||||||
unsafe
|
fixed (byte* srcbase = &src[0])
|
||||||
{
|
{
|
||||||
uint* p = (uint*)(bits.Scan0.ToInt32() + j * bits.Stride);
|
byte* s = srcbase;
|
||||||
for (int i = 0; i < width; i++, p++)
|
uint * t = (uint*)bits.Scan0.ToPointer();
|
||||||
*p = ReplaceChannel(*p, mask, src[i + width * j]);
|
int stride = bits.Stride >> 2;
|
||||||
|
|
||||||
|
for (int j = 0; j < height; j++)
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
uint* p = t;
|
||||||
|
for (int i = 0; i < width; i++, p++)
|
||||||
|
*p = (*p & ~mask) | ((mask & ((uint)*s++) << shift));
|
||||||
|
t += stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,18 +127,5 @@ namespace OpenRa.Game
|
|||||||
bitmap.UnlockBits(bits);
|
bitmap.UnlockBits(bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint ReplaceChannel(uint o, uint mask, byte p)
|
|
||||||
{
|
|
||||||
uint pp = (uint)p;
|
|
||||||
|
|
||||||
pp |= pp << 8; // copy into all channels
|
|
||||||
pp |= pp << 16;
|
|
||||||
|
|
||||||
o &= ~mask;
|
|
||||||
o |= (mask & pp);
|
|
||||||
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user