Skip to content
Snippets Groups Projects
Commit 0750ceae authored by Leandro Ribeiro's avatar Leandro Ribeiro Committed by Pekka Paalanen
Browse files

drm-formats: remove create() and destroy() from the API


Since commit "drm-formats: save result of intersection in the first
array", every block of code where weston_drm_format_array_create() and
destroy() are being called could use init() and fini() instead.

Remove these two functions from the API to make it leaner. This patch
also modifies the code that depends on these functions to use init() and
fini().

Signed-off-by: default avatarLeandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: default avatarAlexandros Frantzis <alexandros.frantzis@collabora.com>
parent c51d4ad9
No related branches found
No related tags found
Loading
Pipeline #395872 passed
......@@ -31,27 +31,6 @@
#include "libweston-internal.h"
#include "shared/weston-drm-fourcc.h"
/**
* Create and initialize a weston_drm_format_array
*
* @return The weston_drm_format_array, or NULL on failure
*/
WL_EXPORT struct weston_drm_format_array *
weston_drm_format_array_create(void)
{
struct weston_drm_format_array *formats;
formats = zalloc(sizeof(*formats));
if (!formats) {
weston_log("%s: out of memory\n", __func__);
return NULL;
}
weston_drm_format_array_init(formats);
return formats;
}
/**
* Initialize a weston_drm_format_array
*
......@@ -63,18 +42,6 @@ weston_drm_format_array_init(struct weston_drm_format_array *formats)
wl_array_init(&formats->arr);
}
/**
* Fini and destroy a weston_drm_format_array
*
* @param formats The weston_drm_format_array to destroy
*/
WL_EXPORT void
weston_drm_format_array_destroy(struct weston_drm_format_array *formats)
{
weston_drm_format_array_fini(formats);
free(formats);
}
/**
* Finish a weston_drm_format_array
*
......@@ -330,13 +297,11 @@ WL_EXPORT int
weston_drm_format_array_intersect(struct weston_drm_format_array *formats_A,
const struct weston_drm_format_array *formats_B)
{
struct weston_drm_format_array *formats_result;
struct weston_drm_format_array formats_result;
struct weston_drm_format *fmt_result, *fmt_A, *fmt_B;
int ret;
formats_result = weston_drm_format_array_create();
if (!formats_result)
return -1;
weston_drm_format_array_init(&formats_result);
wl_array_for_each(fmt_A, &formats_A->arr) {
fmt_B = weston_drm_format_array_find_format(formats_B,
......@@ -344,7 +309,7 @@ weston_drm_format_array_intersect(struct weston_drm_format_array *formats_A,
if (!fmt_B)
continue;
fmt_result = weston_drm_format_array_add_format(formats_result,
fmt_result = weston_drm_format_array_add_format(&formats_result,
fmt_A->format);
if (!fmt_result)
goto err;
......@@ -354,18 +319,18 @@ weston_drm_format_array_intersect(struct weston_drm_format_array *formats_A,
goto err;
if (fmt_result->modifiers.size == 0)
weston_drm_format_array_remove_latest_format(formats_result);
weston_drm_format_array_remove_latest_format(&formats_result);
}
ret = weston_drm_format_array_replace(formats_A, formats_result);
ret = weston_drm_format_array_replace(formats_A, &formats_result);
if (ret < 0)
goto err;
weston_drm_format_array_destroy(formats_result);
weston_drm_format_array_fini(&formats_result);
return 0;
err:
weston_drm_format_array_destroy(formats_result);
weston_drm_format_array_fini(&formats_result);
return -1;
}
......@@ -405,19 +370,17 @@ WL_EXPORT int
weston_drm_format_array_subtract(struct weston_drm_format_array *formats_A,
const struct weston_drm_format_array *formats_B)
{
struct weston_drm_format_array *formats_result;
struct weston_drm_format_array formats_result;
struct weston_drm_format *fmt_result, *fmt_A, *fmt_B;
int ret;
formats_result = weston_drm_format_array_create();
if (!formats_result)
return -1;
weston_drm_format_array_init(&formats_result);
wl_array_for_each(fmt_A, &formats_A->arr) {
fmt_B = weston_drm_format_array_find_format(formats_B,
fmt_A->format);
if (!fmt_B) {
ret = add_format_and_modifiers(formats_result, fmt_A->format,
ret = add_format_and_modifiers(&formats_result, fmt_A->format,
&fmt_A->modifiers);
if (ret < 0)
goto err;
......@@ -425,7 +388,7 @@ weston_drm_format_array_subtract(struct weston_drm_format_array *formats_A,
continue;
}
fmt_result = weston_drm_format_array_add_format(formats_result,
fmt_result = weston_drm_format_array_add_format(&formats_result,
fmt_A->format);
if (!fmt_result)
goto err;
......@@ -435,18 +398,18 @@ weston_drm_format_array_subtract(struct weston_drm_format_array *formats_A,
goto err;
if (fmt_result->modifiers.size == 0)
weston_drm_format_array_remove_latest_format(formats_result);
weston_drm_format_array_remove_latest_format(&formats_result);
}
ret = weston_drm_format_array_replace(formats_A, formats_result);
ret = weston_drm_format_array_replace(formats_A, &formats_result);
if (ret < 0)
goto err;
weston_drm_format_array_destroy(formats_result);
weston_drm_format_array_fini(&formats_result);
return 0;
err:
weston_drm_format_array_destroy(formats_result);
weston_drm_format_array_fini(&formats_result);
return -1;
}
......
......@@ -337,15 +337,9 @@ struct weston_drm_format_array {
struct wl_array arr;
};
struct weston_drm_format_array *
weston_drm_format_array_create(void);
void
weston_drm_format_array_init(struct weston_drm_format_array *formats);
void
weston_drm_format_array_destroy(struct weston_drm_format_array *formats);
void
weston_drm_format_array_fini(struct weston_drm_format_array *formats);
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment