diff --git a/src/common/meta-cogl-drm-formats.c b/src/common/meta-cogl-drm-formats.c index 24c4b833a..fec24acfb 100644 --- a/src/common/meta-cogl-drm-formats.c +++ b/src/common/meta-cogl-drm-formats.c @@ -51,3 +51,25 @@ meta_cogl_pixel_format_from_drm_format (uint32_t drm_format, return TRUE; } + +gboolean +meta_drm_format_from_cogl_pixel_format (CoglPixelFormat cogl_format, + uint32_t *out_drm_format) +{ + const size_t n = G_N_ELEMENTS (meta_cogl_drm_format_map); + size_t i; + + for (i = 0; i < n; i++) + { + if (meta_cogl_drm_format_map[i].cogl_format == cogl_format) + break; + } + + if (i == n) + return FALSE; + + if (out_drm_format) + *out_drm_format = meta_cogl_drm_format_map[i].drm_format; + + return TRUE; +} diff --git a/src/common/meta-cogl-drm-formats.h b/src/common/meta-cogl-drm-formats.h index 7cf32644f..97f8f1fa8 100644 --- a/src/common/meta-cogl-drm-formats.h +++ b/src/common/meta-cogl-drm-formats.h @@ -81,4 +81,7 @@ gboolean meta_cogl_pixel_format_from_drm_format (uint32_t drm_for CoglPixelFormat *out_format, MetaMultiTextureFormat *out_multi_texture_format); +gboolean meta_drm_format_from_cogl_pixel_format (CoglPixelFormat cogl_format, + uint32_t *out_drm_format); + G_END_DECLS