Move opengl related function prototype to opengl.h

And aggregate some of the OPENGL ifdefs

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2018-09-29 22:47:12 +01:00
parent c01ad5bf04
commit 417744df14
5 changed files with 149 additions and 167 deletions

View File

@ -486,6 +486,8 @@ typedef struct {
}
#endif
#else
typedef uint32_t glx_prog_main_t;
#endif
typedef struct {
@ -553,10 +555,8 @@ typedef struct _options_t {
bool glx_use_gpushader4;
/// Custom fragment shader for painting windows, as a string.
char *glx_fshader_win_str;
#ifdef CONFIG_OPENGL
/// Custom GLX program used for painting window.
glx_prog_main_t glx_prog_win;
#endif
/// Whether to fork to background.
bool fork_after_register;
/// Whether to detect rounded corners.
@ -2121,97 +2121,6 @@ void
xr_glx_sync(session_t *ps, Drawable d, XSyncFence *pfence);
#endif
bool
glx_init(session_t *ps, bool need_render);
void
glx_destroy(session_t *ps);
bool
glx_reinit(session_t *ps, bool need_render);
void
glx_on_root_change(session_t *ps);
bool
glx_init_blur(session_t *ps);
#ifdef CONFIG_OPENGL
bool
glx_load_prog_main(session_t *ps,
const char *vshader_str, const char *fshader_str,
glx_prog_main_t *pprogram);
#endif
bool
glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, Pixmap pixmap,
unsigned width, unsigned height, unsigned depth);
void
glx_release_pixmap(session_t *ps, glx_texture_t *ptex);
void
glx_paint_pre(session_t *ps, XserverRegion *preg);
/**
* Check if a texture is binded, or is binded to the given pixmap.
*/
static inline bool
glx_tex_binded(const glx_texture_t *ptex, Pixmap pixmap) {
return ptex && ptex->glpixmap && ptex->texture
&& (!pixmap || pixmap == ptex->pixmap);
}
void
glx_set_clip(session_t *ps, XserverRegion reg, const reg_data_t *pcache_reg);
#ifdef CONFIG_OPENGL
bool
glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
GLfloat factor_center,
XserverRegion reg_tgt, const reg_data_t *pcache_reg,
glx_blur_cache_t *pbc);
#endif
bool
glx_dim_dst(session_t *ps, int dx, int dy, int width, int height, float z,
GLfloat factor, XserverRegion reg_tgt, const reg_data_t *pcache_reg);
bool
glx_render_(session_t *ps, const glx_texture_t *ptex,
int x, int y, int dx, int dy, int width, int height, int z,
double opacity, bool argb, bool neg,
XserverRegion reg_tgt, const reg_data_t *pcache_reg
#ifdef CONFIG_OPENGL
, const glx_prog_main_t *pprogram
#endif
);
#ifdef CONFIG_OPENGL
#define \
glx_render(ps, ptex, x, y, dx, dy, width, height, z, opacity, argb, neg, reg_tgt, pcache_reg, pprogram) \
glx_render_(ps, ptex, x, y, dx, dy, width, height, z, opacity, argb, neg, reg_tgt, pcache_reg, pprogram)
#else
#define \
glx_render(ps, ptex, x, y, dx, dy, width, height, z, opacity, argb, neg, reg_tgt, pcache_reg, pprogram) \
glx_render_(ps, ptex, x, y, dx, dy, width, height, z, opacity, argb, neg, reg_tgt, pcache_reg)
#endif
unsigned char *
glx_take_screenshot(session_t *ps, int *out_length);
#ifdef CONFIG_OPENGL
GLuint
glx_create_shader(GLenum shader_type, const char *shader_str);
GLuint
glx_create_program(const GLuint * const shaders, int nshaders);
GLuint
glx_create_program_from_str(const char *vert_shader_str,
const char *frag_shader_str);
#endif
/**
* Free a GLX texture.
*/
@ -2261,49 +2170,6 @@ free_glx_bc(session_t *ps, glx_blur_cache_t *pbc) {
#endif
#endif
/**
* Free a glx_texture_t.
*/
static inline void
free_texture(session_t *ps, glx_texture_t **pptex) {
glx_texture_t *ptex = *pptex;
// Quit if there's nothing
if (!ptex)
return;
#ifdef CONFIG_OPENGL
glx_release_pixmap(ps, ptex);
free_texture_r(ps, &ptex->texture);
// Free structure itself
free(ptex);
*pptex = NULL;
#endif
assert(!*pptex);
}
/**
* Free GLX part of paint_t.
*/
static inline void
free_paint_glx(session_t *ps, paint_t *ppaint) {
free_texture(ps, &ppaint->ptex);
}
/**
* Free GLX part of win.
*/
static inline void
free_win_res_glx(session_t *ps, win *w) {
free_paint_glx(ps, &w->paint);
free_paint_glx(ps, &w->shadow_paint);
#ifdef CONFIG_OPENGL
free_glx_bc(ps, &w->glx_blur_cache);
#endif
}
/**
* Add a OpenGL debugging marker.
*/