mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-10 12:40:10 +00:00
vulkan: Add a vfunc to query image size
Just split out the function where we do it, so we can do scale factor specific sizing in the backends. In particular, this avoids the need to encode Wayland's rules into GdkVulkanContext and keep them local to the backend.
This commit is contained in:
parent
b541435d46
commit
9bcb3c9f22
@ -399,6 +399,15 @@ gdk_vulkan_context_dispose (GObject *gobject)
|
||||
G_OBJECT_CLASS (gdk_vulkan_context_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_vulkan_context_get_image_size (GdkVulkanContext *context,
|
||||
VkExtent2D *size)
|
||||
{
|
||||
GDK_VULKAN_CONTEXT_GET_CLASS (context)->get_image_size (context,
|
||||
&size->width,
|
||||
&size->height);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
|
||||
GError **error)
|
||||
@ -458,7 +467,6 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
|
||||
capabilities.currentExtent.width,
|
||||
capabilities.currentExtent.height);
|
||||
|
||||
|
||||
/*
|
||||
* Per https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/xhtml/vkspec.html#VkSurfaceCapabilitiesKHR
|
||||
* the current extent may assume a special value, meaning that the extent should assume whatever
|
||||
@ -466,10 +474,7 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
|
||||
*/
|
||||
if (capabilities.currentExtent.width == -1 || capabilities.currentExtent.height == -1)
|
||||
{
|
||||
double scale = gdk_surface_get_scale (surface);
|
||||
|
||||
capabilities.currentExtent.width = MAX (1, (int) ceil (gdk_surface_get_width (surface) * scale));
|
||||
capabilities.currentExtent.height = MAX (1, (int) ceil (gdk_surface_get_height (surface) * scale));
|
||||
gdk_vulkan_context_get_image_size (context, &capabilities.currentExtent);
|
||||
|
||||
GDK_DEBUG (VULKAN, "Effective extent %dx%d",
|
||||
capabilities.currentExtent.width,
|
||||
@ -832,6 +837,20 @@ gdk_vulkan_context_surface_resized (GdkDrawContext *draw_context)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_vulkan_context_get_default_image_size (GdkVulkanContext *context,
|
||||
uint32_t *width,
|
||||
uint32_t *height)
|
||||
{
|
||||
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
||||
double scale;
|
||||
|
||||
scale = gdk_surface_get_scale (surface);
|
||||
|
||||
*width = MAX (1, (uint32_t) ceil (gdk_surface_get_width (surface) * scale));
|
||||
*height = MAX (1, (uint32_t) ceil (gdk_surface_get_height (surface) * scale));
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_vulkan_context_class_init (GdkVulkanContextClass *klass)
|
||||
{
|
||||
@ -844,6 +863,8 @@ gdk_vulkan_context_class_init (GdkVulkanContextClass *klass)
|
||||
draw_context_class->end_frame = gdk_vulkan_context_end_frame;
|
||||
draw_context_class->surface_resized = gdk_vulkan_context_surface_resized;
|
||||
|
||||
klass->get_image_size = gdk_vulkan_context_get_default_image_size;
|
||||
|
||||
/**
|
||||
* GdkVulkanContext::images-updated:
|
||||
* @context: the object on which the signal is emitted
|
||||
|
@ -50,14 +50,18 @@ struct _GdkVulkanContextClass
|
||||
GdkDrawContextClass parent_class;
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
VkResult (* create_surface) (GdkVulkanContext *context,
|
||||
VkSurfaceKHR *surface);
|
||||
VkResult (* create_surface) (GdkVulkanContext *context,
|
||||
VkSurfaceKHR *surface);
|
||||
void (* get_image_size) (GdkVulkanContext *context,
|
||||
uint32_t *out_width,
|
||||
uint32_t *out_height);
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
|
||||
const char * gdk_vulkan_strerror (VkResult result);
|
||||
const char * gdk_vulkan_strerror (VkResult result);
|
||||
|
||||
static inline VkResult
|
||||
gdk_vulkan_handle_result (VkResult res,
|
||||
|
Loading…
Reference in New Issue
Block a user