appledri.c revision 3464ebd5
13464ebd5Sriastradh/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.12 2001/08/27 17:40:57 dawes Exp $ */
23464ebd5Sriastradh/**************************************************************************
33464ebd5Sriastradh
43464ebd5SriastradhCopyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
53464ebd5SriastradhCopyright 2000 VA Linux Systems, Inc.
63464ebd5SriastradhCopyright (c) 2002, 2008 Apple Computer, Inc.
73464ebd5SriastradhAll Rights Reserved.
83464ebd5Sriastradh
93464ebd5SriastradhPermission is hereby granted, free of charge, to any person obtaining a
103464ebd5Sriastradhcopy of this software and associated documentation files (the
113464ebd5Sriastradh"Software"), to deal in the Software without restriction, including
123464ebd5Sriastradhwithout limitation the rights to use, copy, modify, merge, publish,
133464ebd5Sriastradhdistribute, sub license, and/or sell copies of the Software, and to
143464ebd5Sriastradhpermit persons to whom the Software is furnished to do so, subject to
153464ebd5Sriastradhthe following conditions:
163464ebd5Sriastradh
173464ebd5SriastradhThe above copyright notice and this permission notice (including the
183464ebd5Sriastradhnext paragraph) shall be included in all copies or substantial portions
193464ebd5Sriastradhof the Software.
203464ebd5Sriastradh
213464ebd5SriastradhTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
223464ebd5SriastradhOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
233464ebd5SriastradhMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
243464ebd5SriastradhIN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
253464ebd5SriastradhANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
263464ebd5SriastradhTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
273464ebd5SriastradhSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
283464ebd5Sriastradh
293464ebd5Sriastradh**************************************************************************/
303464ebd5Sriastradh
313464ebd5Sriastradh/*
323464ebd5Sriastradh * Authors:
333464ebd5Sriastradh *   Kevin E. Martin <martin@valinux.com>
343464ebd5Sriastradh *   Jens Owen <jens@valinux.com>
353464ebd5Sriastradh *   Rickard E. (Rik) Faith <faith@valinux.com>
363464ebd5Sriastradh *
373464ebd5Sriastradh */
383464ebd5Sriastradh
393464ebd5Sriastradh/* THIS IS NOT AN X CONSORTIUM STANDARD */
403464ebd5Sriastradh
413464ebd5Sriastradh#include <X11/Xlibint.h>
423464ebd5Sriastradh#include "appledristr.h"
433464ebd5Sriastradh#include <X11/extensions/Xext.h>
443464ebd5Sriastradh#include <X11/extensions/extutil.h>
453464ebd5Sriastradh#include <stdio.h>
463464ebd5Sriastradh
473464ebd5Sriastradhstatic XExtensionInfo _appledri_info_data;
483464ebd5Sriastradhstatic XExtensionInfo *appledri_info = &_appledri_info_data;
493464ebd5Sriastradhstatic char *appledri_extension_name = APPLEDRINAME;
503464ebd5Sriastradh
513464ebd5Sriastradh#define AppleDRICheckExtension(dpy,i,val) \
523464ebd5Sriastradh  XextCheckExtension (dpy, i, appledri_extension_name, val)
533464ebd5Sriastradh
543464ebd5Sriastradh/*****************************************************************************
553464ebd5Sriastradh *                                                                           *
563464ebd5Sriastradh *			   private utility routines                          *
573464ebd5Sriastradh *                                                                           *
583464ebd5Sriastradh *****************************************************************************/
593464ebd5Sriastradh
603464ebd5Sriastradhstatic int close_display(Display * dpy, XExtCodes * extCodes);
613464ebd5Sriastradhstatic Bool wire_to_event(Display * dpy, XEvent * re, xEvent * event);
623464ebd5Sriastradh
633464ebd5Sriastradhstatic /* const */ XExtensionHooks appledri_extension_hooks = {
643464ebd5Sriastradh   NULL,                        /* create_gc */
653464ebd5Sriastradh   NULL,                        /* copy_gc */
663464ebd5Sriastradh   NULL,                        /* flush_gc */
673464ebd5Sriastradh   NULL,                        /* free_gc */
683464ebd5Sriastradh   NULL,                        /* create_font */
693464ebd5Sriastradh   NULL,                        /* free_font */
703464ebd5Sriastradh   close_display,               /* close_display */
713464ebd5Sriastradh   wire_to_event,               /* wire_to_event */
723464ebd5Sriastradh   NULL,                        /* event_to_wire */
733464ebd5Sriastradh   NULL,                        /* error */
743464ebd5Sriastradh   NULL,                        /* error_string */
753464ebd5Sriastradh};
763464ebd5Sriastradh
773464ebd5Sriastradhstatic
783464ebd5SriastradhXEXT_GENERATE_FIND_DISPLAY(find_display, appledri_info,
793464ebd5Sriastradh                           appledri_extension_name,
803464ebd5Sriastradh                           &appledri_extension_hooks,
813464ebd5Sriastradh                           AppleDRINumberEvents, NULL)
823464ebd5Sriastradh
833464ebd5Sriastradh     static XEXT_GENERATE_CLOSE_DISPLAY(close_display, appledri_info)
843464ebd5Sriastradh
853464ebd5Sriastradh     static void (*surface_notify_handler) ();
863464ebd5Sriastradh
873464ebd5Sriastradh     void *XAppleDRISetSurfaceNotifyHandler(void (*fun) ())
883464ebd5Sriastradh{
893464ebd5Sriastradh   void *old = surface_notify_handler;
903464ebd5Sriastradh   surface_notify_handler = fun;
913464ebd5Sriastradh   return old;
923464ebd5Sriastradh}
933464ebd5Sriastradh
943464ebd5Sriastradhstatic Bool
953464ebd5Sriastradhwire_to_event(Display *dpy, XEvent *re, xEvent *event)
963464ebd5Sriastradh{
973464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
983464ebd5Sriastradh   xAppleDRINotifyEvent *sevent;
993464ebd5Sriastradh
1003464ebd5Sriastradh   AppleDRICheckExtension(dpy, info, False);
1013464ebd5Sriastradh
1023464ebd5Sriastradh   switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
1033464ebd5Sriastradh   case AppleDRISurfaceNotify:
1043464ebd5Sriastradh      sevent = (xAppleDRINotifyEvent *) event;
1053464ebd5Sriastradh      if (surface_notify_handler != NULL) {
1063464ebd5Sriastradh         (*surface_notify_handler) (dpy, (unsigned int) sevent->arg,
1073464ebd5Sriastradh                                    (int) sevent->kind);
1083464ebd5Sriastradh      }
1093464ebd5Sriastradh      return False;
1103464ebd5Sriastradh   }
1113464ebd5Sriastradh   return False;
1123464ebd5Sriastradh}
1133464ebd5Sriastradh
1143464ebd5Sriastradh/*****************************************************************************
1153464ebd5Sriastradh *                                                                           *
1163464ebd5Sriastradh *		    public Apple-DRI Extension routines                      *
1173464ebd5Sriastradh *                                                                           *
1183464ebd5Sriastradh *****************************************************************************/
1193464ebd5Sriastradh
1203464ebd5Sriastradh#if 0
1213464ebd5Sriastradh#include <stdio.h>
1223464ebd5Sriastradh#define TRACE(msg)  fprintf(stderr, "AppleDRI%s\n", msg);
1233464ebd5Sriastradh#else
1243464ebd5Sriastradh#define TRACE(msg)
1253464ebd5Sriastradh#endif
1263464ebd5Sriastradh
1273464ebd5Sriastradh
1283464ebd5SriastradhBool
1293464ebd5SriastradhXAppleDRIQueryExtension(dpy, event_basep, error_basep)
1303464ebd5Sriastradh     Display *dpy;
1313464ebd5Sriastradh     int *event_basep, *error_basep;
1323464ebd5Sriastradh{
1333464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
1343464ebd5Sriastradh
1353464ebd5Sriastradh   TRACE("QueryExtension...");
1363464ebd5Sriastradh   if (XextHasExtension(info)) {
1373464ebd5Sriastradh      *event_basep = info->codes->first_event;
1383464ebd5Sriastradh      *error_basep = info->codes->first_error;
1393464ebd5Sriastradh      TRACE("QueryExtension... return True");
1403464ebd5Sriastradh      return True;
1413464ebd5Sriastradh   }
1423464ebd5Sriastradh   else {
1433464ebd5Sriastradh      TRACE("QueryExtension... return False");
1443464ebd5Sriastradh      return False;
1453464ebd5Sriastradh   }
1463464ebd5Sriastradh}
1473464ebd5Sriastradh
1483464ebd5SriastradhBool
1493464ebd5SriastradhXAppleDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
1503464ebd5Sriastradh     Display *dpy;
1513464ebd5Sriastradh     int *majorVersion;
1523464ebd5Sriastradh     int *minorVersion;
1533464ebd5Sriastradh     int *patchVersion;
1543464ebd5Sriastradh{
1553464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
1563464ebd5Sriastradh   xAppleDRIQueryVersionReply rep;
1573464ebd5Sriastradh   xAppleDRIQueryVersionReq *req;
1583464ebd5Sriastradh
1593464ebd5Sriastradh   TRACE("QueryVersion...");
1603464ebd5Sriastradh   AppleDRICheckExtension(dpy, info, False);
1613464ebd5Sriastradh
1623464ebd5Sriastradh   LockDisplay(dpy);
1633464ebd5Sriastradh   GetReq(AppleDRIQueryVersion, req);
1643464ebd5Sriastradh   req->reqType = info->codes->major_opcode;
1653464ebd5Sriastradh   req->driReqType = X_AppleDRIQueryVersion;
1663464ebd5Sriastradh   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
1673464ebd5Sriastradh      UnlockDisplay(dpy);
1683464ebd5Sriastradh      SyncHandle();
1693464ebd5Sriastradh      TRACE("QueryVersion... return False");
1703464ebd5Sriastradh      return False;
1713464ebd5Sriastradh   }
1723464ebd5Sriastradh   *majorVersion = rep.majorVersion;
1733464ebd5Sriastradh   *minorVersion = rep.minorVersion;
1743464ebd5Sriastradh   *patchVersion = rep.patchVersion;
1753464ebd5Sriastradh   UnlockDisplay(dpy);
1763464ebd5Sriastradh   SyncHandle();
1773464ebd5Sriastradh   TRACE("QueryVersion... return True");
1783464ebd5Sriastradh   return True;
1793464ebd5Sriastradh}
1803464ebd5Sriastradh
1813464ebd5SriastradhBool
1823464ebd5SriastradhXAppleDRIQueryDirectRenderingCapable(dpy, screen, isCapable)
1833464ebd5Sriastradh     Display *dpy;
1843464ebd5Sriastradh     int screen;
1853464ebd5Sriastradh     Bool *isCapable;
1863464ebd5Sriastradh{
1873464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
1883464ebd5Sriastradh   xAppleDRIQueryDirectRenderingCapableReply rep;
1893464ebd5Sriastradh   xAppleDRIQueryDirectRenderingCapableReq *req;
1903464ebd5Sriastradh
1913464ebd5Sriastradh   TRACE("QueryDirectRenderingCapable...");
1923464ebd5Sriastradh   AppleDRICheckExtension(dpy, info, False);
1933464ebd5Sriastradh
1943464ebd5Sriastradh   LockDisplay(dpy);
1953464ebd5Sriastradh   GetReq(AppleDRIQueryDirectRenderingCapable, req);
1963464ebd5Sriastradh   req->reqType = info->codes->major_opcode;
1973464ebd5Sriastradh   req->driReqType = X_AppleDRIQueryDirectRenderingCapable;
1983464ebd5Sriastradh   req->screen = screen;
1993464ebd5Sriastradh   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
2003464ebd5Sriastradh      UnlockDisplay(dpy);
2013464ebd5Sriastradh      SyncHandle();
2023464ebd5Sriastradh      TRACE("QueryDirectRenderingCapable... return False");
2033464ebd5Sriastradh      return False;
2043464ebd5Sriastradh   }
2053464ebd5Sriastradh   *isCapable = rep.isCapable;
2063464ebd5Sriastradh   UnlockDisplay(dpy);
2073464ebd5Sriastradh   SyncHandle();
2083464ebd5Sriastradh   TRACE("QueryDirectRenderingCapable... return True");
2093464ebd5Sriastradh   return True;
2103464ebd5Sriastradh}
2113464ebd5Sriastradh
2123464ebd5SriastradhBool
2133464ebd5SriastradhXAppleDRIAuthConnection(dpy, screen, magic)
2143464ebd5Sriastradh     Display *dpy;
2153464ebd5Sriastradh     int screen;
2163464ebd5Sriastradh     unsigned int magic;
2173464ebd5Sriastradh{
2183464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
2193464ebd5Sriastradh   xAppleDRIAuthConnectionReq *req;
2203464ebd5Sriastradh   xAppleDRIAuthConnectionReply rep;
2213464ebd5Sriastradh
2223464ebd5Sriastradh   TRACE("AuthConnection...");
2233464ebd5Sriastradh   AppleDRICheckExtension(dpy, info, False);
2243464ebd5Sriastradh
2253464ebd5Sriastradh   LockDisplay(dpy);
2263464ebd5Sriastradh   GetReq(AppleDRIAuthConnection, req);
2273464ebd5Sriastradh   req->reqType = info->codes->major_opcode;
2283464ebd5Sriastradh   req->driReqType = X_AppleDRIAuthConnection;
2293464ebd5Sriastradh   req->screen = screen;
2303464ebd5Sriastradh   req->magic = magic;
2313464ebd5Sriastradh   rep.authenticated = 0;
2323464ebd5Sriastradh   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) {
2333464ebd5Sriastradh      UnlockDisplay(dpy);
2343464ebd5Sriastradh      SyncHandle();
2353464ebd5Sriastradh      TRACE("AuthConnection... return False");
2363464ebd5Sriastradh      return False;
2373464ebd5Sriastradh   }
2383464ebd5Sriastradh   UnlockDisplay(dpy);
2393464ebd5Sriastradh   SyncHandle();
2403464ebd5Sriastradh   TRACE("AuthConnection... return True");
2413464ebd5Sriastradh   return True;
2423464ebd5Sriastradh}
2433464ebd5Sriastradh
2443464ebd5SriastradhBool
2453464ebd5SriastradhXAppleDRICreateSurface(dpy, screen, drawable, client_id, key, uid)
2463464ebd5Sriastradh     Display *dpy;
2473464ebd5Sriastradh     int screen;
2483464ebd5Sriastradh     Drawable drawable;
2493464ebd5Sriastradh     unsigned int client_id;
2503464ebd5Sriastradh     unsigned int *key;
2513464ebd5Sriastradh     unsigned int *uid;
2523464ebd5Sriastradh{
2533464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
2543464ebd5Sriastradh   xAppleDRICreateSurfaceReply rep;
2553464ebd5Sriastradh   xAppleDRICreateSurfaceReq *req;
2563464ebd5Sriastradh
2573464ebd5Sriastradh   TRACE("CreateSurface...");
2583464ebd5Sriastradh   AppleDRICheckExtension(dpy, info, False);
2593464ebd5Sriastradh
2603464ebd5Sriastradh   LockDisplay(dpy);
2613464ebd5Sriastradh   GetReq(AppleDRICreateSurface, req);
2623464ebd5Sriastradh   req->reqType = info->codes->major_opcode;
2633464ebd5Sriastradh   req->driReqType = X_AppleDRICreateSurface;
2643464ebd5Sriastradh   req->screen = screen;
2653464ebd5Sriastradh   req->drawable = drawable;
2663464ebd5Sriastradh   req->client_id = client_id;
2673464ebd5Sriastradh   rep.key_0 = rep.key_1 = rep.uid = 0;
2683464ebd5Sriastradh   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.key_0) {
2693464ebd5Sriastradh      UnlockDisplay(dpy);
2703464ebd5Sriastradh      SyncHandle();
2713464ebd5Sriastradh      TRACE("CreateSurface... return False");
2723464ebd5Sriastradh      return False;
2733464ebd5Sriastradh   }
2743464ebd5Sriastradh   key[0] = rep.key_0;
2753464ebd5Sriastradh   key[1] = rep.key_1;
2763464ebd5Sriastradh   *uid = rep.uid;
2773464ebd5Sriastradh   UnlockDisplay(dpy);
2783464ebd5Sriastradh   SyncHandle();
2793464ebd5Sriastradh   TRACE("CreateSurface... return True");
2803464ebd5Sriastradh   return True;
2813464ebd5Sriastradh}
2823464ebd5Sriastradh
2833464ebd5SriastradhBool
2843464ebd5SriastradhXAppleDRIDestroySurface(dpy, screen, drawable)
2853464ebd5Sriastradh     Display *dpy;
2863464ebd5Sriastradh     int screen;
2873464ebd5Sriastradh     Drawable drawable;
2883464ebd5Sriastradh{
2893464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
2903464ebd5Sriastradh   xAppleDRIDestroySurfaceReq *req;
2913464ebd5Sriastradh
2923464ebd5Sriastradh   TRACE("DestroySurface...");
2933464ebd5Sriastradh   AppleDRICheckExtension(dpy, info, False);
2943464ebd5Sriastradh
2953464ebd5Sriastradh   LockDisplay(dpy);
2963464ebd5Sriastradh   GetReq(AppleDRIDestroySurface, req);
2973464ebd5Sriastradh   req->reqType = info->codes->major_opcode;
2983464ebd5Sriastradh   req->driReqType = X_AppleDRIDestroySurface;
2993464ebd5Sriastradh   req->screen = screen;
3003464ebd5Sriastradh   req->drawable = drawable;
3013464ebd5Sriastradh   UnlockDisplay(dpy);
3023464ebd5Sriastradh   SyncHandle();
3033464ebd5Sriastradh   TRACE("DestroySurface... return True");
3043464ebd5Sriastradh   return True;
3053464ebd5Sriastradh}
3063464ebd5Sriastradh
3073464ebd5SriastradhBool
3083464ebd5SriastradhXAppleDRICreateSharedBuffer(Display * dpy, int screen, Drawable drawable,
3093464ebd5Sriastradh                            Bool doubleSwap, char *path, size_t pathlen,
3103464ebd5Sriastradh                            int *width, int *height)
3113464ebd5Sriastradh{
3123464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
3133464ebd5Sriastradh   xAppleDRICreateSharedBufferReq *req;
3143464ebd5Sriastradh   xAppleDRICreateSharedBufferReply rep;
3153464ebd5Sriastradh
3163464ebd5Sriastradh   AppleDRICheckExtension(dpy, info, False);
3173464ebd5Sriastradh
3183464ebd5Sriastradh   LockDisplay(dpy);
3193464ebd5Sriastradh   GetReq(AppleDRICreateSharedBuffer, req);
3203464ebd5Sriastradh   req->reqType = info->codes->major_opcode;
3213464ebd5Sriastradh   req->driReqType = X_AppleDRICreateSharedBuffer;
3223464ebd5Sriastradh   req->screen = screen;
3233464ebd5Sriastradh   req->drawable = drawable;
3243464ebd5Sriastradh   req->doubleSwap = doubleSwap;
3253464ebd5Sriastradh
3263464ebd5Sriastradh
3273464ebd5Sriastradh   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
3283464ebd5Sriastradh      puts("REPLY ERROR");
3293464ebd5Sriastradh
3303464ebd5Sriastradh      UnlockDisplay(dpy);
3313464ebd5Sriastradh      SyncHandle();
3323464ebd5Sriastradh      return False;
3333464ebd5Sriastradh   }
3343464ebd5Sriastradh
3353464ebd5Sriastradh   /* printf("rep.stringLength %d\n", (int) rep.stringLength); */
3363464ebd5Sriastradh
3373464ebd5Sriastradh   if (rep.stringLength > 0 && rep.stringLength <= pathlen) {
3383464ebd5Sriastradh      _XReadPad(dpy, path, rep.stringLength);
3393464ebd5Sriastradh
3403464ebd5Sriastradh      /* printf("path: %s\n", path); */
3413464ebd5Sriastradh
3423464ebd5Sriastradh      *width = rep.width;
3433464ebd5Sriastradh      *height = rep.height;
3443464ebd5Sriastradh
3453464ebd5Sriastradh      UnlockDisplay(dpy);
3463464ebd5Sriastradh      SyncHandle();
3473464ebd5Sriastradh      return True;
3483464ebd5Sriastradh   }
3493464ebd5Sriastradh
3503464ebd5Sriastradh   UnlockDisplay(dpy);
3513464ebd5Sriastradh   SyncHandle();
3523464ebd5Sriastradh
3533464ebd5Sriastradh   return False;
3543464ebd5Sriastradh}
3553464ebd5Sriastradh
3563464ebd5SriastradhBool
3573464ebd5SriastradhXAppleDRISwapBuffers(Display * dpy, int screen, Drawable drawable)
3583464ebd5Sriastradh{
3593464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
3603464ebd5Sriastradh   xAppleDRISwapBuffersReq *req;
3613464ebd5Sriastradh
3623464ebd5Sriastradh   AppleDRICheckExtension(dpy, info, False);
3633464ebd5Sriastradh
3643464ebd5Sriastradh   LockDisplay(dpy);
3653464ebd5Sriastradh   GetReq(AppleDRISwapBuffers, req);
3663464ebd5Sriastradh   req->reqType = info->codes->major_opcode;
3673464ebd5Sriastradh   req->driReqType = X_AppleDRISwapBuffers;
3683464ebd5Sriastradh   req->screen = screen;
3693464ebd5Sriastradh   req->drawable = drawable;
3703464ebd5Sriastradh   UnlockDisplay(dpy);
3713464ebd5Sriastradh   SyncHandle();
3723464ebd5Sriastradh
3733464ebd5Sriastradh   return True;
3743464ebd5Sriastradh}
3753464ebd5Sriastradh
3763464ebd5SriastradhBool
3773464ebd5SriastradhXAppleDRICreatePixmap(Display * dpy, int screen, Drawable drawable,
3783464ebd5Sriastradh                      int *width, int *height, int *pitch, int *bpp,
3793464ebd5Sriastradh                      size_t * size, char *bufname, size_t bufnamesize)
3803464ebd5Sriastradh{
3813464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
3823464ebd5Sriastradh   xAppleDRICreatePixmapReq *req;
3833464ebd5Sriastradh   xAppleDRICreatePixmapReply rep;
3843464ebd5Sriastradh
3853464ebd5Sriastradh   AppleDRICheckExtension(dpy, info, False);
3863464ebd5Sriastradh
3873464ebd5Sriastradh   LockDisplay(dpy);
3883464ebd5Sriastradh   GetReq(AppleDRICreatePixmap, req);
3893464ebd5Sriastradh   req->reqType = info->codes->major_opcode;
3903464ebd5Sriastradh   req->driReqType = X_AppleDRICreatePixmap;
3913464ebd5Sriastradh   req->screen = screen;
3923464ebd5Sriastradh   req->drawable = drawable;
3933464ebd5Sriastradh
3943464ebd5Sriastradh   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
3953464ebd5Sriastradh      UnlockDisplay(dpy);
3963464ebd5Sriastradh      SyncHandle();
3973464ebd5Sriastradh      return False;
3983464ebd5Sriastradh   }
3993464ebd5Sriastradh
4003464ebd5Sriastradh   /*
4013464ebd5Sriastradh      printf("rep.stringLength %d\n", (int) rep.stringLength);
4023464ebd5Sriastradh    */
4033464ebd5Sriastradh
4043464ebd5Sriastradh   if (rep.stringLength > 0 && rep.stringLength <= bufnamesize) {
4053464ebd5Sriastradh      _XReadPad(dpy, bufname, rep.stringLength);
4063464ebd5Sriastradh
4073464ebd5Sriastradh      /* printf("path: %s\n", bufname); */
4083464ebd5Sriastradh
4093464ebd5Sriastradh      *width = rep.width;
4103464ebd5Sriastradh      *height = rep.height;
4113464ebd5Sriastradh      *pitch = rep.pitch;
4123464ebd5Sriastradh      *bpp = rep.bpp;
4133464ebd5Sriastradh      *size = rep.size;
4143464ebd5Sriastradh
4153464ebd5Sriastradh      UnlockDisplay(dpy);
4163464ebd5Sriastradh      SyncHandle();
4173464ebd5Sriastradh      return True;
4183464ebd5Sriastradh   }
4193464ebd5Sriastradh   else if (rep.stringLength > 0) {
4203464ebd5Sriastradh      _XEatData(dpy, rep.stringLength);
4213464ebd5Sriastradh   }
4223464ebd5Sriastradh
4233464ebd5Sriastradh   UnlockDisplay(dpy);
4243464ebd5Sriastradh   SyncHandle();
4253464ebd5Sriastradh
4263464ebd5Sriastradh   return True;
4273464ebd5Sriastradh}
4283464ebd5Sriastradh
4293464ebd5Sriastradh/*
4303464ebd5Sriastradh * Call it a drawable, because we really don't know what it is
4313464ebd5Sriastradh * until it reaches the server, and we should keep that in mind.
4323464ebd5Sriastradh */
4333464ebd5SriastradhBool
4343464ebd5SriastradhXAppleDRIDestroyPixmap(Display * dpy, Pixmap drawable)
4353464ebd5Sriastradh{
4363464ebd5Sriastradh   XExtDisplayInfo *info = find_display(dpy);
4373464ebd5Sriastradh   xAppleDRIDestroyPixmapReq *req;
4383464ebd5Sriastradh
4393464ebd5Sriastradh   AppleDRICheckExtension(dpy, info, False);
4403464ebd5Sriastradh
4413464ebd5Sriastradh   LockDisplay(dpy);
4423464ebd5Sriastradh   GetReq(AppleDRIDestroyPixmap, req);
4433464ebd5Sriastradh   req->reqType = info->codes->major_opcode;
4443464ebd5Sriastradh   req->driReqType = X_AppleDRIDestroyPixmap;
4453464ebd5Sriastradh   req->drawable = drawable;
4463464ebd5Sriastradh   UnlockDisplay(dpy);
4473464ebd5Sriastradh   SyncHandle();
4483464ebd5Sriastradh
4493464ebd5Sriastradh   return True;
4503464ebd5Sriastradh}
451