From b3d7df5c3e58cd3b0d8928ad3cb70ba80fb95708 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 7 Dec 2021 17:43:55 +0000 Subject: [PATCH] backend-drm: Move plane-type-specific checks to switch statement This makes it a bit more clear and easy to follow, rather than diving through if nesting. Signed-off-by: Daniel Stone --- libweston/backend-drm/state-propose.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/libweston/backend-drm/state-propose.c b/libweston/backend-drm/state-propose.c index 39220fbd..a022bc1b 100644 --- a/libweston/backend-drm/state-propose.c +++ b/libweston/backend-drm/state-propose.c @@ -682,15 +682,24 @@ drm_output_prepare_plane_view(struct drm_output_state *state, possible_plane_mask &= ~(1 << plane->plane_idx); - if (plane->type == WDRM_PLANE_TYPE_CURSOR && - (plane != output->cursor_plane || !shmbuf)) { - continue; - } - - if (plane->type == WDRM_PLANE_TYPE_PRIMARY && - (plane != output->scanout_plane || - mode != DRM_OUTPUT_PROPOSE_STATE_PLANES_ONLY)) { - continue; + switch (plane->type) { + case WDRM_PLANE_TYPE_CURSOR: + assert(shmbuf); + assert(plane == output->cursor_plane); + break; + case WDRM_PLANE_TYPE_PRIMARY: + assert(fb); + if (plane != output->scanout_plane) + continue; + if (mode != DRM_OUTPUT_PROPOSE_STATE_PLANES_ONLY) + continue; + break; + case WDRM_PLANE_TYPE_OVERLAY: + assert(fb); + assert(mode != DRM_OUTPUT_PROPOSE_STATE_RENDERER_ONLY); + break; + default: + assert(false && "unknown plane type"); } if (!drm_plane_is_available(plane, output))