Fix some problems in new backend integration
Fix several use of uninitialized/unallocated variables when using --experimental-backends Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
417e12bc62
commit
c2f274ca8a
|
@ -1,17 +1,17 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
// Copyright (c) Yuxuan Shui <yshuiv7@gmail.com>
|
||||
#include <string.h>
|
||||
#include <xcb/xcb_image.h>
|
||||
#include <xcb/render.h>
|
||||
#include <xcb/xcb_image.h>
|
||||
#include <xcb/xcb_renderutil.h>
|
||||
|
||||
#include "backend/backend.h"
|
||||
#include "backend/backend_common.h"
|
||||
#include "kernel.h"
|
||||
#include "common.h"
|
||||
#include "kernel.h"
|
||||
#include "log.h"
|
||||
#include "x.h"
|
||||
#include "win.h"
|
||||
#include "x.h"
|
||||
|
||||
/**
|
||||
* Generate a 1x1 <code>Picture</code> of a particular color.
|
||||
|
@ -54,8 +54,8 @@ solid_picture(session_t *ps, bool argb, double a, double r, double g, double b)
|
|||
return picture;
|
||||
}
|
||||
|
||||
xcb_image_t *make_shadow(xcb_connection_t *c, const conv *kernel,
|
||||
double opacity, int width, int height) {
|
||||
xcb_image_t *
|
||||
make_shadow(xcb_connection_t *c, const conv *kernel, double opacity, int width, int height) {
|
||||
/*
|
||||
* We classify shadows into 4 kinds of regions
|
||||
* r = shadow radius
|
||||
|
@ -71,6 +71,7 @@ xcb_image_t *make_shadow(xcb_connection_t *c, const conv *kernel,
|
|||
*/
|
||||
xcb_image_t *ximage;
|
||||
const double *shadow_sum = kernel->rsum;
|
||||
assert(shadow_sum);
|
||||
// We only support square kernels for shadow
|
||||
assert(kernel->w == kernel->h);
|
||||
int d = kernel->w, r = d / 2;
|
||||
|
@ -184,15 +185,14 @@ xcb_image_t *make_shadow(xcb_connection_t *c, const conv *kernel,
|
|||
* Generate shadow <code>Picture</code> for a window.
|
||||
*/
|
||||
bool build_shadow(session_t *ps, double opacity, const int width, const int height,
|
||||
xcb_render_picture_t shadow_pixel, xcb_pixmap_t *pixmap,
|
||||
xcb_render_picture_t *pict) {
|
||||
const conv *kernel, xcb_render_picture_t shadow_pixel,
|
||||
xcb_pixmap_t *pixmap, xcb_render_picture_t *pict) {
|
||||
xcb_image_t *shadow_image = NULL;
|
||||
xcb_pixmap_t shadow_pixmap = XCB_NONE, shadow_pixmap_argb = XCB_NONE;
|
||||
xcb_render_picture_t shadow_picture = XCB_NONE, shadow_picture_argb = XCB_NONE;
|
||||
xcb_gcontext_t gc = XCB_NONE;
|
||||
|
||||
shadow_image =
|
||||
make_shadow(ps->c, ps->gaussian_map, opacity, width, height);
|
||||
shadow_image = make_shadow(ps->c, kernel, opacity, width, height);
|
||||
if (!shadow_image) {
|
||||
log_error("Failed to make shadow");
|
||||
return false;
|
||||
|
|
|
@ -14,8 +14,8 @@ typedef struct win win;
|
|||
typedef struct conv conv;
|
||||
|
||||
bool build_shadow(session_t *ps, double opacity, const int width, const int height,
|
||||
xcb_render_picture_t shadow_pixel, xcb_pixmap_t *pixmap,
|
||||
xcb_render_picture_t *pict);
|
||||
const conv *kernel, xcb_render_picture_t shadow_pixel,
|
||||
xcb_pixmap_t *pixmap, xcb_render_picture_t *pict);
|
||||
|
||||
xcb_render_picture_t
|
||||
solid_picture(session_t *ps, bool argb, double a, double r, double g, double b);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "utils.h"
|
||||
#include "win.h"
|
||||
#include "x.h"
|
||||
#include "kernel.h"
|
||||
|
||||
#define auto __auto_type
|
||||
|
||||
|
@ -51,6 +52,8 @@ typedef struct _xrender_data {
|
|||
|
||||
/// 1x1 picture of the shadow color
|
||||
xcb_render_picture_t shadow_pixel;
|
||||
/// convolution kernel for the shadow
|
||||
conv *shadow_kernel;
|
||||
|
||||
/// Blur kernels converted to X format
|
||||
xcb_render_fixed_t *x_blur_kern[MAX_BLUR_PASS];
|
||||
|
@ -365,8 +368,8 @@ static void *prepare_win(void *backend_data, session_t *ps, win *w) {
|
|||
// leave this here until we have chance to re-think the backend API
|
||||
if (w->shadow) {
|
||||
xcb_pixmap_t pixmap;
|
||||
build_shadow(ps, 1, w->widthb, w->heightb, xd->shadow_pixel, &pixmap,
|
||||
&wd->shadow_pict);
|
||||
build_shadow(ps, 1, w->widthb, w->heightb, xd->shadow_kernel,
|
||||
xd->shadow_pixel, &pixmap, &wd->shadow_pict);
|
||||
xcb_free_pixmap(ps->c, pixmap);
|
||||
}
|
||||
return wd;
|
||||
|
@ -396,6 +399,8 @@ static void *init(session_t *ps) {
|
|||
xd->white_pixel = solid_picture(ps, true, 1, 1, 1, 1);
|
||||
xd->shadow_pixel = solid_picture(ps, true, 1, ps->o.shadow_red,
|
||||
ps->o.shadow_green, ps->o.shadow_blue);
|
||||
xd->shadow_kernel = gaussian_kernel(ps->o.shadow_radius);
|
||||
sum_kernel_preprocess(xd->shadow_kernel);
|
||||
|
||||
if (ps->overlay != XCB_NONE) {
|
||||
xd->target = x_create_picture_with_visual_and_pixmap(
|
||||
|
|
|
@ -2645,6 +2645,18 @@ session_init(int argc, char **argv, Display *dpy, const char *config_file,
|
|||
exit(1);
|
||||
}
|
||||
|
||||
if (ps->o.experimental_backends) {
|
||||
ps->ndamage = backend_list[ps->o.backend]->max_buffer_age;
|
||||
} else {
|
||||
ps->ndamage = maximum_buffer_age(ps);
|
||||
}
|
||||
ps->damage_ring = ccalloc(ps->ndamage, region_t);
|
||||
ps->damage = ps->damage_ring + ps->ndamage - 1;
|
||||
|
||||
for (int i = 0; i < ps->ndamage; i++) {
|
||||
pixman_region32_init(&ps->damage_ring[i]);
|
||||
}
|
||||
|
||||
if (ps->o.print_diagnostics) {
|
||||
print_diagnostics(ps, config_file);
|
||||
free(config_file_to_free);
|
||||
|
|
|
@ -1170,14 +1170,6 @@ bool init_render(session_t *ps) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ps->ndamage = maximum_buffer_age(ps);
|
||||
ps->damage_ring = ccalloc(ps->ndamage, region_t);
|
||||
ps->damage = ps->damage_ring + ps->ndamage - 1;
|
||||
|
||||
for (int i = 0; i < ps->ndamage; i++) {
|
||||
pixman_region32_init(&ps->damage_ring[i]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,3 +42,5 @@ void free_root_tile(session_t *ps);
|
|||
|
||||
bool init_render(session_t *ps);
|
||||
void deinit_render(session_t *ps);
|
||||
|
||||
int maximum_buffer_age(session_t *);
|
||||
|
|
14
src/win.c
14
src/win.c
|
@ -611,8 +611,18 @@ void calc_win_size(session_t *ps, win *w) {
|
|||
w->flags |= WFLAG_SIZE_CHANGE;
|
||||
// Invalidate the shadow we built
|
||||
if (ps->o.experimental_backends) {
|
||||
backend_list[ps->o.backend]->release_win(ps->backend_data, ps, w, w->win_data);
|
||||
w->win_data = backend_list[ps->o.backend]->prepare_win(ps->backend_data, ps, w);
|
||||
if (w->state != WSTATE_UNMAPPED && w->state != WSTATE_MAPPED) {
|
||||
// wrapping up fading
|
||||
w->opacity = w->opacity_tgt;
|
||||
win_check_fade_finished(ps, &w);
|
||||
}
|
||||
if (!w) {
|
||||
return;
|
||||
}
|
||||
if (w->state == WSTATE_MAPPED) {
|
||||
backend_list[ps->o.backend]->release_win(ps->backend_data, ps, w, w->win_data);
|
||||
w->win_data = backend_list[ps->o.backend]->prepare_win(ps->backend_data, ps, w);
|
||||
}
|
||||
} else {
|
||||
free_paint(ps, &w->shadow_paint);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue