a bit of perf
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Drawing;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
|
||||||
namespace OpenRA.Editor
|
namespace OpenRA.Editor
|
||||||
{
|
{
|
||||||
@@ -53,6 +54,28 @@ namespace OpenRA.Editor
|
|||||||
if (e.Button == MouseButtons.Right)
|
if (e.Button == MouseButtons.Right)
|
||||||
Brush = Pair.New((ushort)0, null as Bitmap);
|
Brush = Pair.New((ushort)0, null as Bitmap);
|
||||||
|
|
||||||
|
if (e.Button == MouseButtons.Left && Brush.Second != null)
|
||||||
|
{
|
||||||
|
// change the bits in the map
|
||||||
|
var template = TileSet.walk[Brush.First];
|
||||||
|
var pos = GetBrushLocation();
|
||||||
|
|
||||||
|
for( var u = 0; u < template.Size.X; u++ )
|
||||||
|
for (var v = 0; v < template.Size.Y; v++)
|
||||||
|
{
|
||||||
|
var z = u + v * template.Size.X;
|
||||||
|
if (template.TerrainType.ContainsKey(z))
|
||||||
|
Map.MapTiles[u + pos.X, v + pos.Y] =
|
||||||
|
new TileReference<ushort, byte> { type = Brush.First, image = (byte)z, index = (byte)z };
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalidate tiles that were involved.
|
||||||
|
|
||||||
|
// todo: do this properly.
|
||||||
|
foreach (var v in Chunks.Values) v.Dispose();
|
||||||
|
Chunks.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +89,15 @@ namespace OpenRA.Editor
|
|||||||
var hx = Math.Min(Map.Width - u * ChunkSize, ChunkSize);
|
var hx = Math.Min(Map.Width - u * ChunkSize, ChunkSize);
|
||||||
var hy = Math.Min(Map.Height - v * ChunkSize, ChunkSize);
|
var hy = Math.Min(Map.Height - v * ChunkSize, ChunkSize);
|
||||||
|
|
||||||
for( var i = 0; i < hx; i++ )
|
var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
|
||||||
|
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
|
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
int* p = (int*)data.Scan0.ToPointer();
|
||||||
|
var stride = data.Stride >> 2;
|
||||||
|
|
||||||
|
for (var i = 0; i < hx; i++)
|
||||||
for (var j = 0; j < hy; j++)
|
for (var j = 0; j < hy; j++)
|
||||||
{
|
{
|
||||||
var tr = Map.MapTiles[u * ChunkSize + i, v * ChunkSize + j];
|
var tr = Map.MapTiles[u * ChunkSize + i, v * ChunkSize + j];
|
||||||
@@ -76,9 +107,11 @@ namespace OpenRA.Editor
|
|||||||
var rawImage = tile.TileBitmapBytes[index];
|
var rawImage = tile.TileBitmapBytes[index];
|
||||||
for (var x = 0; x < 24; x++)
|
for (var x = 0; x < 24; x++)
|
||||||
for (var y = 0; y < 24; y++)
|
for (var y = 0; y < 24; y++)
|
||||||
bitmap.SetPixel(i * 24 + x, j * 24 + y, Palette.GetColor(rawImage[x + 24 * y]));
|
p[ (j * 24 + y) * stride + i * 24 + x ] = Palette.GetColor(rawImage[x + 24 * y]).ToArgb();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bitmap.UnlockBits(data);
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user