From 3e661f7b6cf83923439deb66fb731fbc62c8e4a2 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 4 Nov 2016 17:24:06 +0000 Subject: [PATCH] compositor-drm: Extract EGL destroy to helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No functional change. Differential Revision: https://phabricator.freedesktop.org/D1484 Signed-off-by: Daniel Stone Reviewed-by: Armin Krezović --- libweston/compositor-drm.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index 88e65bcd..b7e1db4f 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -1322,9 +1322,6 @@ drm_assign_planes(struct weston_output *output_base) pixman_region32_fini(&overlap); } -static void -drm_output_fini_pixman(struct drm_output *output); - /** * Find the closest-matching mode for a given target * @@ -1363,8 +1360,12 @@ choose_mode (struct drm_output *output, struct weston_mode *target_mode) static int drm_output_init_egl(struct drm_output *output, struct drm_backend *b); +static void +drm_output_fini_egl(struct drm_output *output); static int drm_output_init_pixman(struct drm_output *output, struct drm_backend *b); +static void +drm_output_fini_pixman(struct drm_output *output); static int drm_output_switch_mode(struct weston_output *output_base, struct weston_mode *mode) @@ -1414,9 +1415,7 @@ drm_output_switch_mode(struct weston_output *output_base, struct weston_mode *mo return -1; } } else { - gl_renderer->output_destroy(&output->base); - gbm_surface_destroy(output->gbm_surface); - + drm_output_fini_egl(output); if (drm_output_init_egl(output, b) < 0) { weston_log("failed to init output egl state with " "new mode"); @@ -1853,6 +1852,13 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b) return 0; } +static void +drm_output_fini_egl(struct drm_output *output) +{ + gl_renderer->output_destroy(&output->base); + gbm_surface_destroy(output->gbm_surface); +} + static int drm_output_init_pixman(struct drm_output *output, struct drm_backend *b) { @@ -2423,12 +2429,10 @@ drm_output_deinit(struct weston_output *base) struct drm_output *output = to_drm_output(base); struct drm_backend *b = to_drm_backend(base->compositor); - if (b->use_pixman) { + if (b->use_pixman) drm_output_fini_pixman(output); - } else { - gl_renderer->output_destroy(&output->base); - gbm_surface_destroy(output->gbm_surface); - } + else + drm_output_fini_egl(output); weston_plane_release(&output->fb_plane); weston_plane_release(&output->cursor_plane);