pixel-formats: add pixel_format_get_array()
Add a helper function to turn an array of DRM fourccs into an array of corresponding struct pixel_format_info pointers. Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
This commit is contained in:
parent
efffd0d8a4
commit
782fd7f370
@ -40,6 +40,7 @@
|
||||
#include "shared/helpers.h"
|
||||
#include "shared/string-helpers.h"
|
||||
#include "shared/weston-drm-fourcc.h"
|
||||
#include "shared/xalloc.h"
|
||||
#include "wayland-util.h"
|
||||
#include "pixel-formats.h"
|
||||
|
||||
@ -776,3 +777,21 @@ pixel_format_get_shm_format(const struct pixel_format_info *info)
|
||||
|
||||
return info->format;
|
||||
}
|
||||
|
||||
WL_EXPORT const struct pixel_format_info **
|
||||
pixel_format_get_array(const uint32_t *drm_formats, unsigned int formats_count)
|
||||
{
|
||||
const struct pixel_format_info **formats;
|
||||
unsigned int i;
|
||||
|
||||
formats = xcalloc(formats_count, sizeof(*formats));
|
||||
for (i = 0; i < formats_count; i++) {
|
||||
formats[i] = pixel_format_get_info(drm_formats[i]);
|
||||
if (!formats[i]) {
|
||||
free(formats);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return formats;
|
||||
}
|
||||
|
@ -354,3 +354,17 @@ pixel_format_get_modifier(uint64_t modifier);
|
||||
*/
|
||||
uint32_t
|
||||
pixel_format_get_shm_format(const struct pixel_format_info *info);
|
||||
|
||||
/**
|
||||
* Get pixel format array for an array of DRM format codes
|
||||
*
|
||||
* Given an array of DRM format codes, return an array of corresponding pixel
|
||||
* format info pointers.
|
||||
*
|
||||
* @param formats Array of DRM format codes to get info for
|
||||
* @param formats_count Number of entries in formats.
|
||||
* @returns An array of pixel format info pointers, or NULL if any format could
|
||||
* not be found. Must be freed by the caller.
|
||||
*/
|
||||
const struct pixel_format_info **
|
||||
pixel_format_get_array(const uint32_t *formats, unsigned int formats_count);
|
||||
|
Loading…
x
Reference in New Issue
Block a user