x: create_picture_with_{visual, pictfmt} don't need session_t
Take xcb_connection_t and xcb_drawable_t instead. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
0ceee9aad1
commit
26214f312f
|
@ -184,8 +184,8 @@ blur(void *backend_data, session_t *ps, double opacity, const region_t *reg_pain
|
||||||
// Create a buffer for storing blurred picture, make it just big enough
|
// Create a buffer for storing blurred picture, make it just big enough
|
||||||
// for the blur region
|
// for the blur region
|
||||||
xcb_render_picture_t tmp_picture[2] = {
|
xcb_render_picture_t tmp_picture[2] = {
|
||||||
x_create_picture_with_visual(ps, width, height, ps->vis, 0, NULL),
|
x_create_picture_with_visual(ps->c, ps->root, width, height, ps->vis, 0, NULL),
|
||||||
x_create_picture_with_visual(ps, width, height, ps->vis, 0, NULL)};
|
x_create_picture_with_visual(ps->c, ps->root, width, height, ps->vis, 0, NULL)};
|
||||||
|
|
||||||
region_t clip;
|
region_t clip;
|
||||||
pixman_region32_init(&clip);
|
pixman_region32_init(&clip);
|
||||||
|
@ -279,7 +279,7 @@ static void render_win(void *backend_data, session_t *ps, win *w, void *win_data
|
||||||
// We don't want to modify the content of the original window when we process
|
// We don't want to modify the content of the original window when we process
|
||||||
// it, so we create a buffer.
|
// it, so we create a buffer.
|
||||||
if (wd->buffer == XCB_NONE) {
|
if (wd->buffer == XCB_NONE) {
|
||||||
wd->buffer = x_create_picture_with_pictfmt(ps, w->widthb, w->heightb,
|
wd->buffer = x_create_picture_with_pictfmt(ps->c, ps->root, w->widthb, w->heightb,
|
||||||
w->pictfmt, 0, NULL);
|
w->pictfmt, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,7 @@ void paint_one(session_t *ps, win *w, const region_t *reg_paint) {
|
||||||
// Invert window color, if required
|
// Invert window color, if required
|
||||||
if (bkend_use_xrender(ps) && w->invert_color) {
|
if (bkend_use_xrender(ps) && w->invert_color) {
|
||||||
xcb_render_picture_t newpict =
|
xcb_render_picture_t newpict =
|
||||||
x_create_picture_with_pictfmt(ps, wid, hei, w->pictfmt, 0, NULL);
|
x_create_picture_with_pictfmt(ps->c, ps->root, wid, hei, w->pictfmt, 0, NULL);
|
||||||
if (newpict) {
|
if (newpict) {
|
||||||
// Apply clipping region to save some CPU
|
// Apply clipping region to save some CPU
|
||||||
if (reg_paint) {
|
if (reg_paint) {
|
||||||
|
@ -604,7 +604,7 @@ static bool xr_blur_dst(session_t *ps, xcb_render_picture_t tgt_buffer, int x, i
|
||||||
// Directly copying from tgt_buffer to it does not work, so we create a
|
// Directly copying from tgt_buffer to it does not work, so we create a
|
||||||
// Picture in the middle.
|
// Picture in the middle.
|
||||||
xcb_render_picture_t tmp_picture =
|
xcb_render_picture_t tmp_picture =
|
||||||
x_create_picture_with_pictfmt(ps, wid, hei, NULL, 0, NULL);
|
x_create_picture_with_visual(ps->c, ps->root, wid, hei, ps->vis, 0, NULL);
|
||||||
|
|
||||||
if (!tmp_picture) {
|
if (!tmp_picture) {
|
||||||
log_error("Failed to build intermediate Picture.");
|
log_error("Failed to build intermediate Picture.");
|
||||||
|
@ -964,7 +964,7 @@ void paint_all(session_t *ps, win *const t, bool ignore_damage) {
|
||||||
// to it
|
// to it
|
||||||
auto pictfmt = x_get_pictform_for_visual(ps->c, ps->vis);
|
auto pictfmt = x_get_pictform_for_visual(ps->c, ps->vis);
|
||||||
xcb_render_picture_t new_pict = x_create_picture_with_pictfmt(
|
xcb_render_picture_t new_pict = x_create_picture_with_pictfmt(
|
||||||
ps, ps->root_width, ps->root_height, pictfmt, 0, NULL);
|
ps->c, ps->root, ps->root_width, ps->root_height, pictfmt, 0, NULL);
|
||||||
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC,
|
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC,
|
||||||
ps->tgt_buffer.pict, XCB_NONE, new_pict, 0, 0,
|
ps->tgt_buffer.pict, XCB_NONE, new_pict, 0, 0,
|
||||||
0, 0, 0, 0, ps->root_width, ps->root_height);
|
0, 0, 0, 0, ps->root_width, ps->root_height);
|
||||||
|
|
23
src/x.c
23
src/x.c
|
@ -182,6 +182,7 @@ x_create_picture_with_pictfmt_and_pixmap(
|
||||||
pixmap, pictfmt->id, valuemask, buf));
|
pixmap, pictfmt->id, valuemask, buf));
|
||||||
free(buf);
|
free(buf);
|
||||||
if (e) {
|
if (e) {
|
||||||
|
x_print_error(e->full_sequence, e->major_code, e->minor_code, e->error_code);
|
||||||
log_error("failed to create picture");
|
log_error("failed to create picture");
|
||||||
return XCB_NONE;
|
return XCB_NONE;
|
||||||
}
|
}
|
||||||
|
@ -216,39 +217,31 @@ x_create_picture_with_standard_and_pixmap(
|
||||||
* Create an picture.
|
* Create an picture.
|
||||||
*/
|
*/
|
||||||
xcb_render_picture_t
|
xcb_render_picture_t
|
||||||
x_create_picture_with_pictfmt(session_t *ps, int wid, int hei,
|
x_create_picture_with_pictfmt(xcb_connection_t *c, xcb_drawable_t d, int wid, int hei,
|
||||||
const xcb_render_pictforminfo_t *pictfmt, unsigned long valuemask,
|
const xcb_render_pictforminfo_t *pictfmt, unsigned long valuemask,
|
||||||
const xcb_render_create_picture_value_list_t *attr)
|
const xcb_render_create_picture_value_list_t *attr)
|
||||||
{
|
{
|
||||||
if (!pictfmt)
|
|
||||||
pictfmt = x_get_pictform_for_visual(ps->c, ps->vis);
|
|
||||||
|
|
||||||
if (!pictfmt) {
|
|
||||||
log_fatal("Default visual is invalid");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
int depth = pictfmt->depth;
|
int depth = pictfmt->depth;
|
||||||
|
|
||||||
xcb_pixmap_t tmp_pixmap = x_create_pixmap(ps->c, depth, ps->root, wid, hei);
|
xcb_pixmap_t tmp_pixmap = x_create_pixmap(c, depth, d, wid, hei);
|
||||||
if (!tmp_pixmap)
|
if (!tmp_pixmap)
|
||||||
return XCB_NONE;
|
return XCB_NONE;
|
||||||
|
|
||||||
xcb_render_picture_t picture =
|
xcb_render_picture_t picture =
|
||||||
x_create_picture_with_pictfmt_and_pixmap(ps->c, pictfmt, tmp_pixmap, valuemask, attr);
|
x_create_picture_with_pictfmt_and_pixmap(c, pictfmt, tmp_pixmap, valuemask, attr);
|
||||||
|
|
||||||
xcb_free_pixmap(ps->c, tmp_pixmap);
|
xcb_free_pixmap(c, tmp_pixmap);
|
||||||
|
|
||||||
return picture;
|
return picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_render_picture_t
|
xcb_render_picture_t
|
||||||
x_create_picture_with_visual(session_t *ps, int w, int h,
|
x_create_picture_with_visual(xcb_connection_t *c, xcb_drawable_t d, int w, int h,
|
||||||
xcb_visualid_t visual, unsigned long valuemask,
|
xcb_visualid_t visual, unsigned long valuemask,
|
||||||
const xcb_render_create_picture_value_list_t *attr)
|
const xcb_render_create_picture_value_list_t *attr)
|
||||||
{
|
{
|
||||||
auto pictfmt = x_get_pictform_for_visual(ps->c, visual);
|
auto pictfmt = x_get_pictform_for_visual(c, visual);
|
||||||
return x_create_picture_with_pictfmt(ps, w, h, pictfmt, valuemask, attr);
|
return x_create_picture_with_pictfmt(c, d, w, h, pictfmt, valuemask, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool x_fetch_region(xcb_connection_t *c, xcb_xfixes_region_t r, pixman_region32_t *res) {
|
bool x_fetch_region(xcb_connection_t *c, xcb_xfixes_region_t r, pixman_region32_t *res) {
|
||||||
|
|
49
src/x.h
49
src/x.h
|
@ -11,8 +11,8 @@
|
||||||
#include <xcb/xfixes.h>
|
#include <xcb/xfixes.h>
|
||||||
|
|
||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
#include "region.h"
|
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
#include "region.h"
|
||||||
|
|
||||||
typedef struct session session_t;
|
typedef struct session session_t;
|
||||||
|
|
||||||
|
@ -34,15 +34,16 @@ typedef struct winprop {
|
||||||
|
|
||||||
#define XCB_SYNCED_VOID(func, c, ...) \
|
#define XCB_SYNCED_VOID(func, c, ...) \
|
||||||
xcb_request_check(c, func##_checked(c, __VA_ARGS__));
|
xcb_request_check(c, func##_checked(c, __VA_ARGS__));
|
||||||
#define XCB_SYNCED(func, c, ...) \
|
#define XCB_SYNCED(func, c, ...) \
|
||||||
({ \
|
({ \
|
||||||
xcb_generic_error_t *e = NULL; \
|
xcb_generic_error_t *e = NULL; \
|
||||||
__auto_type r = func##_reply(c, func(c, __VA_ARGS__), &e); \
|
__auto_type r = func##_reply(c, func(c, __VA_ARGS__), &e); \
|
||||||
if (e) { \
|
if (e) { \
|
||||||
x_print_error(e->sequence, e->major_code, e->minor_code, e->error_code); \
|
x_print_error(e->sequence, e->major_code, e->minor_code, \
|
||||||
free(e); \
|
e->error_code); \
|
||||||
} \
|
free(e); \
|
||||||
r; \
|
} \
|
||||||
|
r; \
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,13 +93,16 @@ xcb_window_t wid_get_prop_window(session_t *ps, xcb_window_t wid, xcb_atom_t apr
|
||||||
/**
|
/**
|
||||||
* Get the value of a text property of a window.
|
* Get the value of a text property of a window.
|
||||||
*/
|
*/
|
||||||
bool wid_get_text_prop(session_t *ps, xcb_window_t wid, xcb_atom_t prop, char ***pstrlst, int *pnstr);
|
bool wid_get_text_prop(session_t *ps, xcb_window_t wid, xcb_atom_t prop, char ***pstrlst,
|
||||||
|
int *pnstr);
|
||||||
|
|
||||||
const xcb_render_pictforminfo_t *x_get_pictform_for_visual(xcb_connection_t *, xcb_visualid_t);
|
const xcb_render_pictforminfo_t *
|
||||||
|
x_get_pictform_for_visual(xcb_connection_t *, xcb_visualid_t);
|
||||||
int x_get_visual_depth(xcb_connection_t *, xcb_visualid_t);
|
int x_get_visual_depth(xcb_connection_t *, xcb_visualid_t);
|
||||||
|
|
||||||
xcb_render_picture_t
|
xcb_render_picture_t
|
||||||
x_create_picture_with_pictfmt_and_pixmap(xcb_connection_t *, const xcb_render_pictforminfo_t *pictfmt,
|
x_create_picture_with_pictfmt_and_pixmap(xcb_connection_t *,
|
||||||
|
const xcb_render_pictforminfo_t *pictfmt,
|
||||||
xcb_pixmap_t pixmap, unsigned long valuemask,
|
xcb_pixmap_t pixmap, unsigned long valuemask,
|
||||||
const xcb_render_create_picture_value_list_t *attr)
|
const xcb_render_create_picture_value_list_t *attr)
|
||||||
attr_nonnull(1, 2);
|
attr_nonnull(1, 2);
|
||||||
|
@ -118,14 +122,16 @@ x_create_picture_with_standard_and_pixmap(xcb_connection_t *, xcb_pict_standard_
|
||||||
/**
|
/**
|
||||||
* Create an picture.
|
* Create an picture.
|
||||||
*/
|
*/
|
||||||
xcb_render_picture_t
|
xcb_render_picture_t attr_nonnull(1, 4)
|
||||||
x_create_picture_with_pictfmt(session_t *ps, int wid, int hei,
|
x_create_picture_with_pictfmt(xcb_connection_t *, xcb_drawable_t, int wid, int hei,
|
||||||
const xcb_render_pictforminfo_t *pictfmt, unsigned long valuemask,
|
const xcb_render_pictforminfo_t *pictfmt,
|
||||||
const xcb_render_create_picture_value_list_t *attr);
|
unsigned long valuemask,
|
||||||
|
const xcb_render_create_picture_value_list_t *attr);
|
||||||
|
|
||||||
xcb_render_picture_t
|
xcb_render_picture_t attr_nonnull(1)
|
||||||
x_create_picture_with_visual(session_t *ps, int w, int h, xcb_visualid_t visual, unsigned long valuemask,
|
x_create_picture_with_visual(xcb_connection_t *, xcb_drawable_t, int w, int h,
|
||||||
const xcb_render_create_picture_value_list_t *attr);
|
xcb_visualid_t visual, unsigned long valuemask,
|
||||||
|
const xcb_render_create_picture_value_list_t *attr);
|
||||||
|
|
||||||
/// Fetch a X region and store it in a pixman region
|
/// Fetch a X region and store it in a pixman region
|
||||||
bool x_fetch_region(xcb_connection_t *, xcb_xfixes_region_t r, region_t *res);
|
bool x_fetch_region(xcb_connection_t *, xcb_xfixes_region_t r, region_t *res);
|
||||||
|
@ -180,4 +186,5 @@ bool x_fence_sync(xcb_connection_t *, xcb_sync_fence_t);
|
||||||
* will be allocated, and `*ret` will be updated.
|
* will be allocated, and `*ret` will be updated.
|
||||||
* @param[inout] size size of the array pointed to by `ret`.
|
* @param[inout] size size of the array pointed to by `ret`.
|
||||||
*/
|
*/
|
||||||
size_t x_picture_filter_from_conv(const conv *kernel, double center, xcb_render_fixed_t **ret, size_t *size);
|
size_t x_picture_filter_from_conv(const conv *kernel, double center,
|
||||||
|
xcb_render_fixed_t **ret, size_t *size);
|
||||||
|
|
Loading…
Reference in New Issue