mirror of
https://github.com/SourMesen/Mesen.git
synced 2025-04-02 10:52:48 -04:00
UI: Improve/simplify resizing logic
This commit is contained in:
parent
63e8fbb839
commit
b63c1f9c4e
6 changed files with 31 additions and 31 deletions
|
@ -32,8 +32,6 @@ void BaseVideoFilter::UpdateBufferSize()
|
|||
_bufferSize = newBufferSize;
|
||||
_outputBuffer = new uint8_t[newBufferSize];
|
||||
_frameLock.Release();
|
||||
|
||||
MessageManager::SendNotification(ConsoleNotificationType::ResolutionChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -635,7 +635,6 @@ public:
|
|||
_overscan.Right = right;
|
||||
_overscan.Top = top;
|
||||
_overscan.Bottom = bottom;
|
||||
MessageManager::SendNotification(ConsoleNotificationType::ResolutionChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,7 +665,10 @@ public:
|
|||
|
||||
static void SetVideoFilterType(VideoFilterType videoFilterType)
|
||||
{
|
||||
_videoFilterType = videoFilterType;
|
||||
if(_videoFilterType != videoFilterType) {
|
||||
_videoScale = videoFilterType == VideoFilterType::None ? 2.0 : 1.0;
|
||||
_videoFilterType = videoFilterType;
|
||||
}
|
||||
}
|
||||
|
||||
static VideoFilterType GetVideoFilterType()
|
||||
|
@ -688,7 +690,6 @@ public:
|
|||
{
|
||||
if(_aspectRatio != aspectRatio) {
|
||||
_aspectRatio = aspectRatio;
|
||||
MessageManager::SendNotification(ConsoleNotificationType::ResolutionChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -753,7 +754,6 @@ public:
|
|||
{
|
||||
if(_videoScale != scale) {
|
||||
_videoScale = scale;
|
||||
MessageManager::SendNotification(ConsoleNotificationType::ResolutionChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ void VideoDecoder::GetScreenSize(ScreenSize &size, bool ignoreScale)
|
|||
if(aspectRatio != 0.0) {
|
||||
size.Width = (uint32_t)(frameInfo.OriginalHeight * scale * aspectRatio * ((double)frameInfo.Width / frameInfo.OriginalWidth));
|
||||
}
|
||||
size.Scale = scale;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,9 +91,16 @@ void VideoDecoder::DecodeFrame()
|
|||
}
|
||||
_videoFilter->SendFrame(_ppuOutputBuffer);
|
||||
|
||||
FrameInfo frameInfo = _videoFilter->GetFrameInfo();
|
||||
if(_previousScale != EmulationSettings::GetVideoScale() || frameInfo.Height != _previousFrameInfo.Height || frameInfo.Width != _previousFrameInfo.Width) {
|
||||
MessageManager::SendNotification(ConsoleNotificationType::ResolutionChanged);
|
||||
}
|
||||
_previousScale = EmulationSettings::GetVideoScale();
|
||||
_previousFrameInfo = frameInfo;
|
||||
|
||||
_frameChanged = false;
|
||||
|
||||
VideoRenderer::GetInstance()->UpdateFrame(_videoFilter->GetOutputBuffer(), _videoFilter->GetFrameInfo().Width, _videoFilter->GetFrameInfo().Height);
|
||||
VideoRenderer::GetInstance()->UpdateFrame(_videoFilter->GetOutputBuffer(), frameInfo.Width, frameInfo.Height);
|
||||
}
|
||||
|
||||
void VideoDecoder::DebugDecodeFrame(uint16_t* inputBuffer, uint32_t* outputBuffer, uint32_t length)
|
||||
|
|
|
@ -7,6 +7,7 @@ using std::thread;
|
|||
#include "../Utilities/AutoResetEvent.h"
|
||||
#include "EmulationSettings.h"
|
||||
#include "HdNesPack.h"
|
||||
#include "FrameInfo.h"
|
||||
|
||||
class BaseVideoFilter;
|
||||
class IRenderingDevice;
|
||||
|
@ -15,6 +16,7 @@ struct ScreenSize
|
|||
{
|
||||
int32_t Width;
|
||||
int32_t Height;
|
||||
double Scale;
|
||||
};
|
||||
|
||||
class VideoDecoder
|
||||
|
@ -33,6 +35,9 @@ private:
|
|||
atomic<bool> _stopFlag;
|
||||
uint32_t _frameCount = 0;
|
||||
|
||||
FrameInfo _previousFrameInfo = {};
|
||||
double _previousScale = 0;
|
||||
|
||||
VideoFilterType _videoFilterType = VideoFilterType::None;
|
||||
unique_ptr<BaseVideoFilter> _videoFilter;
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ namespace Mesen.GUI.Forms
|
|||
private FormWindowState _originalWindowState;
|
||||
private bool _fullscreenMode = false;
|
||||
private double _regularScale = ConfigManager.Config.VideoInfo.VideoScale;
|
||||
private bool _needScaleUpdate = false;
|
||||
private bool _isNsfPlayerMode = false;
|
||||
private object _loadRomLock = new object();
|
||||
private int _romLoadCounter = 0;
|
||||
|
@ -295,17 +294,6 @@ namespace Mesen.GUI.Forms
|
|||
|
||||
private void UpdateVideoSettings()
|
||||
{
|
||||
if(_needScaleUpdate) {
|
||||
//Reset scale to 1 when filter is changed
|
||||
if(this.WindowState == FormWindowState.Maximized || mnuNoneFilter.Checked) {
|
||||
SetScaleBasedOnWindowSize();
|
||||
} else {
|
||||
SetScale(1);
|
||||
}
|
||||
_regularScale = 1;
|
||||
_needScaleUpdate = false;
|
||||
}
|
||||
|
||||
mnuShowFPS.Checked = ConfigManager.Config.VideoInfo.ShowFPS;
|
||||
mnuBilinearInterpolation.Checked = ConfigManager.Config.VideoInfo.UseBilinearInterpolation;
|
||||
UpdateScaleMenu(ConfigManager.Config.VideoInfo.VideoScale);
|
||||
|
@ -324,11 +312,13 @@ namespace Mesen.GUI.Forms
|
|||
} else {
|
||||
if(!_customSize && this.WindowState != FormWindowState.Maximized) {
|
||||
Size sizeGap = this.Size - this.ClientSize;
|
||||
|
||||
_regularScale = size.Scale;
|
||||
UpdateScaleMenu(size.Scale);
|
||||
|
||||
this.Resize -= frmMain_Resize;
|
||||
this.ClientSize = new Size(Math.Max(this.MinimumSize.Width - sizeGap.Width, size.Width), Math.Max(this.MinimumSize.Height - sizeGap.Height, size.Height + menuStrip.Height));
|
||||
this.Resize += frmMain_Resize;
|
||||
} else {
|
||||
SetScaleBasedOnWindowSize();
|
||||
}
|
||||
|
||||
ctrlRenderer.Size = new Size(size.Width, size.Height);
|
||||
|
@ -374,7 +364,6 @@ namespace Mesen.GUI.Forms
|
|||
this.SetScale(_regularScale);
|
||||
this.UpdateScaleMenu(_regularScale);
|
||||
VideoInfo.ApplyConfig();
|
||||
UpdateViewerSize();
|
||||
}
|
||||
this.Resize += frmMain_Resize;
|
||||
|
||||
|
@ -431,7 +420,7 @@ namespace Mesen.GUI.Forms
|
|||
|
||||
case InteropEmu.ConsoleNotificationType.ResolutionChanged:
|
||||
this.BeginInvoke((MethodInvoker)(() => {
|
||||
UpdateVideoSettings();
|
||||
UpdateViewerSize();
|
||||
}));
|
||||
break;
|
||||
|
||||
|
@ -1196,10 +1185,9 @@ namespace Mesen.GUI.Forms
|
|||
|
||||
private void SetVideoFilter(VideoFilterType type)
|
||||
{
|
||||
_customSize = false;
|
||||
InteropEmu.SetVideoFilter(type);
|
||||
UpdateFilterMenu(type);
|
||||
|
||||
_needScaleUpdate = true;
|
||||
}
|
||||
|
||||
private void mnuNoneFilter_Click(object sender, EventArgs e)
|
||||
|
@ -1430,12 +1418,12 @@ namespace Mesen.GUI.Forms
|
|||
|
||||
private void menuStrip_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
IntPtr handle = this.Handle;
|
||||
this.BeginInvoke((MethodInvoker)(() => {
|
||||
if(_fullscreenMode && _customSize) {
|
||||
SetScaleBasedOnWindowSize();
|
||||
}
|
||||
}));
|
||||
if(_fullscreenMode) {
|
||||
IntPtr handle = this.Handle;
|
||||
this.BeginInvoke((MethodInvoker)(() => {
|
||||
this.ctrlRenderer.Top = this.menuStrip.Visible ? -menuStrip.Height : 0;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void mnuAbout_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -563,6 +563,7 @@ namespace Mesen.GUI
|
|||
{
|
||||
public Int32 Width;
|
||||
public Int32 Height;
|
||||
public double Scale;
|
||||
}
|
||||
|
||||
public enum InputDisplayPosition
|
||||
|
|
Loading…
Add table
Reference in a new issue