Create covers in a task

This commit is contained in:
Flamefire committed 2014-09-25 20:04:08 +02:00
1 parent aff7f42c68
commit 467b619f0a
2 files changed
+12 -7

No files matched your search

+10 -6
View File
@@ -19,6 +19,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using VocaluxeLib;
using VocaluxeLib.Draw;
using VocaluxeLib.Songs;
@@ -101,12 +102,15 @@ namespace Vocaluxe.Base
public static CTextureRef GenerateCover(string text, ESongSorting sorting, CCategory category)
{
CSong firstSong = category.GetSong(0);
Bitmap coverBmp = _NoCoverThemes[_SongSortingToType(sorting)].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null);
if (coverBmp == null)
coverBmp = _NoCoverThemes[_DefaultTypeName].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null);
if (coverBmp == null)
return NoCover;
CTextureRef texture = CDraw.AddTexture(coverBmp);
CTextureRef texture = CDraw.CopyTexture(NoCover);
Task.Factory.StartNew(() =>
{
Bitmap coverBmp = _NoCoverThemes[_SongSortingToType(sorting)].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null);
if (coverBmp == null)
coverBmp = _NoCoverThemes[_DefaultTypeName].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null);
if (coverBmp != null)
CDraw.EnqueueTextureUpdate(texture, coverBmp);
});
lock (_Covers)
{
_Covers.Add(text, texture);
+2 -1
View File
@@ -216,7 +216,8 @@ namespace Vocaluxe.Base
/// <summary>
/// Requests updating a texture from a bitmap<br />
/// Use this if you add textures from another thread or don't need it immediatelly
/// Use this if you add textures from another thread or don't need it immediatelly <br />
/// Bitmap is freed after use
/// </summary>
/// <param name="textureRef">Reference to the texture to update</param>
/// <param name="bmp"></param>