bad attempt at implementing user crop area. need to do differently. needs to happen.. like... as soon as we get the video provider.
This commit is contained in:
parent
cecdff8293
commit
578bb546f3
|
@ -222,6 +222,30 @@ namespace BizHawk.Client.EmuHawk
|
||||||
//add the first filter, encompassing output from the emulator core
|
//add the first filter, encompassing output from the emulator core
|
||||||
chain.AddFilter(fInput, "input");
|
chain.AddFilter(fInput, "input");
|
||||||
|
|
||||||
|
Size currSize = chain_insize;
|
||||||
|
|
||||||
|
//apply user's choice of cropping
|
||||||
|
//NOTE 1. this is going to break the positioning of elements in lua
|
||||||
|
//we COULD change how this works to apply it at a different point; but let's wait for someone to ask for it
|
||||||
|
//we can offer "fix the lua script" as a response, as well, to rebuff them
|
||||||
|
//NOTE 2. this is an inefficient way of doing it. this could be done if we use 'art' everywhere instead of textures.
|
||||||
|
//then, we could adjust the uv coords and carry on, rather than doing this extra resolving step.
|
||||||
|
//Well.... not today
|
||||||
|
int cropX = Global.Config.DispCropLeft + Global.Config.DispCropRight;
|
||||||
|
int cropY = Global.Config.DispCropTop + Global.Config.DispCropBottom;
|
||||||
|
if (cropX != 0 || cropY != 0)
|
||||||
|
{
|
||||||
|
currSize.Width -= cropX;
|
||||||
|
currSize.Height -= cropY;
|
||||||
|
|
||||||
|
Filters.FinalPresentation fCrop = new Filters.FinalPresentation(currSize);
|
||||||
|
fCrop.Config_Crop = true;
|
||||||
|
fCrop.Crop = new Rectangle(Global.Config.DispCropLeft, Global.Config.DispCropTop, cropX, cropY);
|
||||||
|
fCrop.GuiRenderer = Renderer;
|
||||||
|
fCrop.GL = GL;
|
||||||
|
chain.AddFilter(fCrop, "crop");
|
||||||
|
}
|
||||||
|
|
||||||
//if a non-zero padding is required, add a filter to allow for that
|
//if a non-zero padding is required, add a filter to allow for that
|
||||||
//note, we have two sources of padding right now.. one can come from the videoprovider and one from the user.
|
//note, we have two sources of padding right now.. one can come from the videoprovider and one from the user.
|
||||||
//we're combining these now and just using black, for sake of being lean, despite the discussion below:
|
//we're combining these now and just using black, for sake of being lean, despite the discussion below:
|
||||||
|
@ -231,7 +255,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (padding.Vertical != 0 || padding.Horizontal != 0)
|
if (padding.Vertical != 0 || padding.Horizontal != 0)
|
||||||
{
|
{
|
||||||
//TODO - add another filter just for this, its cumbersome to use final presentation... I think. but maybe theres enough similarities to justify it.
|
//TODO - add another filter just for this, its cumbersome to use final presentation... I think. but maybe theres enough similarities to justify it.
|
||||||
Size size = chain_insize;
|
Size size = currSize;
|
||||||
size.Width += padding.Horizontal;
|
size.Width += padding.Horizontal;
|
||||||
size.Height += padding.Vertical;
|
size.Height += padding.Vertical;
|
||||||
Filters.FinalPresentation fPadding = new Filters.FinalPresentation(size);
|
Filters.FinalPresentation fPadding = new Filters.FinalPresentation(size);
|
||||||
|
@ -628,10 +652,18 @@ namespace BizHawk.Client.EmuHawk
|
||||||
bool simulate = job.simulate;
|
bool simulate = job.simulate;
|
||||||
Size chain_outsize = job.chain_outsize;
|
Size chain_outsize = job.chain_outsize;
|
||||||
|
|
||||||
|
int vpWidth = videoProvider.BufferWidth;
|
||||||
|
int vpHeight = videoProvider.BufferHeight;
|
||||||
|
|
||||||
|
//the easiest way to implement crop now is to do it early by adapting the videoprovider
|
||||||
|
//it might be more performant to integrate it into the filter chain somehow, but that's hard
|
||||||
|
int cropX = Global.Config.DispCropLeft + Global.Config.DispCropRight;
|
||||||
|
int cropY = Global.Config.DispCropTop + Global.Config.DispCropBottom;
|
||||||
|
|
||||||
//simulate = true;
|
//simulate = true;
|
||||||
|
|
||||||
int vw = videoProvider.BufferWidth;
|
int vw = vpWidth;
|
||||||
int vh = videoProvider.BufferHeight;
|
int vh = vpHeight;
|
||||||
|
|
||||||
if (Global.Config.DispFixAspectRatio)
|
if (Global.Config.DispFixAspectRatio)
|
||||||
{
|
{
|
||||||
|
@ -647,7 +679,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
if (Global.Config.DispManagerAR == Config.EDispManagerAR.CustomRatio)
|
if (Global.Config.DispManagerAR == Config.EDispManagerAR.CustomRatio)
|
||||||
{
|
{
|
||||||
FixRatio(Global.Config.DispCustomUserARX, Global.Config.DispCustomUserARY, videoProvider.BufferWidth, videoProvider.BufferHeight, out vw, out vh);
|
FixRatio(Global.Config.DispCustomUserARX, Global.Config.DispCustomUserARY, vpWidth, vpHeight, out vw, out vh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,8 +689,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
int[] videoBuffer = videoProvider.GetVideoBuffer();
|
int[] videoBuffer = videoProvider.GetVideoBuffer();
|
||||||
|
|
||||||
int bufferWidth = videoProvider.BufferWidth;
|
int bufferWidth = vpWidth;
|
||||||
int bufferHeight = videoProvider.BufferHeight;
|
int bufferHeight = vpHeight;
|
||||||
bool isGlTextureId = videoBuffer.Length == 1;
|
bool isGlTextureId = videoBuffer.Length == 1;
|
||||||
|
|
||||||
BitmapBuffer bb = null;
|
BitmapBuffer bb = null;
|
||||||
|
@ -669,6 +701,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
//FYI: this is a million years from happening on n64, since it's all geriatric non-FBO code
|
//FYI: this is a million years from happening on n64, since it's all geriatric non-FBO code
|
||||||
//is it workable for saturn?
|
//is it workable for saturn?
|
||||||
|
//TODO - this won't respect the user's selected crop. please don't crop this platform or else I'll have to implement this through the
|
||||||
videoTexture = GL.WrapGLTexture2d(new IntPtr(videoBuffer[0]), bufferWidth, bufferHeight);
|
videoTexture = GL.WrapGLTexture2d(new IntPtr(videoBuffer[0]), bufferWidth, bufferHeight);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -685,6 +718,17 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////apply user's choice of cropping
|
||||||
|
//int cropX = Global.Config.DispCropLeft + Global.Config.DispCropRight;
|
||||||
|
//int cropY = Global.Config.DispCropTop + Global.Config.DispCropBottom;
|
||||||
|
//bufferWidth -= cropX;
|
||||||
|
//bufferHeight -= cropY;
|
||||||
|
|
||||||
|
//Art videoTextureArt = new Art(videoTexture);
|
||||||
|
//videoTextureArt.Width -= cropX;
|
||||||
|
//videoTextureArt.Height -= cropY;
|
||||||
|
//videoTextureArt.u
|
||||||
|
|
||||||
//record the size of what we received, since lua and stuff is gonna want to draw onto it
|
//record the size of what we received, since lua and stuff is gonna want to draw onto it
|
||||||
currEmuWidth = bufferWidth;
|
currEmuWidth = bufferWidth;
|
||||||
currEmuHeight = bufferHeight;
|
currEmuHeight = bufferHeight;
|
||||||
|
|
|
@ -181,9 +181,9 @@ namespace BizHawk.Client.EmuHawk.Filters
|
||||||
public eFilterOption FilterOption = eFilterOption.None;
|
public eFilterOption FilterOption = eFilterOption.None;
|
||||||
public RetroShaderChain BicubicFilter;
|
public RetroShaderChain BicubicFilter;
|
||||||
|
|
||||||
public FinalPresentation(Size size)
|
public FinalPresentation(Size outputSize)
|
||||||
{
|
{
|
||||||
this.OutputSize = size;
|
this.OutputSize = outputSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size OutputSize, InputSize;
|
Size OutputSize, InputSize;
|
||||||
|
@ -194,11 +194,14 @@ namespace BizHawk.Client.EmuHawk.Filters
|
||||||
public bool Flip;
|
public bool Flip;
|
||||||
public IGL GL;
|
public IGL GL;
|
||||||
bool nop;
|
bool nop;
|
||||||
|
public Rectangle Crop;
|
||||||
LetterboxingLogic LL;
|
LetterboxingLogic LL;
|
||||||
Size ContentSize;
|
Size ContentSize;
|
||||||
|
|
||||||
public bool Config_FixAspectRatio, Config_FixScaleInteger, Config_PadOnly;
|
public bool Config_FixAspectRatio, Config_FixScaleInteger, Config_PadOnly;
|
||||||
|
|
||||||
|
public bool Config_Crop;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// only use with Config_PadOnly
|
/// only use with Config_PadOnly
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -223,6 +226,15 @@ namespace BizHawk.Client.EmuHawk.Filters
|
||||||
|
|
||||||
public override Size PresizeInput(string channel, Size size)
|
public override Size PresizeInput(string channel, Size size)
|
||||||
{
|
{
|
||||||
|
if (Config_Crop)
|
||||||
|
{
|
||||||
|
LL = new LetterboxingLogic();
|
||||||
|
LL.vx += -Crop.Left;
|
||||||
|
LL.vy += -Crop.Top;
|
||||||
|
LL.vw = size.Width - Crop.Width;
|
||||||
|
LL.vh = size.Height - Crop.Height;
|
||||||
|
}
|
||||||
|
|
||||||
if (FilterOption != eFilterOption.Bicubic)
|
if (FilterOption != eFilterOption.Bicubic)
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
|
@ -265,7 +277,11 @@ namespace BizHawk.Client.EmuHawk.Filters
|
||||||
FindInput().SurfaceDisposition = SurfaceDisposition.Texture;
|
FindInput().SurfaceDisposition = SurfaceDisposition.Texture;
|
||||||
DeclareOutput(new SurfaceState(new SurfaceFormat(OutputSize), SurfaceDisposition.RenderTarget));
|
DeclareOutput(new SurfaceState(new SurfaceFormat(OutputSize), SurfaceDisposition.RenderTarget));
|
||||||
InputSize = state.SurfaceFormat.Size;
|
InputSize = state.SurfaceFormat.Size;
|
||||||
if (Config_PadOnly)
|
if (Config_Crop)
|
||||||
|
{
|
||||||
|
int zzz = 9;
|
||||||
|
}
|
||||||
|
else if (Config_PadOnly)
|
||||||
{
|
{
|
||||||
//TODO - redundant fix
|
//TODO - redundant fix
|
||||||
LL = new LetterboxingLogic();
|
LL = new LetterboxingLogic();
|
||||||
|
@ -286,6 +302,7 @@ namespace BizHawk.Client.EmuHawk.Filters
|
||||||
LL.vx += Padding.Left;
|
LL.vx += Padding.Left;
|
||||||
LL.vy += Padding.Top;
|
LL.vy += Padding.Top;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentSize = new Size(LL.vw,LL.vh);
|
ContentSize = new Size(LL.vw,LL.vh);
|
||||||
|
|
||||||
if (InputSize == OutputSize) //any reason we need to check vx and vy?
|
if (InputSize == OutputSize) //any reason we need to check vx and vy?
|
||||||
|
@ -343,7 +360,9 @@ namespace BizHawk.Client.EmuHawk.Filters
|
||||||
GuiRenderer.Modelview.Scale(1, -1);
|
GuiRenderer.Modelview.Scale(1, -1);
|
||||||
GuiRenderer.Modelview.Translate(0, -LL.vh);
|
GuiRenderer.Modelview.Translate(0, -LL.vh);
|
||||||
}
|
}
|
||||||
GuiRenderer.Draw(InputTexture,0,0,LL.vw,LL.vh);
|
if (Config_Crop)
|
||||||
|
GuiRenderer.Draw(InputTexture, 0, 0, InputSize.Width, InputSize.Height);
|
||||||
|
else GuiRenderer.Draw(InputTexture, 0, 0, LL.vw, LL.vh);
|
||||||
|
|
||||||
GuiRenderer.End();
|
GuiRenderer.End();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue