glx: add drawable type argument when create drawable
For distinguish different behavior of pixmap and pbuffer in latter commits. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Qiang Yu <yuq825@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13750>
This commit is contained in:
@@ -309,7 +309,8 @@ dri2DestroyDrawable(__GLXDRIdrawable *base)
|
|||||||
|
|
||||||
static __GLXDRIdrawable *
|
static __GLXDRIdrawable *
|
||||||
dri2CreateDrawable(struct glx_screen *base, XID xDrawable,
|
dri2CreateDrawable(struct glx_screen *base, XID xDrawable,
|
||||||
GLXDrawable drawable, struct glx_config *config_base)
|
GLXDrawable drawable, int type,
|
||||||
|
struct glx_config *config_base)
|
||||||
{
|
{
|
||||||
struct dri2_drawable *pdraw;
|
struct dri2_drawable *pdraw;
|
||||||
struct dri2_screen *psc = (struct dri2_screen *) base;
|
struct dri2_screen *psc = (struct dri2_screen *) base;
|
||||||
|
@@ -344,7 +344,8 @@ dri3_destroy_drawable(__GLXDRIdrawable *base)
|
|||||||
|
|
||||||
static __GLXDRIdrawable *
|
static __GLXDRIdrawable *
|
||||||
dri3_create_drawable(struct glx_screen *base, XID xDrawable,
|
dri3_create_drawable(struct glx_screen *base, XID xDrawable,
|
||||||
GLXDrawable drawable, struct glx_config *config_base)
|
GLXDrawable drawable, int type,
|
||||||
|
struct glx_config *config_base)
|
||||||
{
|
{
|
||||||
struct dri3_drawable *pdraw;
|
struct dri3_drawable *pdraw;
|
||||||
struct dri3_screen *psc = (struct dri3_screen *) base;
|
struct dri3_screen *psc = (struct dri3_screen *) base;
|
||||||
|
@@ -405,7 +405,7 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pdraw = psc->driScreen->createDrawable(psc, glxDrawable, glxDrawable,
|
pdraw = psc->driScreen->createDrawable(psc, glxDrawable, glxDrawable,
|
||||||
config);
|
type, config);
|
||||||
|
|
||||||
if (pdraw == NULL) {
|
if (pdraw == NULL) {
|
||||||
ErrorMessageF("failed to create drawable\n");
|
ErrorMessageF("failed to create drawable\n");
|
||||||
|
@@ -605,7 +605,8 @@ driswDestroyDrawable(__GLXDRIdrawable * pdraw)
|
|||||||
|
|
||||||
static __GLXDRIdrawable *
|
static __GLXDRIdrawable *
|
||||||
driswCreateDrawable(struct glx_screen *base, XID xDrawable,
|
driswCreateDrawable(struct glx_screen *base, XID xDrawable,
|
||||||
GLXDrawable drawable, struct glx_config *modes)
|
GLXDrawable drawable, int type,
|
||||||
|
struct glx_config *modes)
|
||||||
{
|
{
|
||||||
struct drisw_drawable *pdp;
|
struct drisw_drawable *pdp;
|
||||||
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
|
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
|
||||||
|
@@ -258,7 +258,8 @@ driwindowsDestroyDrawable(__GLXDRIdrawable * pdraw)
|
|||||||
|
|
||||||
static __GLXDRIdrawable *
|
static __GLXDRIdrawable *
|
||||||
driwindowsCreateDrawable(struct glx_screen *base, XID xDrawable,
|
driwindowsCreateDrawable(struct glx_screen *base, XID xDrawable,
|
||||||
GLXDrawable drawable, struct glx_config *modes)
|
GLXDrawable drawable, int type,
|
||||||
|
struct glx_config *modes)
|
||||||
{
|
{
|
||||||
struct driwindows_drawable *pdp;
|
struct driwindows_drawable *pdp;
|
||||||
struct driwindows_screen *psc = (struct driwindows_screen *) base;
|
struct driwindows_screen *psc = (struct driwindows_screen *) base;
|
||||||
|
@@ -168,7 +168,7 @@ determineTextureFormat(const int *attribs, int numAttribs)
|
|||||||
|
|
||||||
static GLboolean
|
static GLboolean
|
||||||
CreateDRIDrawable(Display *dpy, struct glx_config *config,
|
CreateDRIDrawable(Display *dpy, struct glx_config *config,
|
||||||
XID drawable, XID glxdrawable,
|
XID drawable, XID glxdrawable, int type,
|
||||||
const int *attrib_list, size_t num_attribs)
|
const int *attrib_list, size_t num_attribs)
|
||||||
{
|
{
|
||||||
#ifdef GLX_DIRECT_RENDERING
|
#ifdef GLX_DIRECT_RENDERING
|
||||||
@@ -185,8 +185,8 @@ CreateDRIDrawable(Display *dpy, struct glx_config *config,
|
|||||||
if (psc->driScreen == NULL)
|
if (psc->driScreen == NULL)
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
|
||||||
pdraw = psc->driScreen->createDrawable(psc, drawable,
|
pdraw = psc->driScreen->createDrawable(psc, drawable, glxdrawable,
|
||||||
glxdrawable, config);
|
type, config);
|
||||||
if (pdraw == NULL) {
|
if (pdraw == NULL) {
|
||||||
fprintf(stderr, "failed to create drawable\n");
|
fprintf(stderr, "failed to create drawable\n");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
@@ -435,7 +435,7 @@ protocolDestroyDrawable(Display *dpy, GLXDrawable drawable, CARD32 glxCode)
|
|||||||
*/
|
*/
|
||||||
static GLXDrawable
|
static GLXDrawable
|
||||||
CreateDrawable(Display *dpy, struct glx_config *config,
|
CreateDrawable(Display *dpy, struct glx_config *config,
|
||||||
Drawable drawable, const int *attrib_list, CARD8 glxCode)
|
Drawable drawable, int type, const int *attrib_list)
|
||||||
{
|
{
|
||||||
xGLXCreateWindowReq *req;
|
xGLXCreateWindowReq *req;
|
||||||
struct glx_drawable *glxDraw;
|
struct glx_drawable *glxDraw;
|
||||||
@@ -466,13 +466,17 @@ CreateDrawable(Display *dpy, struct glx_config *config,
|
|||||||
data = (CARD32 *) (req + 1);
|
data = (CARD32 *) (req + 1);
|
||||||
|
|
||||||
req->reqType = opcode;
|
req->reqType = opcode;
|
||||||
req->glxCode = glxCode;
|
|
||||||
req->screen = config->screen;
|
req->screen = config->screen;
|
||||||
req->fbconfig = config->fbconfigID;
|
req->fbconfig = config->fbconfigID;
|
||||||
req->window = drawable;
|
req->window = drawable;
|
||||||
req->glxwindow = xid = XAllocID(dpy);
|
req->glxwindow = xid = XAllocID(dpy);
|
||||||
req->numAttribs = i;
|
req->numAttribs = i;
|
||||||
|
|
||||||
|
if (type == GLX_WINDOW_BIT)
|
||||||
|
req->glxCode = X_GLXCreateWindow;
|
||||||
|
else
|
||||||
|
req->glxCode = X_GLXCreatePixmap;
|
||||||
|
|
||||||
if (attrib_list)
|
if (attrib_list)
|
||||||
memcpy(data, attrib_list, 8 * i);
|
memcpy(data, attrib_list, 8 * i);
|
||||||
|
|
||||||
@@ -484,8 +488,9 @@ CreateDrawable(Display *dpy, struct glx_config *config,
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i)) {
|
if (!CreateDRIDrawable(dpy, config, drawable, xid, type, attrib_list, i)) {
|
||||||
if (glxCode == X_GLXCreatePixmap)
|
CARD8 glxCode;
|
||||||
|
if (type == GLX_PIXMAP_BIT)
|
||||||
glxCode = X_GLXDestroyPixmap;
|
glxCode = X_GLXDestroyPixmap;
|
||||||
else
|
else
|
||||||
glxCode = X_GLXDestroyWindow;
|
glxCode = X_GLXDestroyWindow;
|
||||||
@@ -602,7 +607,7 @@ CreatePbuffer(Display * dpy, struct glx_config *config,
|
|||||||
SyncHandle();
|
SyncHandle();
|
||||||
|
|
||||||
/* xserver created a pixmap with the same id as pbuffer */
|
/* xserver created a pixmap with the same id as pbuffer */
|
||||||
if (!CreateDRIDrawable(dpy, config, id, id, attrib_list, i)) {
|
if (!CreateDRIDrawable(dpy, config, id, id, GLX_PBUFFER_BIT, attrib_list, i)) {
|
||||||
CARD32 o = glx_1_3 ? X_GLXDestroyPbuffer : X_GLXvop_DestroyGLXPbufferSGIX;
|
CARD32 o = glx_1_3 ? X_GLXDestroyPbuffer : X_GLXvop_DestroyGLXPbufferSGIX;
|
||||||
protocolDestroyDrawable(dpy, id, o);
|
protocolDestroyDrawable(dpy, id, o);
|
||||||
id = None;
|
id = None;
|
||||||
@@ -916,7 +921,7 @@ glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap,
|
|||||||
return pixmap;
|
return pixmap;
|
||||||
#else
|
#else
|
||||||
return CreateDrawable(dpy, (struct glx_config *) config,
|
return CreateDrawable(dpy, (struct glx_config *) config,
|
||||||
(Drawable) pixmap, attrib_list, X_GLXCreatePixmap);
|
(Drawable) pixmap, GLX_PIXMAP_BIT, attrib_list);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -950,7 +955,7 @@ glXCreateWindow(Display * dpy, GLXFBConfig config, Window win,
|
|||||||
return win;
|
return win;
|
||||||
#else
|
#else
|
||||||
return CreateDrawable(dpy, (struct glx_config *) config,
|
return CreateDrawable(dpy, (struct glx_config *) config,
|
||||||
(Drawable) win, attrib_list, X_GLXCreateWindow);
|
(Drawable) win, GLX_WINDOW_BIT, attrib_list);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -117,6 +117,7 @@ struct __GLXDRIscreenRec {
|
|||||||
__GLXDRIdrawable *(*createDrawable)(struct glx_screen *psc,
|
__GLXDRIdrawable *(*createDrawable)(struct glx_screen *psc,
|
||||||
XID drawable,
|
XID drawable,
|
||||||
GLXDrawable glxDrawable,
|
GLXDrawable glxDrawable,
|
||||||
|
int type,
|
||||||
struct glx_config *config);
|
struct glx_config *config);
|
||||||
|
|
||||||
int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc,
|
int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc,
|
||||||
|
@@ -762,7 +762,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
|
|||||||
return xid;
|
return xid;
|
||||||
|
|
||||||
config = glx_config_find_visual(psc->visuals, vis->visualid);
|
config = glx_config_find_visual(psc->visuals, vis->visualid);
|
||||||
pdraw = psc->driScreen->createDrawable(psc, pixmap, xid, config);
|
pdraw = psc->driScreen->createDrawable(psc, pixmap, xid, GLX_PIXMAP_BIT, config);
|
||||||
if (pdraw == NULL) {
|
if (pdraw == NULL) {
|
||||||
fprintf(stderr, "failed to create pixmap\n");
|
fprintf(stderr, "failed to create pixmap\n");
|
||||||
xid = None;
|
xid = None;
|
||||||
|
Reference in New Issue
Block a user