aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-11-25 15:30:23 +0100
committerIlia Bozhinov <ammen99@gmail.com>2020-12-03 10:52:25 +0100
commit237c2cf2fbe6056382077456646916f04140f49b (patch)
treeb6a99e3e242fa904c88bf64ffa04e1cfcdb81964 /backend
parent513eca8dabe1b98f6169a0afa046825daa2c76ea (diff)
backend/drm: take a wlr_drm_format in init_drm_surface
Instead of taking a format code and wlr_drm_format_set, simplify the function signature and take a single wlr_drm_format.
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/renderer.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index c9f0e6f0..fb915fbe 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -77,7 +77,7 @@ void finish_drm_renderer(struct wlr_drm_renderer *renderer) {
static bool init_drm_surface(struct wlr_drm_surface *surf,
struct wlr_drm_renderer *renderer, uint32_t width, uint32_t height,
- uint32_t format, const struct wlr_drm_format_set *set, uint32_t flags) {
+ const struct wlr_drm_format *drm_format, uint32_t flags) {
if (surf->width == width && surf->height == height) {
return true;
}
@@ -91,21 +91,13 @@ static bool init_drm_surface(struct wlr_drm_surface *surf,
wlr_swapchain_destroy(surf->swapchain);
surf->swapchain = NULL;
- const struct wlr_drm_format *drm_format = NULL;
- const struct wlr_drm_format format_no_modifiers = { .format = format };
- if (set != NULL) {
- drm_format = wlr_drm_format_set_get(set, format);
- } else {
- drm_format = &format_no_modifiers;
- }
-
struct wlr_drm_format *format_linear = NULL;
if (flags & GBM_BO_USE_LINEAR) {
format_linear = calloc(1, sizeof(struct wlr_drm_format) + sizeof(uint64_t));
if (format_linear == NULL) {
return false;
}
- format_linear->format = format;
+ format_linear->format = drm_format->format;
format_linear->len = 1;
format_linear->modifiers[0] = DRM_FORMAT_MOD_LINEAR;
drm_format = format_linear;
@@ -253,25 +245,28 @@ bool drm_plane_init_surface(struct wlr_drm_plane *plane,
return false;
}
- struct wlr_drm_format_set *format_set =
- with_modifiers ? &plane->formats : NULL;
+ const struct wlr_drm_format *drm_format = NULL;
+ const struct wlr_drm_format format_no_modifiers = { .format = format };
+ if (with_modifiers) {
+ drm_format = wlr_drm_format_set_get(&plane->formats, format);
+ } else {
+ drm_format = &format_no_modifiers;
+ }
drm_plane_finish_surface(plane);
if (!drm->parent) {
return init_drm_surface(&plane->surf, &drm->renderer, width, height,
- format, format_set, flags | GBM_BO_USE_SCANOUT);
+ drm_format, flags | GBM_BO_USE_SCANOUT);
}
if (!init_drm_surface(&plane->surf, &drm->parent->renderer,
- width, height, format, NULL,
- flags | GBM_BO_USE_LINEAR)) {
+ width, height, drm_format, flags | GBM_BO_USE_LINEAR)) {
return false;
}
if (!init_drm_surface(&plane->mgpu_surf, &drm->renderer,
- width, height, format, format_set,
- flags | GBM_BO_USE_SCANOUT)) {
+ width, height, drm_format, flags | GBM_BO_USE_SCANOUT)) {
finish_drm_surface(&plane->surf);
return false;
}