summaryrefslogtreecommitdiff
path: root/lib/igt_fb.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/igt_fb.c')
-rw-r--r--lib/igt_fb.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 0462c35b..5f23136e 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1141,28 +1141,34 @@ const char *igt_format_str(uint32_t drm_format)
}
/**
- * igt_get_all_formats:
+ * igt_get_all_cairo_formats:
* @formats: pointer to pointer to store the allocated formats array
* @format_count: pointer to integer to store the size of the allocated array
*
- * This functions returns an array of all the drm fourcc codes supported by this
- * library.
+ * This functions returns an array of all the drm fourcc codes supported by
+ * cairo and this library.
*/
-void igt_get_all_formats(const uint32_t **formats, int *format_count)
+void igt_get_all_cairo_formats(const uint32_t **formats, int *format_count)
{
static uint32_t *drm_formats;
+ static int n_formats;
if (!drm_formats) {
struct format_desc_struct *f;
uint32_t *format;
- drm_formats = calloc(ARRAY_SIZE(format_desc),
- sizeof(*drm_formats));
+ n_formats = 0;
+ for_each_format(f)
+ if (f->cairo_id != CAIRO_FORMAT_INVALID)
+ n_formats++;
+
+ drm_formats = calloc(n_formats, sizeof(*drm_formats));
format = &drm_formats[0];
for_each_format(f)
- *format++ = f->drm_id;
+ if (f->cairo_id != CAIRO_FORMAT_INVALID)
+ *format++ = f->drm_id;
}
*formats = drm_formats;
- *format_count = ARRAY_SIZE(format_desc);
+ *format_count = n_formats;
}