Skip to content

Commit

Permalink
Merge pull request #6330 from stenzek/resizing
Browse files Browse the repository at this point in the history
Improve handling of surface change/resize events in graphics backends
  • Loading branch information
stenzek committed Feb 19, 2018
2 parents 456c2f4 + 0dddaf9 commit 93c502f
Show file tree
Hide file tree
Showing 20 changed files with 362 additions and 353 deletions.
Expand Up @@ -420,8 +420,8 @@ private void runWithValidSurface()
else if (state == State.PAUSED)
{
Log.debug("[EmulationFragment] Resuming emulation.");
NativeLibrary.UnPauseEmulation();
NativeLibrary.SurfaceChanged(mSurface);
NativeLibrary.UnPauseEmulation();
}
else
{
Expand Down
6 changes: 1 addition & 5 deletions Source/Core/DolphinNoGUI/MainNoGUI.cpp
Expand Up @@ -321,12 +321,8 @@ class PlatformX11 : public Platform
{
last_window_width = event.xconfigure.width;
last_window_height = event.xconfigure.height;

// We call Renderer::ChangeSurface here to indicate the size has changed,
// but pass the same window handle. This is needed for the Vulkan backend,
// otherwise it cannot tell that the window has been resized on some drivers.
if (g_renderer)
g_renderer->ChangeSurface(s_window_handle);
g_renderer->ResizeSurface(last_window_width, last_window_height);
}
}
break;
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinQt2/Host.cpp
Expand Up @@ -51,10 +51,10 @@ void Host::SetRenderFullscreen(bool fullscreen)
m_render_fullscreen = fullscreen;
}

void Host::UpdateSurface()
void Host::ResizeSurface(int new_width, int new_height)
{
if (g_renderer)
g_renderer->ChangeSurface(GetRenderHandle());
g_renderer->ResizeSurface(new_width, new_height);
}

void Host_Message(int id)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt2/Host.h
Expand Up @@ -26,7 +26,7 @@ class Host final : public QObject
void SetRenderHandle(void* handle);
void SetRenderFocus(bool focus);
void SetRenderFullscreen(bool fullscreen);
void UpdateSurface();
void ResizeSurface(int new_width, int new_height);

signals:
void RequestTitle(const QString& title);
Expand Down
8 changes: 6 additions & 2 deletions Source/Core/DolphinQt2/RenderWidget.cpp
Expand Up @@ -22,7 +22,7 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
Qt::DirectConnection);
connect(this, &RenderWidget::HandleChanged, Host::GetInstance(), &Host::SetRenderHandle,
Qt::DirectConnection);
connect(this, &RenderWidget::SizeChanged, Host::GetInstance(), &Host::UpdateSurface,
connect(this, &RenderWidget::SizeChanged, Host::GetInstance(), &Host::ResizeSurface,
Qt::DirectConnection);

emit HandleChanged((void*)winId());
Expand Down Expand Up @@ -84,8 +84,12 @@ bool RenderWidget::event(QEvent* event)
Host::GetInstance()->SetRenderFocus(false);
break;
case QEvent::Resize:
emit SizeChanged();
{
const QResizeEvent* se = static_cast<QResizeEvent*>(event);
QSize new_size = se->size();
emit SizeChanged(new_size.width(), new_size.height());
break;
}
case QEvent::WindowStateChange:
emit StateChanged(isFullScreen());
break;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt2/RenderWidget.h
Expand Up @@ -23,7 +23,7 @@ class RenderWidget final : public QWidget
void Closed();
void HandleChanged(void* handle);
void StateChanged(bool fullscreen);
void SizeChanged();
void SizeChanged(int new_width, int new_height);

private:
void HandleCursorTimer();
Expand Down
7 changes: 2 additions & 5 deletions Source/Core/DolphinWX/FrameTools.cpp
Expand Up @@ -603,21 +603,18 @@ void CFrame::OnRenderParentResize(wxSizeEvent& event)
if (Core::GetState() != Core::State::Uninitialized)
{
int width, height;
m_render_frame->GetClientSize(&width, &height);
if (!SConfig::GetInstance().bRenderToMain && !RendererIsFullscreen() &&
!m_render_frame->IsMaximized() && !m_render_frame->IsIconized())
{
m_render_frame->GetClientSize(&width, &height);
SConfig::GetInstance().iRenderWindowWidth = width;
SConfig::GetInstance().iRenderWindowHeight = height;
}
m_log_window->Refresh();
m_log_window->Update();

// We call Renderer::ChangeSurface here to indicate the size has changed,
// but pass the same window handle. This is needed for the Vulkan backend,
// otherwise it cannot tell that the window has been resized on some drivers.
if (g_renderer)
g_renderer->ChangeSurface(GetRenderHandle());
g_renderer->ResizeSurface(width, height);
}
event.Skip();
}
Expand Down

0 comments on commit 93c502f

Please sign in to comment.