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:
Yuxuan Shui
2019-02-20 18:17:16 +00:00
parent 417e12bc62
commit c2f274ca8a
7 changed files with 44 additions and 23 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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(