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.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Threading.Tasks;
using VocaluxeLib; using VocaluxeLib;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
using VocaluxeLib.Songs; using VocaluxeLib.Songs;
@@ -101,12 +102,15 @@ namespace Vocaluxe.Base
public static CTextureRef GenerateCover(string text, ESongSorting sorting, CCategory category) public static CTextureRef GenerateCover(string text, ESongSorting sorting, CCategory category)
{ {
CSong firstSong = category.GetSong(0); CSong firstSong = category.GetSong(0);
Bitmap coverBmp = _NoCoverThemes[_SongSortingToType(sorting)].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null); CTextureRef texture = CDraw.CopyTexture(NoCover);
if (coverBmp == null) Task.Factory.StartNew(() =>
coverBmp = _NoCoverThemes[_DefaultTypeName].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null); {
if (coverBmp == null) Bitmap coverBmp = _NoCoverThemes[_SongSortingToType(sorting)].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null);
return NoCover; if (coverBmp == null)
CTextureRef texture = CDraw.AddTexture(coverBmp); coverBmp = _NoCoverThemes[_DefaultTypeName].GetCover(text, firstSong != null ? Path.Combine(firstSong.Folder, firstSong.CoverFileName) : null);
if (coverBmp != null)
CDraw.EnqueueTextureUpdate(texture, coverBmp);
});
lock (_Covers) lock (_Covers)
{ {
_Covers.Add(text, texture); _Covers.Add(text, texture);
+2 -1
View File
@@ -216,7 +216,8 @@ namespace Vocaluxe.Base
/// <summary> /// <summary>
/// Requests updating a texture from a bitmap<br /> /// 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> /// </summary>
/// <param name="textureRef">Reference to the texture to update</param> /// <param name="textureRef">Reference to the texture to update</param>
/// <param name="bmp"></param> /// <param name="bmp"></param>