Removed unnecessary locks

This commit is contained in:
Stephan Sundermann committed 2012-03-16 16:53:41 +01:00
1 parent 73132f3932
commit 92a84f62f1
1 file changed
+21 -26
+21 -26
View File
@@ -764,17 +764,18 @@ namespace Vocaluxe.Lib.Draw
rect.Data.Position += rect.Pitch; rect.Data.Position += rect.Pitch;
} }
t.UnlockRectangle(0); t.UnlockRectangle(0);
_D3DTextures.Add(t);
bmp2.Dispose(); bmp2.Dispose();
bmp_data = null; bmp_data = null;
// Add to Texture List // Add to Texture List
texture.index = _D3DTextures.Count - 1;
texture.color = new SColorF(1f, 1f, 1f, 1f); texture.color = new SColorF(1f, 1f, 1f, 1f);
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f); texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
texture.TexturePath = String.Empty; texture.TexturePath = String.Empty;
lock (MutexTexture) lock (MutexTexture)
{ {
_D3DTextures.Add(t);
texture.index = _D3DTextures.Count - 1;
_Textures.Add(texture); _Textures.Add(texture);
} }
@@ -809,7 +810,7 @@ namespace Vocaluxe.Lib.Draw
lock (MutexTexture) lock (MutexTexture)
{ {
_D3DTextures.Add(null); //_D3DTextures.Add(transparentTexture); _D3DTextures.Add(null);
texture.index = _D3DTextures.Count - 1; texture.index = _D3DTextures.Count - 1;
queque.ID = texture.index; queque.ID = texture.index;
_Queque.Add(queque); _Queque.Add(queque);
@@ -838,15 +839,15 @@ namespace Vocaluxe.Lib.Draw
rect.Data.Position += rect.Pitch; rect.Data.Position += rect.Pitch;
} }
t.UnlockRectangle(0); t.UnlockRectangle(0);
_D3DTextures.Add(t);
texture.index = _D3DTextures.Count - 1;
texture.color = new SColorF(1f, 1f, 1f, 1f); texture.color = new SColorF(1f, 1f, 1f, 1f);
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f); texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
texture.TexturePath = String.Empty; texture.TexturePath = String.Empty;
lock (MutexTexture) lock (MutexTexture)
{ {
_D3DTextures.Add(t);
texture.index = _D3DTextures.Count - 1;
_Textures.Add(texture); _Textures.Add(texture);
} }
return texture; return texture;
@@ -874,27 +875,24 @@ namespace Vocaluxe.Lib.Draw
/// <returns>True if succeeded</returns> /// <returns>True if succeeded</returns>
public bool UpdateTexture(ref STexture Texture, ref byte[] Data) public bool UpdateTexture(ref STexture Texture, ref byte[] Data)
{ {
lock (MutexTexture) if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index) && _TextureExists(ref Texture))
{ {
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index) && _TextureExists(ref Texture)) DataRectangle rect = _D3DTextures[Texture.index].LockRectangle(0, LockFlags.None);
for (int i = 0; i < Data.Length; )
{ {
DataRectangle rect = _D3DTextures[Texture.index].LockRectangle(0, LockFlags.None); rect.Data.Write(Data, i, 4 * (int)Texture.width);
for (int i = 0; i < Data.Length; ) i += 4 * (int)Texture.width;
{ rect.Data.Position = rect.Data.Position - 4 * (int)Texture.width;
rect.Data.Write(Data, i, 4 * (int)Texture.width); rect.Data.Position += rect.Pitch;
i += 4 * (int)Texture.width;
rect.Data.Position = rect.Data.Position - 4 * (int)Texture.width;
rect.Data.Position += rect.Pitch;
}
_D3DTextures[Texture.index].UnlockRectangle(0);
Texture.height_ratio = Texture.height / NextPowerOfTwo(Texture.height);
Texture.width_ratio = Texture.width / NextPowerOfTwo(Texture.width);
return true;
} }
else _D3DTextures[Texture.index].UnlockRectangle(0);
return false;
Texture.height_ratio = Texture.height / NextPowerOfTwo(Texture.height);
Texture.width_ratio = Texture.width / NextPowerOfTwo(Texture.width);
return true;
} }
else
return false;
} }
/// <summary> /// <summary>
@@ -1381,10 +1379,7 @@ namespace Vocaluxe.Lib.Draw
/// <returns>The amount of textures</returns> /// <returns>The amount of textures</returns>
public int TextureCount() public int TextureCount()
{ {
lock (MutexTexture) return _Textures.Count;
{
return _Textures.Count;
}
} }
#endregion Textures #endregion Textures
#endregion implementation #endregion implementation