Use more locking to improve thread-safety in Sheet.
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user