From cba1d6de221e33b4a00b88c6a9ddcd1b332ffba6 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 11 Mar 2021 13:41:40 -0500 Subject: [PATCH] glx: Pull use_x_font out of the context vtable The client-side implementation of this operates entirely in terms of the GL and X client APIs. There's nothing DRI-specific about it, evidenced by apple and windows using it unchanged. Save a little code size by handling the direct/indirect difference directly. Reviewed-by: Jesse Natalie Part-of: --- src/glx/applegl_glx.c | 1 - src/glx/dri2_glx.c | 1 - src/glx/dri3_glx.c | 1 - src/glx/drisw_glx.c | 1 - src/glx/driwindows_glx.c | 1 - src/glx/glxclient.h | 2 -- src/glx/glxcmds.c | 26 ++++++++++++++++++++++++-- src/glx/indirect_glx.c | 25 ------------------------- 8 files changed, 24 insertions(+), 34 deletions(-) diff --git a/src/glx/applegl_glx.c b/src/glx/applegl_glx.c index c086e51..b15e533 100644 --- a/src/glx/applegl_glx.c +++ b/src/glx/applegl_glx.c @@ -114,7 +114,6 @@ static const struct glx_context_vtable applegl_context_vtable = { .unbind = applegl_unbind_context, .wait_gl = applegl_wait_gl, .wait_x = applegl_wait_x, - .use_x_font = DRI_glXUseXFont, .bind_tex_image = NULL, .release_tex_image = NULL, .get_proc_address = applegl_get_proc_address, diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 15252b5..53bebe7 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -1047,7 +1047,6 @@ static const struct glx_context_vtable dri2_context_vtable = { .unbind = dri2_unbind_context, .wait_gl = dri2_wait_gl, .wait_x = dri2_wait_x, - .use_x_font = DRI_glXUseXFont, .bind_tex_image = dri2_bind_tex_image, .release_tex_image = dri2_release_tex_image, .get_proc_address = NULL, diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index ce3d040..4afad89 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -714,7 +714,6 @@ static const struct glx_context_vtable dri3_context_vtable = { .unbind = dri3_unbind_context, .wait_gl = dri3_wait_gl, .wait_x = dri3_wait_x, - .use_x_font = DRI_glXUseXFont, .bind_tex_image = dri3_bind_tex_image, .release_tex_image = dri3_release_tex_image, .get_proc_address = NULL, diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index ebd0dcd..32a876c 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -476,7 +476,6 @@ static const struct glx_context_vtable drisw_context_vtable = { .unbind = drisw_unbind_context, .wait_gl = NULL, .wait_x = NULL, - .use_x_font = DRI_glXUseXFont, .bind_tex_image = drisw_bind_tex_image, .release_tex_image = drisw_release_tex_image, .get_proc_address = NULL, diff --git a/src/glx/driwindows_glx.c b/src/glx/driwindows_glx.c index 8552543..0df7e49 100644 --- a/src/glx/driwindows_glx.c +++ b/src/glx/driwindows_glx.c @@ -150,7 +150,6 @@ static const struct glx_context_vtable driwindows_context_vtable = { .unbind = driwindows_unbind_context, .wait_gl = NULL, .wait_x = NULL, - .use_x_font = DRI_glXUseXFont, .bind_tex_image = driwindows_bind_tex_image, .release_tex_image = driwindows_release_tex_image, .get_proc_address = NULL, diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 1f19905..ecda3e5 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -227,8 +227,6 @@ struct glx_context_vtable { void (*unbind)(struct glx_context *context, struct glx_context *new_ctx); void (*wait_gl)(struct glx_context *ctx); void (*wait_x)(struct glx_context *ctx); - void (*use_x_font)(struct glx_context *ctx, - Font font, int first, int count, int listBase); void (*bind_tex_image)(Display * dpy, GLXDrawable drawable, int buffer, const int *attrib_list); diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 5d5d77d..9a16cce 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -583,9 +583,31 @@ _GLX_PUBLIC void glXUseXFont(Font font, int first, int count, int listBase) { struct glx_context *gc = __glXGetCurrentContext(); + xGLXUseXFontReq *req; + Display *dpy = gc->currentDpy; - if (gc->vtable->use_x_font) - gc->vtable->use_x_font(gc, font, first, count, listBase); +#ifdef GLX_DIRECT_RENDERING + if (gc->isDirect) { + DRI_glXUseXFont(gc, font, first, count, listBase); + return; + } +#endif + + /* Flush any pending commands out */ + __glXFlushRenderBuffer(gc, gc->pc); + + /* Send the glXUseFont request */ + LockDisplay(dpy); + GetReq(GLXUseXFont, req); + req->reqType = gc->majorOpcode; + req->glxCode = X_GLXUseXFont; + req->contextTag = gc->currentContextTag; + req->font = font; + req->first = first; + req->count = count; + req->listBase = listBase; + UnlockDisplay(dpy); + SyncHandle(); } /************************************************************************/ diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c index a58d6f0..3e27929 100644 --- a/src/glx/indirect_glx.c +++ b/src/glx/indirect_glx.c @@ -230,30 +230,6 @@ indirect_wait_x(struct glx_context *gc) } static void -indirect_use_x_font(struct glx_context *gc, - Font font, int first, int count, int listBase) -{ - xGLXUseXFontReq *req; - Display *dpy = gc->currentDpy; - - /* Flush any pending commands out */ - __glXFlushRenderBuffer(gc, gc->pc); - - /* Send the glXUseFont request */ - LockDisplay(dpy); - GetReq(GLXUseXFont, req); - req->reqType = gc->majorOpcode; - req->glxCode = X_GLXUseXFont; - req->contextTag = gc->currentContextTag; - req->font = font; - req->first = first; - req->count = count; - req->listBase = listBase; - UnlockDisplay(dpy); - SyncHandle(); -} - -static void indirect_bind_tex_image(Display * dpy, GLXDrawable drawable, int buffer, const int *attrib_list) @@ -342,7 +318,6 @@ static const struct glx_context_vtable indirect_context_vtable = { .unbind = indirect_unbind_context, .wait_gl = indirect_wait_gl, .wait_x = indirect_wait_x, - .use_x_font = indirect_use_x_font, .bind_tex_image = indirect_bind_tex_image, .release_tex_image = indirect_release_tex_image, .get_proc_address = NULL, -- 2.7.4