From 82e8b09d566235be0420f2289153a0bbae7a2e9a Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Wed, 2 Jan 2019 20:34:07 +0000 Subject: [PATCH] Move paint_all_new to backend.c Fix build with -Dnew_backends=false. And more build test for this case. Fixes #83 Signed-off-by: Yuxuan Shui --- .circleci/config.yml | 29 ++++++--- src/backend/backend.c | 110 +++++++++++++++++++++++++++++++++++ src/backend/backend.h | 1 + src/backend/backend_common.c | 108 ---------------------------------- src/backend/backend_common.h | 2 - 5 files changed, 131 insertions(+), 119 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cb5df4e2..e40b12ad 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ commands: - ".git" - run: name: config - command: CC=<< parameters.cc >> meson << parameters.build-config >> -Dnew_backends=true --werror . build + command: CC=<< parameters.cc >> meson << parameters.build-config >> --werror . build - run: name: build command: ninja -C build @@ -43,46 +43,57 @@ jobs: <<: *defaults steps: - build: - build-config: -Dbuild_docs=true + build-config: -Dbuild_docs=true -Dnew_backends=true minimal: <<: *defaults steps: - build: - build-config: -Dopengl=false -Ddbus=false -Dregex=false -Dconfig_file=false + build-config: -Dopengl=false -Ddbus=false -Dregex=false -Dconfig_file=false -Dnew_backends=true nogl: <<: *defaults steps: - build: - build-config: -Dopengl=false + build-config: -Dopengl=false -Dnew_backends=true noregex: <<: *defaults steps: - build: - build-config: -Dregex=false + build-config: -Dregex=false -Dnew_backends=true clang_basic: <<: *defaults steps: - build: cc: clang-6.0 - build-config: + build-config: -Dnew_backends=true clang_minimal: <<: *defaults steps: - build: cc: clang-6.0 - build-config: -Dopengl=false -Ddbus=false -Dregex=false -Dconfig_file=false + build-config: -Dopengl=false -Ddbus=false -Dregex=false -Dconfig_file=false -Dnew_backends=true clang_nogl: <<: *defaults steps: - build: cc: clang-6.0 - build-config: -Dopengl=false + build-config: -Dopengl=false -Dnew_backends=true clang_noregex: <<: *defaults steps: - build: cc: clang-6.0 - build-config: -Dregex=false + build-config: -Dregex=false -Dnew_backends=true + clang_basic_nonew: + <<: *defaults + steps: + - build: + cc: clang-6.0 + build-config: + basic_nonew: + <<: *defaults + steps: + - build: + build-config: -Dnew_backends=true workflows: all_builds: diff --git a/src/backend/backend.c b/src/backend/backend.c index d5d287c2..1dbf2c7d 100644 --- a/src/backend/backend.c +++ b/src/backend/backend.c @@ -10,3 +10,113 @@ bool default_is_win_transparent(void *backend_data, win *w, void *win_data) { bool default_is_frame_transparent(void *backend_data, win *w, void *win_data) { return w->frame_opacity != 1; } + +/// paint all windows +void paint_all_new(session_t *ps, region_t *region, win *const t) { + auto bi = backend_list[ps->o.backend]; + assert(bi); + +#ifdef DEBUG_REPAINT + static struct timespec last_paint = {0}; +#endif + + // Ignore out-of-screen damages + pixman_region32_intersect(region, region, &ps->screen_reg); + + region_t reg_tmp, *reg_paint; + pixman_region32_init(®_tmp); + if (t) { + // Calculate the region upon which the root window (wallpaper) is to be + // painted based on the ignore region of the lowest window, if available + pixman_region32_subtract(®_tmp, region, t->reg_ignore); + reg_paint = ®_tmp; + } else { + reg_paint = region; + } + + if (bi->prepare) + bi->prepare(ps->backend_data, ps, reg_paint); + + // Windows are sorted from bottom to top + // Each window has a reg_ignore, which is the region obscured by all the windows + // on top of that window. This is used to reduce the number of pixels painted. + // + // Whether this is beneficial is to be determined XXX + for (win *w = t; w; w = w->prev_trans) { + // Calculate the region based on the reg_ignore of the next (higher) + // window and the bounding region + // XXX XXX + pixman_region32_subtract(®_tmp, region, w->reg_ignore); + + if (pixman_region32_not_empty(®_tmp)) { + // Render window content + // XXX do this in preprocess? + bi->render_win(ps->backend_data, ps, w, w->win_data, ®_tmp); + + // Blur window background + bool win_transparent = + bi->is_win_transparent(ps->backend_data, w, w->win_data); + bool frame_transparent = + bi->is_frame_transparent(ps->backend_data, w, w->win_data); + if (w->blur_background && + (win_transparent || + (ps->o.blur_background_frame && frame_transparent))) { + // Minimize the region we try to blur, if the window + // itself is not opaque, only the frame is. + region_t reg_blur = win_get_bounding_shape_global_by_val(w); + if (win_is_solid(ps, w)) { + region_t reg_noframe; + pixman_region32_init(®_noframe); + win_get_region_noframe_local(w, ®_noframe); + pixman_region32_translate(®_noframe, w->g.x, + w->g.y); + pixman_region32_subtract(®_blur, ®_blur, + ®_noframe); + pixman_region32_fini(®_noframe); + } + bi->blur(ps->backend_data, ps, + (double)w->opacity / OPAQUE, ®_blur); + pixman_region32_fini(®_blur); + } + + // Draw window on target + bi->compose(ps->backend_data, ps, w, w->win_data, w->g.x, w->g.y, + ®_tmp); + + if (bi->finish_render_win) + bi->finish_render_win(ps->backend_data, ps, w, w->win_data); + } + } + + // Free up all temporary regions + pixman_region32_fini(®_tmp); + + if (bi->present) { + // Present the rendered scene + // Vsync is done here + bi->present(ps->backend_data, ps); + } + +#ifdef DEBUG_REPAINT + print_timestamp(ps); + struct timespec now = get_time_timespec(); + struct timespec diff = {0}; + timespec_subtract(&diff, &now, &last_paint); + printf("[ %5ld:%09ld ] ", diff.tv_sec, diff.tv_nsec); + last_paint = now; + printf("paint:"); + for (win *w = t; w; w = w->prev_trans) + printf(" %#010lx", w->id); + putchar('\n'); + fflush(stdout); +#endif + + // Check if fading is finished on all painted windows + win *pprev = NULL; + for (win *w = t; w; w = pprev) { + pprev = w->prev_trans; + win_check_fade_finished(ps, &w); + } +} + +// vim: set noet sw=8 ts=8 : diff --git a/src/backend/backend.h b/src/backend/backend.h index 22142b3c..43b29c29 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -144,3 +144,4 @@ extern backend_info_t *backend_list[]; bool default_is_win_transparent(void *, win *, void *); bool default_is_frame_transparent(void *, win *, void *); +void paint_all_new(session_t *ps, region_t *region, win *const t); diff --git a/src/backend/backend_common.c b/src/backend/backend_common.c index 883238c7..1d97ee7f 100644 --- a/src/backend/backend_common.c +++ b/src/backend/backend_common.c @@ -240,112 +240,4 @@ shadow_picture_err: return false; } -/// paint all windows -void paint_all_new(session_t *ps, region_t *region, win *const t) { - auto bi = backend_list[ps->o.backend]; - assert(bi); - -#ifdef DEBUG_REPAINT - static struct timespec last_paint = {0}; -#endif - - // Ignore out-of-screen damages - pixman_region32_intersect(region, region, &ps->screen_reg); - - region_t reg_tmp, *reg_paint; - pixman_region32_init(®_tmp); - if (t) { - // Calculate the region upon which the root window (wallpaper) is to be - // painted based on the ignore region of the lowest window, if available - pixman_region32_subtract(®_tmp, region, t->reg_ignore); - reg_paint = ®_tmp; - } else { - reg_paint = region; - } - - if (bi->prepare) - bi->prepare(ps->backend_data, ps, reg_paint); - - // Windows are sorted from bottom to top - // Each window has a reg_ignore, which is the region obscured by all the windows - // on top of that window. This is used to reduce the number of pixels painted. - // - // Whether this is beneficial is to be determined XXX - for (win *w = t; w; w = w->prev_trans) { - // Calculate the region based on the reg_ignore of the next (higher) - // window and the bounding region - // XXX XXX - pixman_region32_subtract(®_tmp, region, w->reg_ignore); - - if (pixman_region32_not_empty(®_tmp)) { - // Render window content - // XXX do this in preprocess? - bi->render_win(ps->backend_data, ps, w, w->win_data, ®_tmp); - - // Blur window background - bool win_transparent = - bi->is_win_transparent(ps->backend_data, w, w->win_data); - bool frame_transparent = - bi->is_frame_transparent(ps->backend_data, w, w->win_data); - if (w->blur_background && - (win_transparent || - (ps->o.blur_background_frame && frame_transparent))) { - // Minimize the region we try to blur, if the window - // itself is not opaque, only the frame is. - region_t reg_blur = win_get_bounding_shape_global_by_val(w); - if (win_is_solid(ps, w)) { - region_t reg_noframe; - pixman_region32_init(®_noframe); - win_get_region_noframe_local(w, ®_noframe); - pixman_region32_translate(®_noframe, w->g.x, - w->g.y); - pixman_region32_subtract(®_blur, ®_blur, - ®_noframe); - pixman_region32_fini(®_noframe); - } - bi->blur(ps->backend_data, ps, - (double)w->opacity / OPAQUE, ®_blur); - pixman_region32_fini(®_blur); - } - - // Draw window on target - bi->compose(ps->backend_data, ps, w, w->win_data, w->g.x, w->g.y, - ®_tmp); - - if (bi->finish_render_win) - bi->finish_render_win(ps->backend_data, ps, w, w->win_data); - } - } - - // Free up all temporary regions - pixman_region32_fini(®_tmp); - - if (bi->present) { - // Present the rendered scene - // Vsync is done here - bi->present(ps->backend_data, ps); - } - -#ifdef DEBUG_REPAINT - print_timestamp(ps); - struct timespec now = get_time_timespec(); - struct timespec diff = {0}; - timespec_subtract(&diff, &now, &last_paint); - printf("[ %5ld:%09ld ] ", diff.tv_sec, diff.tv_nsec); - last_paint = now; - printf("paint:"); - for (win *w = t; w; w = w->prev_trans) - printf(" %#010lx", w->id); - putchar('\n'); - fflush(stdout); -#endif - - // Check if fading is finished on all painted windows - win *pprev = NULL; - for (win *w = t; w; w = pprev) { - pprev = w->prev_trans; - win_check_fade_finished(ps, &w); - } -} - // vim: set noet sw=8 ts=8 : diff --git a/src/backend/backend_common.h b/src/backend/backend_common.h index f3d3ffdc..3b6d9581 100644 --- a/src/backend/backend_common.h +++ b/src/backend/backend_common.h @@ -17,7 +17,5 @@ bool build_shadow(session_t *ps, double opacity, const int width, const int heig xcb_render_picture_t solid_picture(session_t *ps, bool argb, double a, double r, double g, double b); -void paint_all_new(session_t *ps, region_t *region, win *const t); - xcb_image_t * make_shadow(xcb_connection_t *c, const conv *kernel, double opacity, int width, int height);