basic TransformPoint work

This commit is contained in:
zeromus 2014-10-10 00:15:15 +00:00
parent e28bcf9982
commit 9b6add0e40
4 changed files with 52 additions and 0 deletions
BizHawk.Client.EmuHawk/DisplayManager

View File

@ -247,6 +247,20 @@ namespace BizHawk.Client.EmuHawk
return new Point((int)v.X, (int)v.Y);
}
/// <summary>
/// Using the current filter program, turn a emulator screen space coordinat to a window coordinate (suitable for lua layer drawing)
/// </summary>
public Point TransformPoint(Point p)
{
//now, if theres no filter program active, just give up
if (CurrentFilterProgram == null) return p;
//otherwise, have the filter program untransform it
Vector2 v = new Vector2(p.X, p.Y);
v = CurrentFilterProgram.TransformPoint("default", v);
return new Point((int)v.X, (int)v.Y);
}
/// <summary>
/// This will receive an emulated output frame from an IVideoProvider and run it through the complete frame processing pipeline

View File

@ -94,6 +94,19 @@ namespace BizHawk.Client.EmuHawk.FilterManager
return point;
}
/// <summary>
/// Receives a point in the input space of the filter program and transforms it through to output points
/// </summary>
public Vector2 TransformPoint(string channel, Vector2 point)
{
for (int i = 0; i < Filters.Count; i++)
{
var filter = Filters[i];
point = filter.TransformPoint(channel, point);
}
return point;
}
public class ProgramStep
{
public ProgramStep(ProgramStepType type, object args, string comment = null)

View File

@ -51,6 +51,20 @@ namespace BizHawk.Client.EmuHawk.Filters
}
return point;
}
public virtual Vector2 TransformPoint(string channel, Vector2 point)
{
//base class behaviour here just uses the input and output sizes, if appropriate. few filters will have to do anything more complex
var input = FindInput(channel);
var output = FindOutput(channel);
if (input != null && output != null)
{
point.X *= ((float)output.SurfaceFormat.Size.Width) / (float)input.SurfaceFormat.Size.Width;
point.Y *= ((float)output.SurfaceFormat.Size.Height) / (float)input.SurfaceFormat.Size.Height;
}
return point;
}
public void SetInput(Texture2d tex)
{
InputTexture = tex;

View File

@ -232,6 +232,17 @@ namespace BizHawk.Client.EmuHawk.Filters
return point;
}
public override Vector2 TransformPoint(string channel, Vector2 point)
{
if (nop)
return point;
point.X *= LL.WidthScale;
point.Y *= LL.HeightScale;
point.X += LL.vx;
point.Y += LL.vy;
return point;
}
public override void Run()
{
if (nop)