drm-formats: add weston_drm_format_array_count_pairs()
It simply returns the number of format/modifier pairs in the array. This will be useful for the next commits, in which we add support for dma-buf feedback. Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
@@ -184,6 +184,24 @@ weston_drm_format_array_find_format(const struct weston_drm_format_array *format
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of format/modifier pairs in a weston_drm_format_array
|
||||
*
|
||||
* @param formats The weston_drm_format_array
|
||||
* @return The number of format/modifier pairs in the array
|
||||
*/
|
||||
WL_EXPORT unsigned int
|
||||
weston_drm_format_array_count_pairs(const struct weston_drm_format_array *formats)
|
||||
{
|
||||
struct weston_drm_format *fmt;
|
||||
unsigned int num_pairs = 0;
|
||||
|
||||
wl_array_for_each(fmt, &formats->arr)
|
||||
num_pairs += fmt->modifiers.size / sizeof(uint64_t);
|
||||
|
||||
return num_pairs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the content of two weston_drm_format_array
|
||||
*
|
||||
|
||||
@@ -358,6 +358,9 @@ struct weston_drm_format *
|
||||
weston_drm_format_array_find_format(const struct weston_drm_format_array *formats,
|
||||
uint32_t format);
|
||||
|
||||
unsigned int
|
||||
weston_drm_format_array_count_pairs(const struct weston_drm_format_array *formats);
|
||||
|
||||
bool
|
||||
weston_drm_format_array_equal(const struct weston_drm_format_array *formats_A,
|
||||
const struct weston_drm_format_array *formats_B);
|
||||
|
||||
Reference in New Issue
Block a user