Move session_t::pictfmts into x.c
As a global variable, since they shouldn't change during the period compton is running. Also limit the scope of the variable to x.c. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
0be3fb5ea2
commit
ad3dc5d233
|
@ -356,8 +356,6 @@ typedef struct session {
|
||||||
xcb_connection_t *c;
|
xcb_connection_t *c;
|
||||||
/// Default visual.
|
/// Default visual.
|
||||||
xcb_visualid_t vis;
|
xcb_visualid_t vis;
|
||||||
/// Pict formats info
|
|
||||||
xcb_render_query_pict_formats_reply_t *pictfmts;
|
|
||||||
/// Default depth.
|
/// Default depth.
|
||||||
int depth;
|
int depth;
|
||||||
/// Root window.
|
/// Root window.
|
||||||
|
|
|
@ -3161,7 +3161,6 @@ session_destroy(session_t *ps) {
|
||||||
}
|
}
|
||||||
free(ps->o.glx_fshader_win_str);
|
free(ps->o.glx_fshader_win_str);
|
||||||
free_xinerama_info(ps);
|
free_xinerama_info(ps);
|
||||||
free(ps->pictfmts);
|
|
||||||
|
|
||||||
deinit_render(ps);
|
deinit_render(ps);
|
||||||
|
|
||||||
|
|
28
src/x.c
28
src/x.c
|
@ -111,27 +111,30 @@ bool wid_get_text_prop(session_t *ps, xcb_window_t wid, xcb_atom_t prop,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void x_get_server_pictfmts(session_t *ps) {
|
// A cache of pict formats. We assume they don't change during the lifetime
|
||||||
if (ps->pictfmts)
|
// of compton
|
||||||
|
static thread_local xcb_render_query_pict_formats_reply_t *g_pictfmts = NULL;
|
||||||
|
|
||||||
|
static inline void x_get_server_pictfmts(xcb_connection_t *c) {
|
||||||
|
if (g_pictfmts)
|
||||||
return;
|
return;
|
||||||
xcb_generic_error_t *e = NULL;
|
xcb_generic_error_t *e = NULL;
|
||||||
// Get window picture format
|
// Get window picture format
|
||||||
ps->pictfmts =
|
g_pictfmts =
|
||||||
xcb_render_query_pict_formats_reply(ps->c,
|
xcb_render_query_pict_formats_reply(c,
|
||||||
xcb_render_query_pict_formats(ps->c), &e);
|
xcb_render_query_pict_formats(c), &e);
|
||||||
if (e || !ps->pictfmts) {
|
if (e || !g_pictfmts) {
|
||||||
log_fatal("failed to get pict formats\n");
|
log_fatal("failed to get pict formats\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_render_pictforminfo_t *x_get_pictform_for_visual(session_t *ps, xcb_visualid_t visual) {
|
xcb_render_pictforminfo_t *x_get_pictform_for_visual(session_t *ps, xcb_visualid_t visual) {
|
||||||
if (!ps->pictfmts)
|
x_get_server_pictfmts(ps->c);
|
||||||
x_get_server_pictfmts(ps);
|
|
||||||
|
|
||||||
xcb_render_pictvisual_t *pv = xcb_render_util_find_visual_format(ps->pictfmts, visual);
|
xcb_render_pictvisual_t *pv = xcb_render_util_find_visual_format(g_pictfmts, visual);
|
||||||
for(xcb_render_pictforminfo_iterator_t i =
|
for(xcb_render_pictforminfo_iterator_t i =
|
||||||
xcb_render_query_pict_formats_formats_iterator(ps->pictfmts); i.rem;
|
xcb_render_query_pict_formats_formats_iterator(g_pictfmts); i.rem;
|
||||||
xcb_render_pictforminfo_next(&i)) {
|
xcb_render_pictforminfo_next(&i)) {
|
||||||
if (i.data->id == pv->format) {
|
if (i.data->id == pv->format) {
|
||||||
return i.data;
|
return i.data;
|
||||||
|
@ -183,11 +186,10 @@ x_create_picture_with_standard_and_pixmap(
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (!ps->pictfmts)
|
x_get_server_pictfmts(ps->c);
|
||||||
x_get_server_pictfmts(ps);
|
|
||||||
|
|
||||||
xcb_render_pictforminfo_t *pictfmt =
|
xcb_render_pictforminfo_t *pictfmt =
|
||||||
xcb_render_util_find_standard_format(ps->pictfmts, standard);
|
xcb_render_util_find_standard_format(g_pictfmts, standard);
|
||||||
assert(pictfmt);
|
assert(pictfmt);
|
||||||
return x_create_picture_with_pictfmt_and_pixmap(ps, pictfmt, pixmap, valuemask, attr);
|
return x_create_picture_with_pictfmt_and_pixmap(ps, pictfmt, pixmap, valuemask, attr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue