here's one way of extending the canvas. I dont think it's right. I can't test it now anyway, I'm checking it in for reference. I will probably revert it and do it another way: add a filter after the input filter but before the "emu" surface filter.

This commit is contained in:
zeromus 2015-03-23 03:19:06 +00:00
parent dcea6aeed1
commit dfafee2b25
2 changed files with 55 additions and 5 deletions

View File

@ -120,6 +120,11 @@ namespace BizHawk.Client.EmuHawk
/// </summary>
int currEmuWidth, currEmuHeight;
/// <summary>
/// additional pixels added at the unscaled level for the use of lua drawing. essentially increases the input video provider dimensions
/// </summary>
public System.Windows.Forms.Padding GameExtraPadding;
TextureFrugalizer VideoTextureFrugalizer;
Dictionary<string, TextureFrugalizer> LuaSurfaceFrugalizers = new Dictionary<string, TextureFrugalizer>();
RenderTargetFrugalizer[] ShaderChainFrugalizers;
@ -318,6 +323,8 @@ namespace BizHawk.Client.EmuHawk
/// <summary>
/// Attempts to calculate a good client size with the given zoom factor, considering the user's DisplayManager preferences
/// TODO - this needs to be redone with a concept different from zoom factor.
/// basically, each increment of a 'zoomlike' factor should definitely increase the viewable area somehow, even if it isnt strictly by an entire zoom level.
/// </summary>
public Size CalculateClientSize(IVideoProvider videoProvider, int zoom)
{
@ -339,6 +346,13 @@ namespace BizHawk.Client.EmuHawk
virtualHeight = Global.Config.DispCustomUserARHeight;
}
bufferWidth += GameExtraPadding.Left + GameExtraPadding.Right;
virtualWidth += GameExtraPadding.Left + GameExtraPadding.Right;
bufferHeight += GameExtraPadding.Top + GameExtraPadding.Bottom;
virtualHeight += GameExtraPadding.Top + GameExtraPadding.Bottom;
//Console.WriteLine("DISPZOOM " + zoom); //test
//old stuff
@ -429,6 +443,8 @@ namespace BizHawk.Client.EmuHawk
chain_outsize = new Size(bufferWidth * zoom, bufferHeight * zoom);
}
//add requested lua layer canvas extension
var job = new JobInfo
{
videoProvider = fvp,
@ -477,11 +493,18 @@ namespace BizHawk.Client.EmuHawk
}
}
//vw += GameExtraPadding.Left + GameExtraPadding.Right;
//vh += GameExtraPadding.Top + GameExtraPadding.Bottom;
int[] videoBuffer = videoProvider.GetVideoBuffer();
TESTEROO:
int bufferWidth = videoProvider.BufferWidth;
int bufferHeight = videoProvider.BufferHeight;
//bufferWidth += GameExtraPadding.Left + GameExtraPadding.Right;
//bufferHeight += GameExtraPadding.Top + GameExtraPadding.Bottom;
bool isGlTextureId = videoBuffer.Length == 1;
//TODO - need to do some work here for GDI+ to repair gl texture ID importing
@ -543,6 +566,7 @@ TESTEROO:
//setup the final presentation filter
Filters.FinalPresentation fPresent = filterProgram["presentation"] as Filters.FinalPresentation;
fPresent.InputPadding = GameExtraPadding;
fPresent.VirtualTextureSize = new Size(vw, vh);
fPresent.TextureSize = new Size(bufferWidth, bufferHeight);
fPresent.BackgroundColor = videoProvider.BackgroundColor;

View File

