This commit is contained in:
Paul Chote
2010-08-12 00:06:08 +12:00
parent b88512df43
commit 93a48c0cf1
2 changed files with 22 additions and 17 deletions

View File

@@ -253,8 +253,12 @@ namespace OpenRA.FileFormats
} }
} }
public int[,] FrameData() int cachedFrame;
public int[,] FrameData { get
{ {
if (cachedFrame != currentFrame)
{
cachedFrame = currentFrame;
for (var y = 0; y < blocks.Y; y++) for (var y = 0; y < blocks.Y; y++)
for (var x = 0; x < blocks.X; x++) for (var x = 0; x < blocks.X; x++)
{ {
@@ -268,8 +272,9 @@ namespace OpenRA.FileFormats
frameData[y*blockHeight + j, x*blockWidth + i] = palette[color]; frameData[y*blockHeight + j, x*blockWidth + i] = palette[color];
} }
} }
return frameData;
} }
return frameData;
}}
int NextPowerOf2(int v) int NextPowerOf2(int v)
{ {

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Widgets
Sound.PlayRaw(video.AudioData); Sound.PlayRaw(video.AudioData);
nextFrame = 0; nextFrame = 0;
videoSprite.sheet.Texture.SetData(video.FrameData()); videoSprite.sheet.Texture.SetData(video.FrameData);
first = false; first = false;
} }
@@ -59,7 +59,7 @@ namespace OpenRA.Widgets
{ {
video.AdvanceFrame(); video.AdvanceFrame();
if (nextFrame == video.CurrentFrame) if (nextFrame == video.CurrentFrame)
videoSprite.sheet.Texture.SetData(video.FrameData()); videoSprite.sheet.Texture.SetData(video.FrameData);
} }
Game.Renderer.RgbaSpriteRenderer.DrawSprite(videoSprite, new int2(RenderBounds.X,RenderBounds.Y), "chrome"); Game.Renderer.RgbaSpriteRenderer.DrawSprite(videoSprite, new int2(RenderBounds.X,RenderBounds.Y), "chrome");