linux-dmabuf: replace assert with the new weston-assert

Make use of the new weston-assert in linux-dmabuf.c

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
Leandro Ribeiro 2023-09-25 18:10:32 -03:00 committed by Marius Vlad
parent d2b70d2fa9
commit 08018d3a28
4 changed files with 27 additions and 21 deletions

View file

@ -425,7 +425,7 @@ dmabuf_feedback_maybe_update(struct drm_device *device, struct weston_view *ev,
drm_debug(b, "\t[repaint] Need to update and resend the "
"dma-buf feedback for surface of view %p\n", ev);
weston_dmabuf_feedback_send_all(dmabuf_feedback,
weston_dmabuf_feedback_send_all(b->compositor, dmabuf_feedback,
b->compositor->dmabuf_feedback_format_table);
/* Set the timer to off */

View file

@ -2542,7 +2542,7 @@ weston_buffer_from_resource(struct weston_compositor *ec,
if (!buffer->pixel_format || buffer->pixel_format->hide_from_clients)
goto fail;
} else if ((dmabuf = linux_dmabuf_buffer_get(buffer->resource))) {
} else if ((dmabuf = linux_dmabuf_buffer_get(ec, buffer->resource))) {
buffer->type = WESTON_BUFFER_DMABUF;
buffer->dmabuf = dmabuf;
buffer->direct_display = dmabuf->direct_display;

View file

@ -25,7 +25,6 @@
#include "config.h"
#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <unistd.h>
@ -39,6 +38,7 @@
#include "shared/os-compatibility.h"
#include "shared/helpers.h"
#include "libweston-internal.h"
#include "shared/weston-assert.h"
#include "shared/weston-drm-fourcc.h"
static void
@ -95,8 +95,8 @@ params_add(struct wl_client *client,
return;
}
assert(buffer->params_resource == params_resource);
assert(!buffer->buffer_resource);
weston_assert_ptr_eq(buffer->compositor, buffer->params_resource, params_resource);
weston_assert_ptr_is_null(buffer->compositor, buffer->buffer_resource);
if (plane_idx >= MAX_DMABUF_PLANES) {
wl_resource_post_error(params_resource,
@ -144,8 +144,8 @@ destroy_linux_dmabuf_wl_buffer(struct wl_resource *resource)
struct linux_dmabuf_buffer *buffer;
buffer = wl_resource_get_user_data(resource);
assert(buffer->buffer_resource == resource);
assert(!buffer->params_resource);
weston_assert_ptr_eq(buffer->compositor, buffer->buffer_resource, resource);
weston_assert_ptr_is_null(buffer->compositor, buffer->params_resource);
if (buffer->user_data_destroy_func)
buffer->user_data_destroy_func(buffer);
@ -174,8 +174,8 @@ params_create_common(struct wl_client *client,
return;
}
assert(buffer->params_resource == params_resource);
assert(!buffer->buffer_resource);
weston_assert_ptr_eq(buffer->compositor, buffer->params_resource, params_resource);
weston_assert_ptr_is_null(buffer->compositor, buffer->buffer_resource);
/* Switch the linux_dmabuf_buffer object from params resource to
* eventually wl_buffer resource.
@ -779,16 +779,18 @@ weston_dmabuf_feedback_send(struct weston_dmabuf_feedback *dmabuf_feedback,
* is dynamic and can change throughout compositor's life. These changes results
* in the need to resend the feedback events to clients.
*
* @param compositor The weston compositor
* @param dmabuf_feedback The weston_dmabuf_feedback object
* @param format_table The dma-buf feedback formats table
*/
WL_EXPORT void
weston_dmabuf_feedback_send_all(struct weston_dmabuf_feedback *dmabuf_feedback,
weston_dmabuf_feedback_send_all(struct weston_compositor *compositor,
struct weston_dmabuf_feedback *dmabuf_feedback,
struct weston_dmabuf_feedback_format_table *format_table)
{
struct wl_resource *res;
assert(!wl_list_empty(&dmabuf_feedback->resource_list));
weston_assert_true(compositor, !wl_list_empty(&dmabuf_feedback->resource_list));
wl_resource_for_each(res, &dmabuf_feedback->resource_list)
weston_dmabuf_feedback_send(dmabuf_feedback,
format_table, res, false);
@ -941,11 +943,13 @@ err:
* protocol interface, returns the linux_dmabuf_buffer object. This can
* be used as a type check for a wl_buffer.
*
* \param compositor The weston compositor.
* \param resource A wl_buffer resource.
* \return The linux_dmabuf_buffer if it exists, or NULL otherwise.
*/
WL_EXPORT struct linux_dmabuf_buffer *
linux_dmabuf_buffer_get(struct wl_resource *resource)
linux_dmabuf_buffer_get(struct weston_compositor *compositor,
struct wl_resource *resource)
{
struct linux_dmabuf_buffer *buffer;
@ -957,9 +961,9 @@ linux_dmabuf_buffer_get(struct wl_resource *resource)
return NULL;
buffer = wl_resource_get_user_data(resource);
assert(buffer);
assert(!buffer->params_resource);
assert(buffer->buffer_resource == resource);
weston_assert_ptr(compositor, buffer);
weston_assert_ptr_is_null(compositor, buffer->params_resource);
weston_assert_ptr_eq(compositor, buffer->buffer_resource, resource);
return buffer;
}
@ -986,7 +990,7 @@ linux_dmabuf_buffer_set_user_data(struct linux_dmabuf_buffer *buffer,
void *data,
dmabuf_user_data_destroy_func func)
{
assert(data == NULL || buffer->user_data == NULL);
weston_assert_true(buffer->compositor, data == NULL || buffer->user_data == NULL);
buffer->user_data = data;
buffer->user_data_destroy_func = func;
@ -1044,7 +1048,7 @@ bind_linux_dmabuf(struct wl_client *client,
/* If we got here, it means that the renderer is able to import dma-buf
* buffers, and so it must have get_supported_formats() set. */
assert(compositor->renderer->get_supported_formats != NULL);
weston_assert_ptr(compositor, compositor->renderer->get_supported_formats);
supported_formats = compositor->renderer->get_supported_formats(compositor);
wl_array_for_each(fmt, &supported_formats->arr) {
@ -1119,12 +1123,12 @@ linux_dmabuf_buffer_send_server_error(struct linux_dmabuf_buffer *buffer,
struct wl_resource *display_resource;
uint32_t id;
assert(buffer->buffer_resource);
weston_assert_ptr(buffer->compositor, buffer->buffer_resource);
id = wl_resource_get_id(buffer->buffer_resource);
client = wl_resource_get_client(buffer->buffer_resource);
display_resource = wl_client_get_object(client, 1);
assert(display_resource);
weston_assert_ptr(buffer->compositor, display_resource);
wl_resource_post_error(display_resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"linux_dmabuf server error with "

View file

@ -151,7 +151,8 @@ int
weston_direct_display_setup(struct weston_compositor *compositor);
struct linux_dmabuf_buffer *
linux_dmabuf_buffer_get(struct wl_resource *resource);
linux_dmabuf_buffer_get(struct weston_compositor *compositor,
struct wl_resource *resource);
void
linux_dmabuf_buffer_set_user_data(struct linux_dmabuf_buffer *buffer,
@ -171,7 +172,8 @@ void
weston_dmabuf_feedback_destroy(struct weston_dmabuf_feedback *dmabuf_feedback);
void
weston_dmabuf_feedback_send_all(struct weston_dmabuf_feedback *dmabuf_feedback,
weston_dmabuf_feedback_send_all(struct weston_compositor *compositor,
struct weston_dmabuf_feedback *dmabuf_feedback,
struct weston_dmabuf_feedback_format_table *format_table);
struct weston_dmabuf_feedback_tranche *