a\v dumping now uses a composited emu+osd+lua. (at the moment this is not toggleable; a setting must be added)
this needs a little work, but is functional...
This commit is contained in:
parent
3c6549a7bb
commit
e10e351e03
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace BizHawk.MultiClient.AVOut
|
||||
{
|
||||
/// <summary>
|
||||
/// an IVideoProivder wrapping a Bitmap
|
||||
/// </summary>
|
||||
public class BmpVideoProvder : IVideoProvider
|
||||
{
|
||||
Bitmap bmp;
|
||||
public BmpVideoProvder(Bitmap bmp)
|
||||
{
|
||||
this.bmp = bmp;
|
||||
}
|
||||
|
||||
public int[] GetVideoBuffer()
|
||||
{
|
||||
// is there a faster way to do this?
|
||||
var data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
|
||||
int[] ret = new int[bmp.Width * bmp.Height];
|
||||
|
||||
// won't work if stride is messed up
|
||||
System.Runtime.InteropServices.Marshal.Copy(data.Scan0, ret, 0, bmp.Width * bmp.Height);
|
||||
bmp.UnlockBits(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int VirtualWidth
|
||||
{
|
||||
// todo: Bitmap actually has size metric data; use it
|
||||
get { return bmp.Width; }
|
||||
}
|
||||
|
||||
public int BufferWidth
|
||||
{
|
||||
get { return bmp.Width; }
|
||||
}
|
||||
|
||||
public int BufferHeight
|
||||
{
|
||||
get { return bmp.Height; }
|
||||
}
|
||||
|
||||
public int BackgroundColor
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -114,6 +114,7 @@
|
|||
<DependentUpon>ArchiveChooser.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AVOut\AviWriter.cs" />
|
||||
<Compile Include="AVOut\BmpVideoProvder.cs" />
|
||||
<Compile Include="AVOut\FFmpegWriter.cs" />
|
||||
<Compile Include="AVOut\FFmpegWriterForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
|
|
@ -598,17 +598,27 @@ namespace BizHawk.MultiClient
|
|||
luaEmuSurface = luaEmuSurfaceSet.GetCurrent();
|
||||
}
|
||||
|
||||
/// <summary>update Global.RenderPanel from the passed IVideoProvider</summary>
|
||||
public void UpdateSource(IVideoProvider videoProvider)
|
||||
{
|
||||
UpdateSourceEx(videoProvider, Global.RenderPanel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// update the passed IRenderer with the passed IVideoProvider
|
||||
/// </summary>
|
||||
/// <param name="videoProvider"></param>
|
||||
/// <param name="renderPanel">also must implement IBlitter</param>
|
||||
public void UpdateSourceEx(IVideoProvider videoProvider, IRenderer renderPanel)
|
||||
{
|
||||
var newPendingSurface = sourceSurfaceSet.AllocateSurface(videoProvider.BufferWidth, videoProvider.BufferHeight, false);
|
||||
newPendingSurface.AcceptIntArray(videoProvider.GetVideoBuffer());
|
||||
sourceSurfaceSet.SetPending(newPendingSurface);
|
||||
|
||||
var renderPanel = Global.RenderPanel;
|
||||
if (renderPanel == null) return;
|
||||
|
||||
currNativeWidth = Global.RenderPanel.NativeSize.Width;
|
||||
currNativeHeight = Global.RenderPanel.NativeSize.Height;
|
||||
currNativeWidth = renderPanel.NativeSize.Width;
|
||||
currNativeHeight = renderPanel.NativeSize.Height;
|
||||
|
||||
currentSourceSurface = sourceSurfaceSet.GetCurrent();
|
||||
|
||||
|
@ -634,16 +644,16 @@ namespace BizHawk.MultiClient
|
|||
DisplaySurface surfaceToRender = filteredSurface;
|
||||
if (surfaceToRender == null) surfaceToRender = currentSourceSurface;
|
||||
|
||||
Global.RenderPanel.Clear(Color.FromArgb(videoProvider.BackgroundColor));
|
||||
Global.RenderPanel.Render(surfaceToRender);
|
||||
renderPanel.Clear(Color.FromArgb(videoProvider.BackgroundColor));
|
||||
renderPanel.Render(surfaceToRender);
|
||||
if (luaEmuSurface != null)
|
||||
{
|
||||
Global.RenderPanel.RenderOverlay(luaEmuSurface);
|
||||
renderPanel.RenderOverlay(luaEmuSurface);
|
||||
}
|
||||
|
||||
RenderOSD();
|
||||
RenderOSD((IBlitter)renderPanel);
|
||||
|
||||
Global.RenderPanel.Present();
|
||||
renderPanel.Present();
|
||||
|
||||
if (filteredSurface != null)
|
||||
filteredSurface.Dispose();
|
||||
|
@ -700,13 +710,13 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
}
|
||||
|
||||
void RenderOSD()
|
||||
void RenderOSD(IBlitter renderPanel)
|
||||
{
|
||||
Global.OSD.Begin((IBlitter)Global.RenderPanel);
|
||||
((IBlitter)Global.RenderPanel).Open();
|
||||
Global.OSD.DrawScreenInfo((IBlitter)Global.RenderPanel);
|
||||
Global.OSD.DrawMessages((IBlitter)Global.RenderPanel);
|
||||
((IBlitter)Global.RenderPanel).Close();
|
||||
Global.OSD.Begin(renderPanel);
|
||||
renderPanel.Open();
|
||||
Global.OSD.DrawScreenInfo(renderPanel);
|
||||
Global.OSD.DrawMessages(renderPanel);
|
||||
renderPanel.Close();
|
||||
}
|
||||
|
||||
void CheckFilter()
|
||||
|
|
|
@ -2132,7 +2132,34 @@ namespace BizHawk.MultiClient
|
|||
//DumpProxy.GetSamples(temp);
|
||||
//genSound = false;
|
||||
|
||||
CurrAviWriter.AddFrame(Global.Emulator.VideoProvider);
|
||||
// TODO: WRAP ME IN SOME UI SETTING
|
||||
if (true)
|
||||
{
|
||||
// this code captures the emu display with OSD and lua composited onto it.
|
||||
|
||||
// it's slow and a bit hackish; a better solution is to create a new
|
||||
// "dummy render" class that implements IRenderer, IBlitter, and possibly
|
||||
// IVideoProvider, and pass that to DisplayManager.UpdateSourceEx()
|
||||
|
||||
var c = new RetainedViewportPanel();
|
||||
// this size can be different for showing off stretching or filters
|
||||
c.Width = Global.Emulator.VideoProvider.BufferWidth;
|
||||
c.Height = Global.Emulator.VideoProvider.BufferHeight;
|
||||
var s = new SysdrawingRenderPanel(c);
|
||||
|
||||
Global.DisplayManager.UpdateSourceEx(Global.Emulator.VideoProvider, s);
|
||||
|
||||
var b = new AVOut.BmpVideoProvder(c.GetBitmap());
|
||||
|
||||
CurrAviWriter.AddFrame(b);
|
||||
|
||||
s.Dispose();
|
||||
c.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrAviWriter.AddFrame(Global.Emulator.VideoProvider);
|
||||
}
|
||||
CurrAviWriter.AddSamples(temp);
|
||||
|
||||
if (autoDumpLength > 0)
|
||||
|
|
|
@ -138,6 +138,13 @@ namespace BizHawk.Core
|
|||
|
||||
Bitmap bmp;
|
||||
|
||||
/// <summary>bit of a hack; use at your own risk</summary>
|
||||
/// <returns>you probably shouldn't modify this?</returns>
|
||||
public Bitmap GetBitmap()
|
||||
{
|
||||
return bmp;
|
||||
}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs pevent)
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in New Issue