@ -35,13 +35,24 @@ namespace BizHawk.Client.EmuHawk.Filters
public float WidthScale, HeightScale;
//do maths on the viewport and the native resolution and the user settings to get a display rectangle
public LetterboxingLogic(bool maintainAspect, bool maintainInteger, int targetWidth, int targetHeight, int sourceWidth, int sourceHeight, Size textureSize, Size virtualSize)
public LetterboxingLogic(System.Windows.Forms.Padding inputPadding, bool maintainAspect, bool maintainInteger, int targetWidth, int targetHeight, int sourceWidth, int sourceHeight, Size textureSize, Size virtualSize)
{
//when using inputPadding, the output will already be sized to accept it. the inptu size will be untouched.
//heres how we handle it:
//1. pretend the input is larger
int padw = inputPadding.Left + inputPadding.Right;
int padh = inputPadding.Top + inputPadding.Bottom;
int textureWidth = textureSize.Width;
int textureHeight = textureSize.Height;
int virtualWidth = virtualSize.Width;
int virtualHeight = virtualSize.Height;
textureWidth += padw;
textureHeight += padh;
virtualWidth += padw;
virtualHeight += padh;
//zero 02-jun-2014 - we passed these in, but ignored them. kind of weird..
int oldSourceWidth = sourceWidth;
int oldSourceHeight = sourceHeight;
@ -128,13 +139,16 @@ namespace BizHawk.Client.EmuHawk.Filters
PS = trials[bestIndex];
}
vw = (int)(PS.X * textureWidth);
vh = (int)(PS.Y * textureHeight);
//accomodate padding here to keep pixel precision
vw = (int)(PS.X * (textureWidth-padw));
vh = (int)(PS.Y * (textureHeight-padh));
widthScale = PS.X;
heightScale = PS.Y;
}
else
{
widthScale /= (sourceWidth / (float)(sourceWidth - padw));
heightScale /= (sourceHeight / (float)(sourceHeight - padh));
vw = (int)(widthScale * sourceWidth);
vh = (int)(heightScale * sourceHeight);
}
@ -150,6 +164,13 @@ namespace BizHawk.Client.EmuHawk.Filters
//HeightScale = heightScale;
WidthScale = (float)vw / oldSourceWidth;
HeightScale = (float)vh / oldSourceHeight;
//now add the padding, as best we can.
//it's a little hard because: ...
//vx += (int)(inputPadding.Left * WidthScale);
//vy += (int)(inputPadding.Top * HeightScale);
//vx += inputPadding.Left;
//vy += inputPadding.Top;
}
}
@ -178,6 +199,11 @@ namespace BizHawk.Client.EmuHawk.Filters
LetterboxingLogic LL;
Size ContentSize;
/// <summary>
/// How much should padding should be added to the input (for canvas extension)
/// </summary>
public System.Windows.Forms.Padding InputPadding;
public override void Initialize()
{
DeclareInput();
@ -200,7 +226,7 @@ namespace BizHawk.Client.EmuHawk.Filters
if (FilterOption != eFilterOption.Bicubic)
return size;
LL = new LetterboxingLogic(Global.Config.DispFixAspectRatio, Global.Config.DispFixScaleInteger, OutputSize.Width, OutputSize.Height, size.Width, size.Height, TextureSize, VirtualTextureSize);
LL = new LetterboxingLogic(InputPadding, Global.Config.DispFixAspectRatio, Global.Config.DispFixScaleInteger, OutputSize.Width, OutputSize.Height, size.Width, size.Height, TextureSize, VirtualTextureSize);
return size;
}
@ -223,7 +249,7 @@ namespace BizHawk.Client.EmuHawk.Filters
FindInput().SurfaceDisposition = SurfaceDisposition.Texture;
DeclareOutput(new SurfaceState(new SurfaceFormat(OutputSize), SurfaceDisposition.RenderTarget));
InputSize = state.SurfaceFormat.Size;
LL = new LetterboxingLogic(Global.Config.DispFixAspectRatio, Global.Config.DispFixScaleInteger, OutputSize.Width, OutputSize.Height, InputSize.Width, InputSize.Height, TextureSize, VirtualTextureSize);
LL = new LetterboxingLogic(InputPadding, Global.Config.DispFixAspectRatio, Global.Config.DispFixScaleInteger, OutputSize.Width, OutputSize.Height, InputSize.Width, InputSize.Height, TextureSize, VirtualTextureSize);
ContentSize = new Size(LL.vw,LL.vh);
}