glx (new backend): Add some missing functions
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
8c71f3fcbe
commit
6e454adff1
|
@ -223,14 +223,15 @@ bool gl_compose(const gl_texture_t *ptex, int x, int y, int dx, int dy, int widt
|
||||||
}
|
}
|
||||||
|
|
||||||
// Programmable path
|
// Programmable path
|
||||||
assert(shader->prog);
|
if (shader->prog) {
|
||||||
glUseProgram(shader->prog);
|
glUseProgram(shader->prog);
|
||||||
if (shader->unifm_opacity >= 0)
|
if (shader->unifm_opacity >= 0)
|
||||||
glUniform1f(shader->unifm_opacity, opacity);
|
glUniform1f(shader->unifm_opacity, opacity);
|
||||||
if (shader->unifm_invert_color >= 0)
|
if (shader->unifm_invert_color >= 0)
|
||||||
glUniform1i(shader->unifm_invert_color, neg);
|
glUniform1i(shader->unifm_invert_color, neg);
|
||||||
if (shader->unifm_tex >= 0)
|
if (shader->unifm_tex >= 0)
|
||||||
glUniform1i(shader->unifm_tex, 0);
|
glUniform1i(shader->unifm_tex, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// log_trace("Draw: %d, %d, %d, %d -> %d, %d (%d, %d) z %d\n",
|
// log_trace("Draw: %d, %d, %d, %d -> %d, %d (%d, %d) z %d\n",
|
||||||
// x, y, width, height, dx, dy, ptex->width, ptex->height, z);
|
// x, y, width, height, dx, dy, ptex->width, ptex->height, z);
|
||||||
|
|
|
@ -69,6 +69,12 @@ GLuint gl_create_shader(GLenum shader_type, const char *shader_str);
|
||||||
GLuint gl_create_program(const GLuint *const shaders, int nshaders);
|
GLuint gl_create_program(const GLuint *const shaders, int nshaders);
|
||||||
GLuint
|
GLuint
|
||||||
gl_create_program_from_str(const char *vert_shader_str, const char *frag_shader_str);
|
gl_create_program_from_str(const char *vert_shader_str, const char *frag_shader_str);
|
||||||
|
/**
|
||||||
|
* @brief Render a region with texture data.
|
||||||
|
*/
|
||||||
|
bool gl_compose(const gl_texture_t *ptex, int x, int y, int dx, int dy, int width,
|
||||||
|
int height, int z, double opacity, bool argb, bool neg,
|
||||||
|
const region_t *reg_tgt, const gl_win_shader_t *shader);
|
||||||
|
|
||||||
bool gl_load_prog_main(session_t *ps, const char *vshader_str, const char *fshader_str,
|
bool gl_load_prog_main(session_t *ps, const char *vshader_str, const char *fshader_str,
|
||||||
gl_win_shader_t *pprogram);
|
gl_win_shader_t *pprogram);
|
||||||
|
|
|
@ -101,8 +101,10 @@ static void glx_release_pixmap(struct _glx_data *gd, Display *dpy, struct _glx_w
|
||||||
/**
|
/**
|
||||||
* Free a glx_texture_t.
|
* Free a glx_texture_t.
|
||||||
*/
|
*/
|
||||||
static void attr_unused glx_release_win(struct _glx_data *gd, Display *dpy, struct _glx_win_data *wd) {
|
static void glx_release_win(void *backend_data, session_t *ps, win *w, void *win_data) {
|
||||||
glx_release_pixmap(gd, dpy, wd);
|
struct _glx_win_data *wd = win_data;
|
||||||
|
struct _glx_data *gd = backend_data;
|
||||||
|
glx_release_pixmap(gd, ps->dpy, wd);
|
||||||
glDeleteTextures(1, &wd->texture.texture);
|
glDeleteTextures(1, &wd->texture.texture);
|
||||||
|
|
||||||
// Free structure itself
|
// Free structure itself
|
||||||
|
@ -433,7 +435,7 @@ static void *glx_init(session_t *ps) {
|
||||||
// Check GL_ARB_texture_non_power_of_two, requires a GLX context and
|
// Check GL_ARB_texture_non_power_of_two, requires a GLX context and
|
||||||
// must precede FBConfig fetching
|
// must precede FBConfig fetching
|
||||||
gd->cap.non_power_of_two_texture = gl_has_extension("GL_ARB_texture_non_"
|
gd->cap.non_power_of_two_texture = gl_has_extension("GL_ARB_texture_non_"
|
||||||
"power_of_two");
|
"power_of_two");
|
||||||
|
|
||||||
gd->glXBindTexImage = (void *)glXGetProcAddress((const GLubyte *)"glXBindTexImage"
|
gd->glXBindTexImage = (void *)glXGetProcAddress((const GLubyte *)"glXBindTexImage"
|
||||||
"EXT");
|
"EXT");
|
||||||
|
@ -472,7 +474,7 @@ static void *glx_init(session_t *ps) {
|
||||||
// glXSwapBuffers(ps->dpy, get_tgt_window(ps));
|
// glXSwapBuffers(ps->dpy, get_tgt_window(ps));
|
||||||
|
|
||||||
// Initialize blur filters
|
// Initialize blur filters
|
||||||
gl_create_blur_filters(ps, gd->blur_shader, &gd->cap);
|
// gl_create_blur_filters(ps, gd->blur_shader, &gd->cap);
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
|
|
||||||
|
@ -596,13 +598,35 @@ static void glx_present(void *backend_data, session_t *ps) {
|
||||||
glXSwapBuffers(ps->dpy, ps->overlay != XCB_NONE ? ps->overlay : ps->root);
|
glXSwapBuffers(ps->dpy, ps->overlay != XCB_NONE ? ps->overlay : ps->root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int glx_buffer_age(void *backend_data, session_t *ps) {
|
||||||
|
if (ps->o.glx_swap_method == SWAPM_BUFFER_AGE) {
|
||||||
|
unsigned int val;
|
||||||
|
glXQueryDrawable(ps->dpy, get_tgt_window(ps), GLX_BACK_BUFFER_AGE_EXT, &val);
|
||||||
|
return (int)val ?: -1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void glx_compose(void *backend_data, session_t *ps, win *w, void *win_data,
|
||||||
|
int dst_x, int dst_y, const region_t *region) {
|
||||||
|
struct _glx_data *gd = backend_data;
|
||||||
|
struct _glx_win_data *wd = win_data;
|
||||||
|
|
||||||
|
gl_compose(&wd->texture, 0, 0, dst_x, dst_y, w->widthb, w->heightb, 0, 0, false,
|
||||||
|
false, region, &gd->win_shader);
|
||||||
|
}
|
||||||
|
|
||||||
backend_info_t glx_backend = {
|
backend_info_t glx_backend = {
|
||||||
.init = glx_init,
|
.init = glx_init,
|
||||||
.deinit = glx_deinit,
|
.deinit = glx_deinit,
|
||||||
.prepare_win = glx_prepare_win,
|
.prepare_win = glx_prepare_win,
|
||||||
.render_win = glx_render_win,
|
.render_win = glx_render_win,
|
||||||
|
.release_win = glx_release_win,
|
||||||
.present = glx_present,
|
.present = glx_present,
|
||||||
|
.compose = glx_compose,
|
||||||
.is_win_transparent = default_is_win_transparent,
|
.is_win_transparent = default_is_win_transparent,
|
||||||
.is_frame_transparent = default_is_frame_transparent,
|
.is_frame_transparent = default_is_frame_transparent,
|
||||||
|
.buffer_age = glx_buffer_age,
|
||||||
.max_buffer_age = 5, // XXX why?
|
.max_buffer_age = 5, // XXX why?
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue