Use more locking to improve thread-safety in Sheet.

This commit is contained in:
RoosterDragon
2014-11-22 17:56:19 +00:00
parent c2b7d9ca5b
commit c2d86557f1

View File

@@ -73,16 +73,17 @@ namespace OpenRA.Graphics
void GenerateTexture() void GenerateTexture()
{ {
if (texture == null) lock (textureLock)
{ {
texture = Game.Renderer.Device.CreateTexture(); if (texture == null)
dirty = true;
}
if (data != null)
{
lock (textureLock)
{ {
texture = Game.Renderer.Device.CreateTexture();
dirty = true;
}
if (data != null)
{
if (dirty) if (dirty)
{ {
texture.SetData(data, Size.Width, Size.Height); texture.SetData(data, Size.Width, Size.Height);
@@ -140,13 +141,16 @@ namespace OpenRA.Graphics
public void CreateBuffer() public void CreateBuffer()
{ {
if (data != null) lock (textureLock)
return; {
if (texture == null) if (data != null)
data = new byte[4 * Size.Width * Size.Height]; return;
else if (texture == null)
data = texture.GetData(); data = new byte[4 * Size.Width * Size.Height];
releaseBufferOnCommit = false; else
data = texture.GetData();
releaseBufferOnCommit = false;
}
} }
public void CommitData() public void CommitData()