proper handling of dirty sheets (about 2 years overdue)
This commit is contained in:
@@ -28,8 +28,8 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
readonly Renderer renderer;
|
||||
protected readonly Bitmap bitmap;
|
||||
|
||||
ITexture texture;
|
||||
bool dirty;
|
||||
|
||||
internal Sheet(Renderer renderer, Size size)
|
||||
{
|
||||
@@ -43,17 +43,18 @@ namespace OpenRA.Graphics
|
||||
this.bitmap = (Bitmap)Image.FromStream(FileSystem.Open(filename));
|
||||
}
|
||||
|
||||
void Resolve()
|
||||
{
|
||||
texture = renderer.Device.CreateTexture(bitmap);
|
||||
}
|
||||
|
||||
public ITexture Texture
|
||||
{
|
||||
get
|
||||
{
|
||||
if (texture == null)
|
||||
Resolve();
|
||||
texture = renderer.Device.CreateTexture(bitmap);
|
||||
|
||||
if (dirty)
|
||||
{
|
||||
texture.SetData(bitmap);
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
@@ -68,5 +69,7 @@ namespace OpenRA.Graphics
|
||||
}
|
||||
|
||||
public Bitmap Bitmap { get { return bitmap; } } // for perf
|
||||
|
||||
public void MakeDirty() { dirty = true; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace OpenRA.Graphics
|
||||
}
|
||||
|
||||
Sprite rect = new Sprite(current, new Rectangle(p, imageSize), channel.Value);
|
||||
current.MakeDirty();
|
||||
p.X += imageSize.Width;
|
||||
|
||||
return rect;
|
||||
|
||||
@@ -53,8 +53,6 @@ namespace OpenRA
|
||||
sprites = new Sprite[map.MapSize, map.MapSize];
|
||||
gapField = new int[map.MapSize, map.MapSize];
|
||||
gapActive = new bool[map.MapSize, map.MapSize];
|
||||
|
||||
shadowBits[0].sheet.Texture.SetData(shadowBits[0].sheet.Bitmap); // HACK
|
||||
}
|
||||
|
||||
public bool HasGPS
|
||||
|
||||
Reference in New Issue
Block a user