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,31 +38,38 @@
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 = if (!visual) {
assert(depth == 32);
if (!argb_fbconfig) {
xcb_render_pictforminfo_t tmp_pictfmt = {
.direct =
{ {
.red_mask = 255, .red_mask = 255,
.blue_mask = 255, .blue_mask = 255,
.green_mask = 255, .green_mask = 255,
.alpha_mask = depth == 32 ? 255 : 0, .alpha_mask = 255,
}, },
.type = XCB_RENDER_PICT_TYPE_DIRECT}; .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 {
xcb_render_pictforminfo_t *pictfmt = x_get_pictform_for_visual(ps->c, visual);
if (!depth) { if (!depth) {
assert(visual); assert(visual);
depth = x_get_visual_depth(ps->c, visual); depth = x_get_visual_depth(ps->c, visual);
} }
if (!visual) {
assert(depth);
pictfmt = &tmp_pictfmt;
} else {
pictfmt = x_get_pictform_for_visual(ps->c, visual);
}
if (!pictfmt) { if (!pictfmt) {
return false; return false;
} }
@ -74,9 +81,11 @@ static inline bool paint_bind_tex(session_t *ps, paint_t *ppaint, unsigned wid,
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;
} }