mirror of https://github.com/snes9xgit/snes9x.git
Wayland: Reorder resizing operations
Ensure a buffer is in place before calling viewporter.
This commit is contained in:
parent
9b77335345
commit
f0001ab428
|
@ -119,11 +119,9 @@ bool WaylandEGLContext::create_context()
|
|||
|
||||
void WaylandEGLContext::resize(WaylandSurface::Metrics m)
|
||||
{
|
||||
wayland_surface->resize(m);
|
||||
|
||||
std::tie(width, height) = wayland_surface->get_size();
|
||||
std::tie(width, height) = wayland_surface->get_size_for_metrics(m);
|
||||
wl_egl_window_resize(egl_window, width, height, 0, 0);
|
||||
|
||||
wayland_surface->resize(m);
|
||||
make_current();
|
||||
}
|
||||
|
||||
|
|
|
@ -148,12 +148,17 @@ bool WaylandSurface::attach(wl_display *display, wl_surface *surface, Metrics m)
|
|||
|
||||
std::tuple<int, int> WaylandSurface::get_size()
|
||||
{
|
||||
if (actual_scale == 0.0)
|
||||
{
|
||||
return { metrics.width * metrics.scale, metrics.height * metrics.scale };
|
||||
return get_size_for_metrics(metrics);
|
||||
}
|
||||
|
||||
return { round(metrics.width * actual_scale), round(metrics.height * actual_scale) };
|
||||
std::tuple<int, int> WaylandSurface::get_size_for_metrics(Metrics m)
|
||||
{
|
||||
if (actual_scale == 0.0)
|
||||
{
|
||||
return { m.width * m.scale, m.height * m.scale };
|
||||
}
|
||||
|
||||
return { round(m.width * actual_scale), round(m.height * actual_scale) };
|
||||
}
|
||||
|
||||
void WaylandSurface::resize(Metrics m)
|
||||
|
|
|
@ -23,6 +23,7 @@ class WaylandSurface
|
|||
bool attach(wl_display *display, wl_surface *surface, Metrics source_metrics);
|
||||
void resize(Metrics new_metrics);
|
||||
std::tuple<int, int> get_size();
|
||||
std::tuple<int, int> get_size_for_metrics(Metrics m);
|
||||
|
||||
struct wl_display *display;
|
||||
struct wl_registry *registry;
|
||||
|
|
|
@ -91,10 +91,7 @@ void S9xVulkanDisplayDriver::refresh()
|
|||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (GDK_IS_WAYLAND_WINDOW(drawing_area->get_window()->gobj()))
|
||||
{
|
||||
wayland_surface->resize(get_metrics(*drawing_area));
|
||||
std::tie(new_width, new_height) = wayland_surface->get_size();
|
||||
}
|
||||
std::tie(new_width, new_height) = wayland_surface->get_size_for_metrics(get_metrics(*drawing_area));
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
@ -108,6 +105,11 @@ void S9xVulkanDisplayDriver::refresh()
|
|||
context->wait_idle();
|
||||
current_width = new_width;
|
||||
current_height = new_height;
|
||||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if (GDK_IS_WAYLAND_WINDOW(drawing_area->get_window()->gobj()))
|
||||
wayland_surface->resize(get_metrics(*drawing_area));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -220,19 +220,23 @@ void EmuCanvasVulkan::resizeEvent(QResizeEvent *event)
|
|||
if (!context)
|
||||
return;
|
||||
|
||||
int width = event->size().width();
|
||||
int height = event->size().height();
|
||||
|
||||
context->swapchain->set_vsync(config->enable_vsync);
|
||||
|
||||
#ifndef _WIN32
|
||||
if (platform == "wayland")
|
||||
{
|
||||
wayland_surface->resize({ parent->x() - main_window->x(), parent->y() - main_window->y(), width, height, (int)devicePixelRatio() });
|
||||
std::tie(width, height) = wayland_surface->get_size();
|
||||
// On Wayland, Vulkan WSI provides the buffer for the subsurface,
|
||||
// so we have to specify a width and height instead of polling the parent.
|
||||
WaylandSurface::Metrics m = {
|
||||
parent->x() - main_window->x(),
|
||||
parent->y() - main_window->y(),
|
||||
event->size().width(),
|
||||
event->size().height(),
|
||||
(int)devicePixelRatio()
|
||||
};
|
||||
|
||||
auto [width, height] = wayland_surface->get_size_for_metrics(m);
|
||||
context->swapchain->check_and_resize(width, height);
|
||||
|
||||
wayland_surface->resize(m);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue