measure sprite font performance
This commit is contained in:
@@ -60,6 +60,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public void InitializeFonts(Manifest m)
|
public void InitializeFonts(Manifest m)
|
||||||
{
|
{
|
||||||
|
using (new Support.PerfTimer("SpriteFonts"))
|
||||||
Fonts = m.Fonts.ToDictionary(x => x.Key, x => new SpriteFont(Platform.ResolvePath(x.Value.First), x.Value.Second));
|
Fonts = m.Fonts.ToDictionary(x => x.Key, x => new SpriteFont(Platform.ResolvePath(x.Value.First), x.Value.Second));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
|
using OpenRA.Support;
|
||||||
using SharpFont;
|
using SharpFont;
|
||||||
|
|
||||||
namespace OpenRA.Graphics
|
namespace OpenRA.Graphics
|
||||||
@@ -19,10 +20,12 @@ namespace OpenRA.Graphics
|
|||||||
public class SpriteFont
|
public class SpriteFont
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
string name;
|
||||||
|
|
||||||
public SpriteFont(string name, int size)
|
public SpriteFont(string name, int size)
|
||||||
{
|
{
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
face = library.NewFace(name, 0);
|
face = library.NewFace(name, 0);
|
||||||
face.SetPixelSizes((uint)size, (uint)size);
|
face.SetPixelSizes((uint)size, (uint)size);
|
||||||
@@ -41,7 +44,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
void PrecacheColor(Color c)
|
void PrecacheColor(Color c)
|
||||||
{
|
{
|
||||||
// precache glyphs for U+0020 - U+007f
|
using (new PerfTimer("PrecacheColor {0} {1}px {2}".F(name, size, c.Name)))
|
||||||
for (var n = (char)0x20; n < (char)0x7f; n++)
|
for (var n = (char)0x20; n < (char)0x7f; n++)
|
||||||
if (glyphs[Pair.New(n, c)] == null)
|
if (glyphs[Pair.New(n, c)] == null)
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
|
|||||||
Reference in New Issue
Block a user