Cache FBConfig used for shadows

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-02-03 18:09:11 +00:00
parent 8922312e42
commit 24370f44e6
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 38 additions and 29 deletions

View File

@ -38,45 +38,54 @@
static inline bool paint_bind_tex(session_t *ps, paint_t *ppaint, unsigned wid, unsigned hei, static inline bool paint_bind_tex(session_t *ps, paint_t *ppaint, unsigned wid, unsigned hei,
unsigned depth, xcb_visualid_t visual, bool force) { unsigned depth, xcb_visualid_t visual, bool force) {
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
// XXX This is a mess. But this will go away after the backend refactor.
static thread_local struct glx_fbconfig_info *argb_fbconfig = NULL;
if (!ppaint->pixmap) if (!ppaint->pixmap)
return false; return false;
xcb_render_pictforminfo_t *pictfmt = NULL; struct glx_fbconfig_info *fbcfg;
xcb_render_pictforminfo_t tmp_pictfmt = {.direct =
{
.red_mask = 255,
.blue_mask = 255,
.green_mask = 255,
.alpha_mask = depth == 32 ? 255 : 0,
},
.type = XCB_RENDER_PICT_TYPE_DIRECT};
if (!depth) {
assert(visual);
depth = x_get_visual_depth(ps->c, visual);
}
if (!visual) { if (!visual) {
assert(depth); assert(depth == 32);
pictfmt = &tmp_pictfmt; if (!argb_fbconfig) {
xcb_render_pictforminfo_t tmp_pictfmt = {
.direct =
{
.red_mask = 255,
.blue_mask = 255,
.green_mask = 255,
.alpha_mask = 255,
},
.type = XCB_RENDER_PICT_TYPE_DIRECT};
argb_fbconfig = glx_find_fbconfig(ps->dpy, ps->scr, &tmp_pictfmt, 32);
}
if (!argb_fbconfig) {
log_error("Failed to find appropriate FBConfig for 32 bit depth");
return false;
}
fbcfg = argb_fbconfig;
} else { } else {
pictfmt = x_get_pictform_for_visual(ps->c, visual); xcb_render_pictforminfo_t *pictfmt = x_get_pictform_for_visual(ps->c, visual);
} if (!depth) {
assert(visual);
depth = x_get_visual_depth(ps->c, visual);
}
if (!pictfmt) { if (!pictfmt) {
return false; return false;
} }
if (!ppaint->fbcfg) { if (!ppaint->fbcfg) {
ppaint->fbcfg = glx_find_fbconfig(ps->dpy, ps->scr, pictfmt, depth); ppaint->fbcfg = glx_find_fbconfig(ps->dpy, ps->scr, pictfmt, depth);
} }
if (!ppaint->fbcfg) { if (!ppaint->fbcfg) {
log_error("Failed to find appropriate FBConfig for X pixmap"); log_error("Failed to find appropriate FBConfig for X pixmap");
return false; return false;
}
fbcfg = ppaint->fbcfg;
} }
if (force || !glx_tex_binded(ppaint->ptex, ppaint->pixmap)) if (force || !glx_tex_binded(ppaint->ptex, ppaint->pixmap))
return glx_bind_pixmap(ps, &ppaint->ptex, ppaint->pixmap, wid, hei, ppaint->fbcfg); return glx_bind_pixmap(ps, &ppaint->ptex, ppaint->pixmap, wid, hei, fbcfg);
#endif #endif
return true; return true;
} }