mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
vulkan/wsi/wayland: Move color management surface to swapchain.
cc: mesa-stable
This commit is contained in:
parent
a2d765d4bf
commit
99f6c3308c
1 changed files with 23 additions and 22 deletions
|
|
@ -188,8 +188,6 @@ struct wsi_wl_surface {
|
|||
struct vk_instance *instance;
|
||||
|
||||
struct {
|
||||
struct wp_color_management_surface_v1 *color_surface;
|
||||
int color_surface_refcount;
|
||||
VkColorSpaceKHR colorspace;
|
||||
VkHdrMetadataEXT hdr_metadata;
|
||||
bool has_hdr_metadata;
|
||||
|
|
@ -248,6 +246,8 @@ struct wsi_wl_swapchain {
|
|||
} present_ids;
|
||||
|
||||
struct {
|
||||
struct wp_color_management_surface_v1 *color_surface;
|
||||
int color_surface_refcount;
|
||||
VkColorSpaceKHR colorspace;
|
||||
VkHdrMetadataEXT hdr_metadata;
|
||||
bool has_hdr_metadata;
|
||||
|
|
@ -1196,23 +1196,24 @@ needs_color_surface(struct wsi_wl_display *display, VkColorSpaceKHR colorspace)
|
|||
}
|
||||
|
||||
static void
|
||||
wsi_wl_surface_add_color_refcount(struct wsi_wl_surface *wsi_surface)
|
||||
wsi_wl_swapchain_add_color_refcount(struct wsi_wl_swapchain *chain)
|
||||
{
|
||||
wsi_surface->color.color_surface_refcount++;
|
||||
if (wsi_surface->color.color_surface_refcount == 1) {
|
||||
wsi_surface->color.color_surface =
|
||||
struct wsi_wl_surface *wsi_surface = chain->wsi_wl_surface;
|
||||
chain->color.color_surface_refcount++;
|
||||
if (chain->color.color_surface_refcount == 1) {
|
||||
chain->color.color_surface =
|
||||
wp_color_manager_v1_get_surface(wsi_surface->display->color_manager,
|
||||
wsi_surface->wayland_surface.wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
wsi_wl_surface_remove_color_refcount(struct wsi_wl_surface *wsi_surface)
|
||||
wsi_wl_swapchain_remove_color_refcount(struct wsi_wl_swapchain *chain)
|
||||
{
|
||||
wsi_surface->color.color_surface_refcount--;
|
||||
if (wsi_surface->color.color_surface_refcount == 0) {
|
||||
wp_color_management_surface_v1_destroy(wsi_surface->color.color_surface);
|
||||
wsi_surface->color.color_surface = NULL;
|
||||
chain->color.color_surface_refcount--;
|
||||
if (chain->color.color_surface_refcount == 0) {
|
||||
wp_color_management_surface_v1_destroy(chain->color.color_surface);
|
||||
chain->color.color_surface = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1288,14 +1289,14 @@ wsi_wl_swapchain_update_colorspace(struct wsi_wl_swapchain *chain)
|
|||
}
|
||||
}
|
||||
|
||||
bool new_color_surface = !surface->color.color_surface;
|
||||
bool new_color_surface = !chain->color.color_surface;
|
||||
bool needs_color_surface_new = needs_color_surface(display, chain->color.colorspace);
|
||||
bool needs_color_surface_old = surface->color.color_surface &&
|
||||
bool needs_color_surface_old = chain->color.color_surface &&
|
||||
needs_color_surface(display, surface->color.colorspace);
|
||||
if (!needs_color_surface_old && needs_color_surface_new) {
|
||||
wsi_wl_surface_add_color_refcount(surface);
|
||||
wsi_wl_swapchain_add_color_refcount(chain);
|
||||
} else if (needs_color_surface_old && !needs_color_surface_new) {
|
||||
wsi_wl_surface_remove_color_refcount(surface);
|
||||
wsi_wl_swapchain_remove_color_refcount(chain);
|
||||
}
|
||||
|
||||
struct wayland_hdr_metadata wayland_hdr_metadata = {
|
||||
|
|
@ -2207,9 +2208,6 @@ wsi_wl_surface_destroy(VkIcdSurfaceBase *icd_surface, VkInstance _instance,
|
|||
dmabuf_feedback_fini(&wsi_wl_surface->pending_dmabuf_feedback);
|
||||
}
|
||||
|
||||
if (wsi_wl_surface->color.color_surface)
|
||||
wp_color_management_surface_v1_destroy(wsi_wl_surface->color.color_surface);
|
||||
|
||||
loader_wayland_surface_destroy(&wsi_wl_surface->wayland_surface);
|
||||
|
||||
if (wsi_wl_surface->display)
|
||||
|
|
@ -3579,10 +3577,8 @@ wsi_wl_swapchain_chain_free(struct wsi_wl_swapchain *chain,
|
|||
wp_tearing_control_v1_destroy(chain->tearing_control);
|
||||
if (chain->wl_syncobj_surface)
|
||||
wp_linux_drm_syncobj_surface_v1_destroy(chain->wl_syncobj_surface);
|
||||
if (needs_color_surface(wsi_wl_surface->display, chain->color.colorspace) &&
|
||||
wsi_wl_surface->color.color_surface) {
|
||||
wsi_wl_surface_remove_color_refcount(wsi_wl_surface);
|
||||
}
|
||||
if (chain->color.color_surface)
|
||||
wp_color_management_surface_v1_destroy(chain->color.color_surface);
|
||||
|
||||
/* Only unregister if we are the non-retired swapchain, or
|
||||
* we are a retired swapchain and memory allocation failed,
|
||||
|
|
@ -3714,6 +3710,11 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
|
|||
wp_linux_drm_syncobj_surface_v1_destroy(old_chain->wl_syncobj_surface);
|
||||
old_chain->wl_syncobj_surface = NULL;
|
||||
}
|
||||
if (old_chain->color.color_surface) {
|
||||
wp_color_management_surface_v1_destroy(old_chain->color.color_surface);
|
||||
old_chain->color.color_surface_refcount = 0;
|
||||
old_chain->color.color_surface = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Take ownership of the wsi_wl_surface */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue