From 50ea3617ef0b26abe9f4c9a80dfe3d70e55f11f1 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 16 Dec 2018 03:00:56 +0000 Subject: [PATCH] Move some deinitialization to render.c Signed-off-by: Yuxuan Shui --- src/compton.c | 41 +---------------------------------------- src/compton.h | 4 ---- src/render.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/render.h | 2 ++ 4 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/compton.c b/src/compton.c index 2aeafd0..bdbaf5b 100644 --- a/src/compton.c +++ b/src/compton.c @@ -186,21 +186,6 @@ free_win_res(session_t *ps, win *w) { free(w->role); } -/** - * Free root tile related things. - */ -static inline void -free_root_tile(session_t *ps) { - free_picture(ps->c, &ps->root_tile_paint.pict); - free_texture(ps, &ps->root_tile_paint.ptex); - if (ps->root_tile_fill) { - xcb_free_pixmap(ps->c, ps->root_tile_paint.pixmap); - ps->root_tile_paint.pixmap = XCB_NONE; - } - ps->root_tile_paint.pixmap = None; - ps->root_tile_fill = false; -} - /** * Get current system clock in milliseconds. */ @@ -3959,14 +3944,6 @@ session_destroy(session_t *ps) { ps->list = NULL; } - // Free alpha_picts - { - for (int i = 0; i <= MAX_ALPHA; ++i) - free_picture(ps->c, &ps->alpha_picts[i]); - free(ps->alpha_picts); - ps->alpha_picts = NULL; - } - // Free blacklists free_wincondlst(&ps->o.shadow_blacklist); free_wincondlst(&ps->o.fade_blacklist); @@ -4002,15 +3979,6 @@ session_destroy(session_t *ps) { ps->ignore_tail = &ps->ignore_head; } - // Free cshadow_picture and black_picture - if (ps->cshadow_picture == ps->black_picture) - ps->cshadow_picture = None; - else - free_picture(ps->c, &ps->cshadow_picture); - - free_picture(ps->c, &ps->black_picture); - free_picture(ps->c, &ps->white_picture); - // Free tgt_{buffer,picture} and root_picture if (ps->tgt_buffer.pict == ps->tgt_picture) ps->tgt_buffer.pict = None; @@ -4024,16 +3992,11 @@ session_destroy(session_t *ps) { free_picture(ps->c, &ps->root_picture); free_paint(ps, &ps->tgt_buffer); - // Free other X resources - free_root_tile(ps); pixman_region32_fini(&ps->screen_reg); pixman_region32_fini(&ps->all_damage); for (int i = 0; i < CGLX_MAX_BUFFER_AGE; ++i) pixman_region32_fini(&ps->all_damage_last[i]); free(ps->expose_rects); - free(ps->shadow_corner); - free(ps->shadow_top); - free(ps->gaussian_map); free(ps->o.config_file); free(ps->o.write_pid_path); @@ -4048,9 +4011,7 @@ session_destroy(session_t *ps) { free_xinerama_info(ps); free(ps->pictfmts); -#ifdef CONFIG_OPENGL - glx_destroy(ps); -#endif + deinit_render(ps); #ifdef CONFIG_VSYNC_DRM // Close file opened for DRM VSync diff --git a/src/compton.h b/src/compton.h index db66bef..1f7ace7 100644 --- a/src/compton.h +++ b/src/compton.h @@ -108,10 +108,6 @@ static inline void free_paint_glx(session_t *ps, paint_t *p) {} static inline void free_win_res_glx(session_t *ps, win *w) {} -static inline void -free_texture(session_t *ps, glx_texture_t **t) { - assert(!*t); -} #endif /** diff --git a/src/render.c b/src/render.c index de5b92d..8e89486 100644 --- a/src/render.c +++ b/src/render.c @@ -1285,4 +1285,49 @@ bool init_render(session_t *ps) { return true; } +/** + * Free root tile related things. + */ +void free_root_tile(session_t *ps) { + free_picture(ps->c, &ps->root_tile_paint.pict); +#ifdef CONFIG_OPENGL + free_texture(ps, &ps->root_tile_paint.ptex); +#else + assert(!ps->root_tile_paint.ptex); +#endif + if (ps->root_tile_fill) { + xcb_free_pixmap(ps->c, ps->root_tile_paint.pixmap); + ps->root_tile_paint.pixmap = XCB_NONE; + } + ps->root_tile_paint.pixmap = None; + ps->root_tile_fill = false; +} + +void deinit_render(session_t *ps) { + // Free alpha_picts + for (int i = 0; i <= MAX_ALPHA; ++i) + free_picture(ps->c, &ps->alpha_picts[i]); + free(ps->alpha_picts); + ps->alpha_picts = NULL; + + // Free cshadow_picture and black_picture + if (ps->cshadow_picture == ps->black_picture) + ps->cshadow_picture = XCB_NONE; + else + free_picture(ps->c, &ps->cshadow_picture); + + free_picture(ps->c, &ps->black_picture); + free_picture(ps->c, &ps->white_picture); + free(ps->shadow_corner); + free(ps->shadow_top); + free(ps->gaussian_map); + + // Free other X resources + free_root_tile(ps); + +#ifdef CONFIG_OPENGL + glx_destroy(ps); +#endif +} + // vim: set ts=8 sw=8 noet : diff --git a/src/render.h b/src/render.h index 3a2d31d..eca135e 100644 --- a/src/render.h +++ b/src/render.h @@ -30,5 +30,7 @@ paint_all(session_t *ps, region_t *region, const region_t *region_real, win * co void free_picture(xcb_connection_t *c, xcb_render_picture_t *p); void free_paint(session_t *ps, paint_t *ppaint); +void free_root_tile(session_t *ps); bool init_render(session_t *ps); +void deinit_render(session_t *ps);