Ejemplo n.º 1
0
Bool SDL_NAME(XF86DGASetViewPort)(
    Display* dpy,
    int screen,
    int x, 
    int y
){
    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
    xXF86DGASetViewPortReq *req;

    XF86DGACheckExtension (dpy, info, False);

    LockDisplay(dpy);
    GetReq(XF86DGASetViewPort, req);
    req->reqType = info->codes->major_opcode;
    req->dgaReqType = X_XF86DGASetViewPort;
    req->screen = screen;
    req->x = x;
    req->y = y;
    UnlockDisplay(dpy);
    SyncHandle();
    XSync(dpy,False);
    return True;
}
Ejemplo n.º 2
0
GLboolean
glAreTexturesResidentEXT(GLsizei n, const GLuint * textures,
                         GLboolean * residences)
{
    struct glx_context *const gc = __glXGetCurrentContext();

    if (gc->isDirect) {
        return GET_DISPATCH()->AreTexturesResident(n, textures, residences);
    }
    else {
        struct glx_context *const gc = __glXGetCurrentContext();
        Display *const dpy = gc->currentDpy;
        GLboolean retval = (GLboolean) 0;
        const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
        if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
            GLubyte const *pc =
                __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
                                        X_GLvop_AreTexturesResidentEXT,
                                        cmdlen);
            (void) memcpy((void *) (pc + 0), (void *) (&n), 4);
            (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4));
            if (n & 3) {
                /* see comments in __indirect_glAreTexturesResident() */
                GLboolean *res4 = malloc((n + 3) & ~3);
                retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE);
                memcpy(residences, res4, n);
                free(res4);
            }
            else {
                retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE);
            }
            UnlockDisplay(dpy);
            SyncHandle();
        }
        return retval;
    }
}
Ejemplo n.º 3
0
int
XDrawArcs(
    register Display *dpy,
    Drawable d,
    GC gc,
    XArc *arcs,
    int n_arcs)
{
    register xPolyArcReq *req;
    register long len;

    LockDisplay(dpy);
    FlushGC(dpy, gc);
    GetReq(PolyArc,req);
    req->drawable = d;
    req->gc = gc->gid;
    len = ((long)n_arcs) * arc_scale;
    SetReqLen(req, len, 1);
    len <<= 2; /* watch out for macros... */
    Data16 (dpy, (short *) arcs, len);
    UnlockDisplay(dpy);
    SyncHandle();
    return 1;
}
Ejemplo n.º 4
0
void
DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region,
               CARD32 dest, CARD32 src)
{
   XExtDisplayInfo *info = DRI2FindDisplay(dpy);
   xDRI2CopyRegionReq *req;
   xDRI2CopyRegionReply rep;

   XextSimpleCheckExtension(dpy, info, dri2ExtensionName);

   LockDisplay(dpy);
   GetReq(DRI2CopyRegion, req);
   req->reqType = info->codes->major_opcode;
   req->dri2ReqType = X_DRI2CopyRegion;
   req->drawable = drawable;
   req->region = region;
   req->dest = dest;
   req->src = src;

   _XReply(dpy, (xReply *) & rep, 0, xFalse);

   UnlockDisplay(dpy);
   SyncHandle();
}
Ejemplo n.º 5
0
int
XGetScreenSaver(
     register Display *dpy,
     /* the following are return only vars */
     int *timeout,
     int *interval,
     int *prefer_blanking,
     int *allow_exp)  /*boolean */

{
    xGetScreenSaverReply rep;
    register xReq *req;
    LockDisplay(dpy);
    GetEmptyReq(GetScreenSaver, req);

    (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
    *timeout = rep.timeout;
    *interval = rep.interval;
    *prefer_blanking = rep.preferBlanking;
    *allow_exp = rep.allowExposures;
    UnlockDisplay(dpy);
    SyncHandle();
    return 1;
}
Ejemplo n.º 6
0
void XNVCTRLSetAttribute (
    Display *dpy,
    int screen,
    unsigned int display_mask,
    unsigned int attribute,
    int value
)
{
    XExtDisplayInfo *info = find_display (dpy);
    xnvCtrlSetAttributeReq *req;

    XNVCTRLSimpleCheckExtension (dpy, info);

    LockDisplay (dpy);
    GetReq (nvCtrlSetAttribute, req);
    req->reqType = info->codes->major_opcode;
    req->nvReqType = X_nvCtrlSetAttribute;
    req->screen = screen;
    req->display_mask = display_mask;
    req->attribute = attribute;
    req->value = value;
    UnlockDisplay (dpy);
    SyncHandle ();
}
Ejemplo n.º 7
0
int
XRemoveHost (
    register Display *dpy,
    XHostAddress *host)
{
    register xChangeHostsReq *req;
    register int length;
    XServerInterpretedAddress *siAddr;
    int addrlen;

    if (host->family == FamilyServerInterpreted) {
	siAddr = (XServerInterpretedAddress *) host->address;
	addrlen = siAddr->typelength + siAddr->valuelength + 1;
    } else {
	addrlen = host->length;
    }
    
    length = (addrlen + 3) & ~0x3;	/* round up */

    LockDisplay(dpy);
    GetReqExtra (ChangeHosts, length, req);
    req->mode = HostDelete;
    req->hostFamily = host->family;
    req->hostLength = addrlen;
    if (host->family == FamilyServerInterpreted) {
	char *dest = (char *) NEXTPTR(req,xChangeHostsReq);
	memcpy(dest, siAddr->type, siAddr->typelength);
	dest[siAddr->typelength] = '\0';
	memcpy(dest + siAddr->typelength + 1,siAddr->value,siAddr->valuelength);
    } else {
	memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, addrlen);
    }
    UnlockDisplay(dpy);
    SyncHandle();
    return 1;
}
Ejemplo n.º 8
0
Status
XkbGetIndicatorState(Display *dpy,unsigned deviceSpec,unsigned *pStateRtrn)
{
    register xkbGetIndicatorStateReq *req;
    xkbGetIndicatorStateReply	rep;
    XkbInfoPtr xkbi;
    Bool ok;

    if ((dpy->flags & XlibDisplayNoXkb) ||
	(!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
	return BadAccess;
    LockDisplay(dpy);
    xkbi = dpy->xkb_info;
    GetReq(kbGetIndicatorState, req);
    req->reqType = xkbi->codes->major_opcode;
    req->xkbReqType = X_kbGetIndicatorState;
    req->deviceSpec = deviceSpec;
    ok=_XReply(dpy, (xReply *)&rep, 0, xFalse);
    if (ok && (pStateRtrn!=NULL))
	*pStateRtrn= rep.state;
    UnlockDisplay(dpy);
    SyncHandle();
    return (ok?Success:BadImplementation);
}
Ejemplo n.º 9
0
Status
DPMSForceLevel(Display *dpy, CARD16 level)
{
    XExtDisplayInfo *info = find_display (dpy);
    register xDPMSForceLevelReq *req;

    DPMSCheckExtension (dpy, info, 0);

    if ((level != DPMSModeOn) &&
	(level != DPMSModeStandby) &&
	(level != DPMSModeSuspend) &&
	(level != DPMSModeOff))
	return BadValue;

    LockDisplay(dpy);
    GetReq(DPMSForceLevel, req);
    req->reqType = info->codes->major_opcode;
    req->dpmsReqType = X_DPMSForceLevel;
    req->level = level;

    UnlockDisplay(dpy);
    SyncHandle();
    return 1;
}
Ejemplo n.º 10
0
Archivo: XpInput.c Proyecto: aosm/X11
void
XpSelectInput (
    Display       *dpy,
    XPContext     print_context,
    unsigned long event_mask
)
{
    xPrintSelectInputReq   *req;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
	return; /* NoSuchExtension NULL */

    LockDisplay (dpy);

    GetReq(PrintSelectInput,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintSelectInput;
    req->printContext = print_context;
    req->eventMask = event_mask;

    UnlockDisplay (dpy);
    SyncHandle ();
}
Ejemplo n.º 11
0
void
XRenderSetPictureFilter  (Display   *dpy,
			  Picture   picture,
			  const char *filter,
			  XFixed    *params,
			  int	    nparams)
{
    XRenderExtDisplayInfo		*info = XRenderFindDisplay (dpy);
    xRenderSetPictureFilterReq	*req;
    int				nbytes = strlen (filter);

    RenderSimpleCheckExtension (dpy, info);
    LockDisplay(dpy);
    GetReq(RenderSetPictureFilter, req);
    req->reqType = info->codes->major_opcode;
    req->renderReqType = X_RenderSetPictureFilter;
    req->picture = picture;
    req->nbytes = nbytes;
    req->length += ((nbytes + 3) >> 2) + nparams;
    Data (dpy, filter, nbytes);
    Data (dpy, (_Xconst char *)params, nparams << 2);
    UnlockDisplay(dpy);
    SyncHandle();
}
Ejemplo n.º 12
0
/**
 * Get a drawable's attribute.
 *
 * This function is used to implement \c glXGetSelectedEvent and
 * \c glXGetSelectedEventSGIX.
 *
 * \note
 * This function dynamically determines whether to use the SGIX_pbuffer
 * version of the protocol or the GLX 1.3 version of the protocol.
 *
 * \todo
 * The number of attributes returned is likely to be small, probably less than
 * 10.  Given that, this routine should try to use an array on the stack to
 * capture the reply rather than always calling Xmalloc.
 *
 * \todo
 * This function needs to be modified to work with direct-rendering drivers.
 */
static int
GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
                     int attribute, unsigned int *value)
{
   __GLXdisplayPrivate *priv;
   xGLXGetDrawableAttributesReply reply;
   CARD32 *data;
   CARD8 opcode;
   unsigned int length;
   unsigned int i;
   unsigned int num_attributes;
   GLboolean use_glx_1_3;

   if ((dpy == NULL) || (drawable == 0)) {
      return 0;
   }

   priv = __glXInitialize(dpy);
   use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3));

   *value = 0;


   opcode = __glXSetupForCommand(dpy);
   if (!opcode)
      return 0;

   LockDisplay(dpy);

   if (use_glx_1_3) {
      xGLXGetDrawableAttributesReq *req;

      GetReqExtra(GLXGetDrawableAttributes, 4, req);
      req->reqType = opcode;
      req->glxCode = X_GLXGetDrawableAttributes;
      req->drawable = drawable;
   }
   else {
      xGLXVendorPrivateWithReplyReq *vpreq;

      GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq);
      data = (CARD32 *) (vpreq + 1);
      data[0] = (CARD32) drawable;

      vpreq->reqType = opcode;
      vpreq->glxCode = X_GLXVendorPrivateWithReply;
      vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX;
   }

   _XReply(dpy, (xReply *) & reply, 0, False);

   if (reply.type == X_Error) {
      UnlockDisplay(dpy);
      SyncHandle();
      return 0;
   }

   length = reply.length;
   if (length) {
      num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
      data = (CARD32 *) Xmalloc(length * sizeof(CARD32));
      if (data == NULL) {
         /* Throw data on the floor */
         _XEatData(dpy, length);
      }
      else {
         _XRead(dpy, (char *) data, length * sizeof(CARD32));

         /* Search the set of returned attributes for the attribute requested by
          * the caller.
          */
         for (i = 0; i < num_attributes; i++) {
            if (data[i * 2] == attribute) {
               *value = data[(i * 2) + 1];
               break;
            }
         }

#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
         {
            __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);

            if (pdraw != NULL && !pdraw->textureTarget)
               pdraw->textureTarget =
                  determineTextureTarget((const int *) data, num_attributes);
            if (pdraw != NULL && !pdraw->textureFormat)
               pdraw->textureFormat =
                  determineTextureFormat((const int *) data, num_attributes);
         }
#endif

         Xfree(data);
      }
   }

   UnlockDisplay(dpy);
   SyncHandle();

   return 0;
}
Ejemplo n.º 13
0
char *
XpGetOneAttribute (
    Display       *dpy,
    XPContext     print_context,
    XPAttributes  type,
    char          *attribute_name
)
{
    int     buflen = 0;
    char    *buf;

    xPrintGetOneAttributeReq     *req;
    xPrintGetOneAttributeReply   rep;
    XExtensionVersion          *ext;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);


    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return( (char *) NULL ); /* No such extension */

    LockDisplay (dpy);

    GetReq(PrintGetOneAttribute,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintGetOneAttribute;
    req->type = type;
    req->printContext = print_context;
    req->nameLen = strlen( attribute_name );

    /*
     * Attach variable data and adjust request length.
     */
    req->length += _XpPadOut(req->nameLen) >> 2 ;
    Data( dpy, (char *) attribute_name, req->nameLen );    /* n bytes + pad */

    if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
        UnlockDisplay(dpy);
        SyncHandle();
        return( (char *) NULL ); /* No such extension */
    }

    /*
     * Read variable answer.
     */
    buf = Xmalloc( (unsigned) rep.valueLen + 1 );

    if (!buf) {
        UnlockDisplay(dpy);
        SyncHandle();
        return( (char *) NULL ); /* malloc error */
    }

    buf[rep.valueLen] = 0;

    _XReadPad (dpy, (char *) buf, (long) rep.valueLen );
    buf[rep.valueLen] = 0;

    UnlockDisplay(dpy);
    SyncHandle();

    return( buf );
}
Ejemplo n.º 14
0
void
XChangeDeviceProperty(Display* dpy, XDevice* dev,
                      Atom property, Atom type,
                      int format, int mode,
                      _Xconst unsigned char *data, int nelements)
{
    xChangeDevicePropertyReq   *req;
    int                         len;

    XExtDisplayInfo *info = XInput_find_display(dpy);

    LockDisplay(dpy);
    if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1)
	return;

    GetReq(ChangeDeviceProperty, req);
    req->reqType    = info->codes->major_opcode;
    req->ReqType    = X_ChangeDeviceProperty;
    req->deviceid   = dev->device_id;
    req->property   = property;
    req->type       = type;
    req->mode       = mode;
    if (nelements < 0) {
	req->nUnits = 0;
	req->format = 0; /* ask for garbage, get garbage */
    } else {
	req->nUnits = nelements;
	req->format = format;
    }

    switch (req->format) {
    case 8:
	len = ((long)nelements + 3) >> 2;
	if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
	    SetReqLen(req, len, len);
	    Data (dpy, (_Xconst char *)data, nelements);
	} /* else force BadLength */
	break;

    case 16:
	len = ((long)nelements + 1) >> 1;
	if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
	    SetReqLen(req, len, len);
	    len = (long)nelements << 1;
	    Data16 (dpy, (_Xconst short *) data, len);
	} /* else force BadLength */
	break;

    case 32:
	len = nelements;
	if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
	    SetReqLen(req, len, len);
	    len = (long)nelements << 2;
	    Data32 (dpy, (_Xconst long *) data, len);
	} /* else force BadLength */
	break;

    default:
	/* BadValue will be generated */ ;
    }

    UnlockDisplay(dpy);
    SyncHandle();
}
Ejemplo n.º 15
0
Archivo: Xdbe.c Proyecto: aosm/X11
/*
 * XdbeGetVisualInfo -
 *	This function returns information about which visuals support
 *	double buffering.  The argument num_screens specifies how many
 *	elements there are in the screen_specifiers list.  Each drawable
 *	in screen_specifiers designates a screen for which the supported
 *	visuals are being requested.  If num_screens is zero, information
 *	for all screens is requested.  In this case, upon return from this
 *	function, num_screens will be set to the number of screens that were
 *	found.  If an error occurs, this function returns NULL, else it returns
 *	a pointer to a list of XdbeScreenVisualInfo structures of length
 *	num_screens.  The nth element in the returned list corresponds to the
 *	nth drawable in the screen_specifiers list, unless num_screens was
 *	passed in with the value zero, in which case the nth element in the
 *	returned list corresponds to the nth screen of the server, starting
 *	with screen zero.
 */
XdbeScreenVisualInfo *XdbeGetVisualInfo (
    Display        *dpy,
    Drawable       *screen_specifiers,
    int            *num_screens)  /* SEND and RETURN */
{
    XExtDisplayInfo *info = find_display(dpy);
    register xDbeGetVisualInfoReq *req;
    xDbeGetVisualInfoReply rep;
    XdbeScreenVisualInfo *scrVisInfo;
    int i;

    DbeCheckExtension (dpy, info, (XdbeScreenVisualInfo *)NULL);

    LockDisplay (dpy);

    DbeGetReq(DbeGetVisualInfo, req, info);
    req->length = 2 + *num_screens;
    req->n      = *num_screens;
    Data32 (dpy, screen_specifiers, (*num_screens * sizeof (CARD32)));

    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return NULL;
    }

    /* return the number of screens actually found if we
     * requested information about all screens (*num_screens == 0)
     */
    if (*num_screens == 0)
       *num_screens = rep.m;

    /* allocate list of visual information to be returned */
    if (!(scrVisInfo =
        (XdbeScreenVisualInfo *)Xmalloc(
        (unsigned)(*num_screens * sizeof(XdbeScreenVisualInfo))))) {
        UnlockDisplay (dpy);
        SyncHandle ();
        return NULL;
    }

    for (i = 0; i < *num_screens; i++)
    {
        int nbytes;
        int j;
        long c;

        _XRead32 (dpy, &c, sizeof(CARD32));
        scrVisInfo[i].count = c;

        nbytes = scrVisInfo[i].count * sizeof(XdbeVisualInfo);

        /* if we can not allocate the list of visual/depth info
         * then free the lists that we already allocate as well
         * as the visual info list itself
         */
        if (!(scrVisInfo[i].visinfo = (XdbeVisualInfo *)Xmalloc(
            (unsigned)nbytes))) {
            for (j = 0; j < i; j++) {
                Xfree ((char *)scrVisInfo[j].visinfo);
            }
            Xfree ((char *)scrVisInfo);
            UnlockDisplay (dpy);
            SyncHandle ();
            return NULL;
        }
    
        /* Read the visual info item into the wire structure.  Then copy each
         * element into the library structure.  The element sizes and/or
         * padding may be different in the two structures.
         */
        for (j = 0; j < scrVisInfo[i].count; j++) {
            xDbeVisInfo xvi;

            _XRead (dpy, (char *)&xvi, sizeof(xDbeVisInfo));
            scrVisInfo[i].visinfo[j].visual    = xvi.visualID;
            scrVisInfo[i].visinfo[j].depth     = xvi.depth;
            scrVisInfo[i].visinfo[j].perflevel = xvi.perfLevel;
        }

    }

    UnlockDisplay (dpy);
    SyncHandle ();
    return scrVisInfo;

} /* XdbeGetVisualInfo() */
Ejemplo n.º 16
0
Archivo: surface.c Proyecto: metux/mesa
PUBLIC
Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surface)
{
   XvMCContextPrivate *context_priv;
   struct pipe_context *pipe;
   XvMCSurfacePrivate *surface_priv;
   struct pipe_video_buffer tmpl;

   XVMC_MSG(XVMC_TRACE, "[XvMC] Creating surface %p.\n", surface);

   assert(dpy);

   if (!context)
      return XvMCBadContext;
   if (!surface)
      return XvMCBadSurface;

   context_priv = context->privData;
   pipe = context_priv->pipe;

   surface_priv = CALLOC(1, sizeof(XvMCSurfacePrivate));
   if (!surface_priv)
      return BadAlloc;

   memset(&tmpl, 0, sizeof(tmpl));
   tmpl.buffer_format = pipe->screen->get_video_param
   (
      pipe->screen,
      context_priv->decoder->profile,
      context_priv->decoder->entrypoint,
      PIPE_VIDEO_CAP_PREFERED_FORMAT
   );
   tmpl.chroma_format = context_priv->decoder->chroma_format;
   tmpl.width = context_priv->decoder->width;
   tmpl.height = context_priv->decoder->height;
   tmpl.interlaced = pipe->screen->get_video_param
   (
      pipe->screen,
      context_priv->decoder->profile,
      context_priv->decoder->entrypoint,
      PIPE_VIDEO_CAP_PREFERS_INTERLACED
   );

   surface_priv->video_buffer = pipe->create_video_buffer(pipe, &tmpl);
   if (!surface_priv->video_buffer) {
      FREE(surface_priv);
      return BadAlloc;
   }
   surface_priv->context = context;

   surface->surface_id = XAllocID(dpy);
   surface->context_id = context->context_id;
   surface->surface_type_id = context->surface_type_id;
   surface->width = context->width;
   surface->height = context->height;
   surface->privData = surface_priv;

   SyncHandle();

   XVMC_MSG(XVMC_TRACE, "[XvMC] Surface %p created.\n", surface);

   return Success;
}
Ejemplo n.º 17
0
Status XeviGetVisualInfo(
    register Display *dpy,
    VisualID *visual,
    int n_visual,
    ExtendedVisualInfo **evi_return,
    int *n_info_return)
{
    XExtDisplayInfo *info = find_display (dpy);
    register xEVIGetVisualInfoReq *req;
    xEVIGetVisualInfoReply rep;
    int sz_info, sz_xInfo, sz_conflict, sz_xConflict;
    VisualID32 *temp_conflict, *temp_visual, *xConflictPtr;
    VisualID *conflict;
    xExtendedVisualInfo *temp_xInfo;
    XVisualInfo *vinfo;
    register ExtendedVisualInfo *infoPtr;
    register xExtendedVisualInfo *xInfoPtr;
    register int n_data, visualIndex, vinfoIndex;
    Bool isValid;
    XeviCheckExtension (dpy, info, 0);
    if (!n_info_return || !evi_return) {
	return BadValue;
    }
    *n_info_return = 0;
    *evi_return = NULL;
    vinfo = XGetVisualInfo(dpy, 0, NULL, &sz_info);
    if (!vinfo) {
	return BadValue;
    }
    if (!n_visual || !visual) {		/* copy the all visual */
    	temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * sz_info);
    	n_visual = 0;
        for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++)
	    if (notInList(temp_visual, n_visual, vinfo[vinfoIndex].visualid))
	        temp_visual[n_visual++] = vinfo[vinfoIndex].visualid;
    }
    else {	/* check if the visual is valid */
        for (visualIndex = 0; visualIndex < n_visual; visualIndex++) {
	    isValid = False;
            for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++) {
	        if (visual[visualIndex] == vinfo[vinfoIndex].visualid) {
		    isValid = True;
		    break;
	        }
	    }
	    if (!isValid) {
		XFree(vinfo);
	        return BadValue;
	    }
	}
	temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * n_visual);
        for (visualIndex = 0; visualIndex < n_visual; visualIndex++)
	    temp_visual[visualIndex] = visual[visualIndex];
    }
    XFree(vinfo);
    LockDisplay(dpy);
    GetReq(EVIGetVisualInfo, req);
    req->reqType = info->codes->major_opcode;
    req->xeviReqType = X_EVIGetVisualInfo;
    req->n_visual = n_visual;
    SetReqLen(req, n_visual, 1);
    Data(dpy, (char *)temp_visual, n_visual * sz_VisualID32);
    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
	UnlockDisplay(dpy);
	SyncHandle();
	Xfree(temp_visual);
	return BadAccess;
    }
    Xfree(temp_visual);
    if ((rep.n_info < 65536) && (rep.n_conflicts < 65536)) {
	sz_info = rep.n_info * sizeof(ExtendedVisualInfo);
	sz_xInfo = rep.n_info * sz_xExtendedVisualInfo;
	sz_conflict = rep.n_conflicts * sizeof(VisualID);
	sz_xConflict = rep.n_conflicts * sz_VisualID32;
	*evi_return = Xmalloc(sz_info + sz_conflict);
	temp_xInfo = Xmalloc(sz_xInfo);
	temp_conflict = Xmalloc(sz_xConflict);
    } else {
	sz_xInfo = sz_xConflict = 0;
	*evi_return = NULL;
	temp_xInfo = NULL;
	temp_conflict = NULL;
    }
    if (!*evi_return || !temp_xInfo || !temp_conflict) {
	_XEatDataWords(dpy, rep.length);
	UnlockDisplay(dpy);
	SyncHandle();
	if (*evi_return) {
	   Xfree(*evi_return);
	   *evi_return = NULL;
	}
	if (temp_xInfo)
	   Xfree(temp_xInfo);
	if (temp_conflict)
	   Xfree(temp_conflict);
	return BadAlloc;
    }
    _XRead(dpy, (char *)temp_xInfo, sz_xInfo);
    _XRead(dpy, (char *)temp_conflict, sz_xConflict);
    UnlockDisplay(dpy);
    SyncHandle();
    infoPtr = *evi_return;
    xInfoPtr = temp_xInfo;
    xConflictPtr = temp_conflict;
    n_data = rep.n_info;
    conflict = (VisualID *)(infoPtr + n_data);
    while (n_data-- > 0) {
	infoPtr->core_visual_id		= xInfoPtr->core_visual_id;
	infoPtr->screen			= xInfoPtr->screen;
	infoPtr->level			= xInfoPtr->level;
	infoPtr->transparency_type	= xInfoPtr->transparency_type;
	infoPtr->transparency_value	= xInfoPtr->transparency_value;
	infoPtr->min_hw_colormaps	= xInfoPtr->min_hw_colormaps;
	infoPtr->max_hw_colormaps	= xInfoPtr->max_hw_colormaps;
	infoPtr->num_colormap_conflicts = xInfoPtr->num_colormap_conflicts;
	infoPtr->colormap_conflicts	= conflict;
	conflict += infoPtr->num_colormap_conflicts;
	infoPtr++;
	xInfoPtr++;
    }
    n_data = rep.n_conflicts;
    conflict = (VisualID *)(infoPtr);
    while (n_data-- > 0)
       *conflict++ = *xConflictPtr++;
    Xfree(temp_xInfo);
    Xfree(temp_conflict);
    *n_info_return = rep.n_info;
    return Success;
}
Ejemplo n.º 18
0
void glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
			  GLvoid *row, GLvoid *column, GLvoid *span)
{
    __GLX_SINGLE_DECLARE_VARIABLES();
    xGLXGetSeparableFilterReply reply;
    GLubyte *rowBuf, *colBuf;

    if (!dpy) return;
    __GLX_SINGLE_LOAD_VARIABLES();

    /* Send request */
    __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13));
    __GLX_SINGLE_PUT_LONG(0,target);
    __GLX_SINGLE_PUT_LONG(4,format);
    __GLX_SINGLE_PUT_LONG(8,type);
    __GLX_SINGLE_PUT_CHAR(12,gc->state.storePack.swapEndian);
    __GLX_SINGLE_READ_XREPLY();
    compsize = reply.length << 2;

    if (compsize != 0) {
	GLint width, height;
	GLint widthsize, heightsize;

	width = reply.width;
	height = reply.height;

	widthsize = __glImageSize(width,1,1,format, type);
	heightsize = __glImageSize(height,1,1,format, type);

	/* Allocate a holding buffer to transform the data from */
	rowBuf = (GLubyte*) Xmalloc(widthsize);
	if (!rowBuf) {
	    /* Throw data away */
	    _XEatData(dpy, compsize);
	    __glXSetError(gc, GL_OUT_OF_MEMORY);
	    UnlockDisplay(dpy);
	    SyncHandle();
	    return;
	} else {
	    __GLX_SINGLE_GET_CHAR_ARRAY(((char*)rowBuf),widthsize);
	    __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row);
	    Xfree((char*) rowBuf);
	}
	colBuf = (GLubyte*) Xmalloc(heightsize);
	if (!colBuf) {
	    /* Throw data away */
	    _XEatData(dpy, compsize - __GLX_PAD(widthsize));
	    __glXSetError(gc, GL_OUT_OF_MEMORY);
	    UnlockDisplay(dpy);
	    SyncHandle();
	    return;
	} else {
	    __GLX_SINGLE_GET_CHAR_ARRAY(((char*)colBuf),heightsize);
	    __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column);
	    Xfree((char*) colBuf);
	}
    } else {
	/*
	** don't modify user's buffer.
	*/
    }
    __GLX_SINGLE_END();
    
}
Ejemplo n.º 19
0
/**
 * Get a drawable's attribute.
 *
 * This function is used to implement \c glXGetSelectedEvent and
 * \c glXGetSelectedEventSGIX.
 *
 * \note
 * This function dynamically determines whether to use the SGIX_pbuffer
 * version of the protocol or the GLX 1.3 version of the protocol.
 *
 * \todo
 * The number of attributes returned is likely to be small, probably less than
 * 10.  Given that, this routine should try to use an array on the stack to
 * capture the reply rather than always calling Xmalloc.
 *
 * \todo
 * This function needs to be modified to work with direct-rendering drivers.
 */
static int
GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
		      int attribute, unsigned int *value )
{
   __GLXdisplayPrivate *priv = __glXInitialize(dpy);
   xGLXGetDrawableAttributesReply reply;
   CARD32 * data;
   unsigned int length;
   unsigned int i;
   unsigned int num_attributes;
   GLboolean use_glx_1_3 = ((priv->majorVersion > 1)
			    || (priv->minorVersion >= 3));


   if ( (dpy == NULL) || (drawable == 0) ) {
      return 0;
   }

   
   LockDisplay(dpy);

   if ( use_glx_1_3 ) {
      xGLXGetDrawableAttributesReq *req;

      GetReqExtra( GLXGetDrawableAttributes, 4, req );
      req->reqType = __glXSetupForCommand(dpy);
      req->glxCode = X_GLXGetDrawableAttributes;
      req->drawable = drawable;
   }
   else {
      xGLXVendorPrivateWithReplyReq *vpreq;

      GetReqExtra( GLXVendorPrivateWithReply, 4, vpreq );
      data = (CARD32 *) (vpreq + 1);
      data[0] = (CARD32) drawable;

      vpreq->reqType = __glXSetupForCommand(dpy);
      vpreq->glxCode = X_GLXVendorPrivateWithReply;
      vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX;
   }

   _XReply(dpy, (xReply*) &reply, 0, False);

   length = reply.length;
   num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
   data = (CARD32 *) Xmalloc( length * sizeof(CARD32) );
   if ( data == NULL ) {
      /* Throw data on the floor */
      _XEatData(dpy, length);
   } else {
      _XRead(dpy, (char *)data, length * sizeof(CARD32) );
   }

   UnlockDisplay(dpy);
   SyncHandle();


   /* Search the set of returned attributes for the attribute requested by
    * the caller.
    */

   for ( i = 0 ; i < num_attributes ; i++ ) {
      if ( data[i*2] == attribute ) {
	 *value = data[ (i*2) + 1 ];
	 break;
      }
   }

   Xfree( data );

   return 0;
}
Ejemplo n.º 20
0
XFilters *
XRenderQueryFilters (Display *dpy, Drawable drawable)
{
    XRenderExtDisplayInfo		*info = XRenderFindDisplay (dpy);
    XRenderInfo			*xri;
    xRenderQueryFiltersReq	*req;
    xRenderQueryFiltersReply	rep;
    XFilters			*filters;
    char			*name;
    char			len;
    int				i;
    long			nbytes, nbytesAlias, nbytesName;

    if (!RenderHasExtension (info))
	return NULL;

    if (!XRenderQueryFormats (dpy))
	return NULL;

    xri = info->info;
    if (xri->minor_version < 6)
	return NULL;

    LockDisplay (dpy);
    GetReq (RenderQueryFilters, req);
    req->reqType = info->codes->major_opcode;
    req->renderReqType = X_RenderQueryFilters;
    req->drawable = drawable;
    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse))
    {
	UnlockDisplay (dpy);
	SyncHandle ();
	return NULL;
    }
    /*
     * Compute total number of bytes for filter names
     */
    nbytes = (long)rep.length << 2;
    nbytesAlias = rep.numAliases * 2;
    if (rep.numAliases & 1)
	nbytesAlias += 2;
    nbytesName = nbytes - nbytesAlias;

    /*
     * Allocate one giant block for the whole data structure
     */
    filters = Xmalloc (sizeof (XFilters) +
		       rep.numFilters * sizeof (char *) +
		       rep.numAliases * sizeof (short) +
		       nbytesName);

    if (!filters)
    {
	_XEatData (dpy, (unsigned long) rep.length << 2);
	UnlockDisplay (dpy);
	SyncHandle ();
	return NULL;
    }

    /*
     * Layout:
     *	XFilters
     *	numFilters  char * pointers to filter names
     *	numAliases  short alias values
     *	nbytesName  char strings
     */

    filters->nfilter = rep.numFilters;
    filters->nalias = rep.numAliases;
    filters->filter = (char **) (filters + 1);
    filters->alias = (short *) (filters->filter + rep.numFilters);
    name = (char *) (filters->alias + rep.numAliases);

    /*
     * Read the filter aliases
     */
    _XRead16Pad (dpy, filters->alias, 2 * rep.numAliases);

    /*
     * Read the filter names
     */
    for (i = 0; i < rep.numFilters; i++)
    {
	int	l;
	_XRead (dpy, &len, 1);
	l = len & 0xff;
	filters->filter[i] = name;
	_XRead (dpy, name, l);
	name[l] = '\0';
	name += l + 1;
    }
    i = name - (char *) (filters->alias + rep.numAliases);

    if (i & 3)
	_XEatData (dpy, 4 - (i & 3));

    UnlockDisplay (dpy);
    SyncHandle ();
    return filters;
}
Ejemplo n.º 21
0
/**
 * Create a non-pbuffer GLX drawable.
 *
 * \todo
 * This function needs to be modified to work with direct-rendering drivers.
 */
static GLXDrawable
CreateDrawable(Display * dpy, const __GLcontextModes * fbconfig,
               Drawable drawable, const int *attrib_list, CARD8 glxCode)
{
   xGLXCreateWindowReq *req;
   CARD32 *data;
   unsigned int i;
   CARD8 opcode;

   i = 0;
   if (attrib_list) {
      while (attrib_list[i * 2] != None)
         i++;
   }

   opcode = __glXSetupForCommand(dpy);
   if (!opcode)
      return None;

   LockDisplay(dpy);
   GetReqExtra(GLXCreateWindow, 8 * i, req);
   data = (CARD32 *) (req + 1);

   req->reqType = opcode;
   req->glxCode = glxCode;
   req->screen = (CARD32) fbconfig->screen;
   req->fbconfig = fbconfig->fbconfigID;
   req->window = (CARD32) drawable;
   req->glxwindow = (GLXWindow) XAllocID(dpy);
   req->numAttribs = (CARD32) i;

   if (attrib_list)
      memcpy(data, attrib_list, 8 * i);

   UnlockDisplay(dpy);
   SyncHandle();

#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
   do {
      /* FIXME: Maybe delay __DRIdrawable creation until the drawable
       * is actually bound to a context... */

      __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
      __GLXDRIdrawable *pdraw;
      __GLXscreenConfigs *psc;

      psc = &priv->screenConfigs[fbconfig->screen];
      if (psc->driScreen == NULL)
         break;
      pdraw = psc->driScreen->createDrawable(psc, drawable,
                                             req->glxwindow, fbconfig);
      if (pdraw == NULL) {
         fprintf(stderr, "failed to create drawable\n");
         break;
      }

      if (__glxHashInsert(psc->drawHash, req->glxwindow, pdraw)) {
         (*pdraw->destroyDrawable) (pdraw);
         return None;           /* FIXME: Check what we're supposed to do here... */
      }

      pdraw->textureTarget = determineTextureTarget(attrib_list, i);
      pdraw->textureFormat = determineTextureFormat(attrib_list, i);
   } while (0);
#endif

   return (GLXDrawable) req->glxwindow;
}
Ejemplo n.º 22
0
/**
 * Create a pbuffer.
 *
 * This function is used to implement \c glXCreatePbuffer and
 * \c glXCreateGLXPbufferSGIX.
 *
 * \note
 * This function dynamically determines whether to use the SGIX_pbuffer
 * version of the protocol or the GLX 1.3 version of the protocol.
 */
static GLXDrawable
CreatePbuffer(Display * dpy, struct glx_config *config,
              unsigned int width, unsigned int height,
              const int *attrib_list, GLboolean size_in_attribs)
{
   struct glx_display *priv = __glXInitialize(dpy);
   GLXDrawable id = 0;
   CARD32 *data;
   CARD8 opcode;
   unsigned int i;
   Pixmap pixmap;
   GLboolean glx_1_3 = GL_FALSE;

   i = 0;
   if (attrib_list) {
      while (attrib_list[i * 2])
         i++;
   }

   opcode = __glXSetupForCommand(dpy);
   if (!opcode)
      return None;

   LockDisplay(dpy);
   id = XAllocID(dpy);

   if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
      xGLXCreatePbufferReq *req;
      unsigned int extra = (size_in_attribs) ? 0 : 2;

      glx_1_3 = GL_TRUE;

      GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req);
      data = (CARD32 *) (req + 1);

      req->reqType = opcode;
      req->glxCode = X_GLXCreatePbuffer;
      req->screen = config->screen;
      req->fbconfig = config->fbconfigID;
      req->pbuffer = id;
      req->numAttribs = i + extra;

      if (!size_in_attribs) {
         data[(2 * i) + 0] = GLX_PBUFFER_WIDTH;
         data[(2 * i) + 1] = width;
         data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT;
         data[(2 * i) + 3] = height;
         data += 4;
      }
   }
   else {
      xGLXVendorPrivateReq *vpreq;

      GetReqExtra(GLXVendorPrivate, 20 + (8 * i), vpreq);
      data = (CARD32 *) (vpreq + 1);

      vpreq->reqType = opcode;
      vpreq->glxCode = X_GLXVendorPrivate;
      vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX;

      data[0] = config->screen;
      data[1] = config->fbconfigID;
      data[2] = id;
      data[3] = width;
      data[4] = height;
      data += 5;
   }

   (void) memcpy(data, attrib_list, sizeof(CARD32) * 2 * i);

   UnlockDisplay(dpy);
   SyncHandle();

   pixmap = XCreatePixmap(dpy, RootWindow(dpy, config->screen),
			  width, height, config->rgbBits);

   if (!CreateDRIDrawable(dpy, config, pixmap, id, attrib_list, i)) {
      CARD32 o = glx_1_3 ? X_GLXDestroyPbuffer : X_GLXvop_DestroyGLXPbufferSGIX;
      XFreePixmap(dpy, pixmap);
      protocolDestroyDrawable(dpy, id, o);
      id = None;
   }

   return id;
}
Ejemplo n.º 23
0
/**
 * Create a pbuffer.
 *
 * This function is used to implement \c glXCreatePbuffer and
 * \c glXCreateGLXPbufferSGIX.
 *
 * \note
 * This function dynamically determines whether to use the SGIX_pbuffer
 * version of the protocol or the GLX 1.3 version of the protocol.
 *
 * \todo
 * This function needs to be modified to work with direct-rendering drivers.
 */
static GLXDrawable
CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig,
              unsigned int width, unsigned int height,
              const int *attrib_list, GLboolean size_in_attribs)
{
   __GLXdisplayPrivate *priv = __glXInitialize(dpy);
   GLXDrawable id = 0;
   CARD32 *data;
   CARD8 opcode;
   unsigned int i;

   i = 0;
   if (attrib_list) {
      while (attrib_list[i * 2])
         i++;
   }

   opcode = __glXSetupForCommand(dpy);
   if (!opcode)
      return None;

   LockDisplay(dpy);
   id = XAllocID(dpy);

   if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
      xGLXCreatePbufferReq *req;
      unsigned int extra = (size_in_attribs) ? 0 : 2;

      GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req);
      data = (CARD32 *) (req + 1);

      req->reqType = opcode;
      req->glxCode = X_GLXCreatePbuffer;
      req->screen = (CARD32) fbconfig->screen;
      req->fbconfig = fbconfig->fbconfigID;
      req->pbuffer = (GLXPbuffer) id;
      req->numAttribs = (CARD32) (i + extra);

      if (!size_in_attribs) {
         data[(2 * i) + 0] = GLX_PBUFFER_WIDTH;
         data[(2 * i) + 1] = width;
         data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT;
         data[(2 * i) + 3] = height;
         data += 4;
      }
   }
   else {
      xGLXVendorPrivateReq *vpreq;

      GetReqExtra(GLXVendorPrivate, 20 + (8 * i), vpreq);
      data = (CARD32 *) (vpreq + 1);

      vpreq->reqType = opcode;
      vpreq->glxCode = X_GLXVendorPrivate;
      vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX;

      data[0] = (CARD32) fbconfig->screen;
      data[1] = (CARD32) fbconfig->fbconfigID;
      data[2] = (CARD32) id;
      data[3] = (CARD32) width;
      data[4] = (CARD32) height;
      data += 5;
   }

   (void) memcpy(data, attrib_list, sizeof(CARD32) * 2 * i);

   UnlockDisplay(dpy);
   SyncHandle();

   return id;
}
Ejemplo n.º 24
0
static void
CalcServerVersionAndExtensions(void)
{
    int s;
    char **be_extensions;
    char *ext;
    char *denied_extensions;

    /*
     * set the server glx version to be the minimum version
     * supported by all back-end servers
     */
    __glXVersionMajor = 0;
    __glXVersionMinor = 0;
    for (s = 0; s < __glXNumActiveScreens; s++) {
        DMXScreenInfo *dmxScreen = &dmxScreens[s];
        Display *dpy = dmxScreen->beDisplay;
        xGLXQueryVersionReq *req;
        xGLXQueryVersionReply reply;

        /* Send the glXQueryVersion request */
        LockDisplay(dpy);
        GetReq(GLXQueryVersion, req);
        req->reqType = dmxScreen->glxMajorOpcode;
        req->glxCode = X_GLXQueryVersion;
        req->majorVersion = GLX_SERVER_MAJOR_VERSION;
        req->minorVersion = GLX_SERVER_MINOR_VERSION;
        _XReply(dpy, (xReply *) &reply, 0, False);
        UnlockDisplay(dpy);
        SyncHandle();

        if (s == 0) {
            __glXVersionMajor = reply.majorVersion;
            __glXVersionMinor = reply.minorVersion;
        }
        else {
            if (reply.majorVersion < __glXVersionMajor) {
                __glXVersionMajor = reply.majorVersion;
                __glXVersionMinor = reply.minorVersion;
            }
            else if ((reply.majorVersion == __glXVersionMajor) &&
                     (reply.minorVersion < __glXVersionMinor)) {
                __glXVersionMinor = reply.minorVersion;
            }
        }

    }

    if (GLX_SERVER_MAJOR_VERSION < __glXVersionMajor) {
        __glXVersionMajor = GLX_SERVER_MAJOR_VERSION;
        __glXVersionMinor = GLX_SERVER_MINOR_VERSION;
    }
    else if ((GLX_SERVER_MAJOR_VERSION == __glXVersionMajor) &&
             (GLX_SERVER_MINOR_VERSION < __glXVersionMinor)) {
        __glXVersionMinor = GLX_SERVER_MINOR_VERSION;
    }

    snprintf(GLXServerVersion, sizeof(GLXServerVersion),
             "%d.%d DMX %d back-end server(s)",
             __glXVersionMajor, __glXVersionMinor, __glXNumActiveScreens);
    /*
     * set the ExtensionsString to the minimum extensions string
     */
    ExtensionsString[0] = '\0';

    /*
     * read extensions strings of all back-end servers
     */
    be_extensions = (char **) malloc(__glXNumActiveScreens * sizeof(char *));
    if (!be_extensions)
        return;

    for (s = 0; s < __glXNumActiveScreens; s++) {
        DMXScreenInfo *dmxScreen = &dmxScreens[s];
        Display *dpy = dmxScreen->beDisplay;
        xGLXQueryServerStringReq *req;
        xGLXQueryServerStringReply reply;
        int length, numbytes;

        /* Send the glXQueryServerString request */
        LockDisplay(dpy);
        GetReq(GLXQueryServerString, req);
        req->reqType = dmxScreen->glxMajorOpcode;
        req->glxCode = X_GLXQueryServerString;
        req->screen = DefaultScreen(dpy);
        req->name = GLX_EXTENSIONS;
        _XReply(dpy, (xReply *) &reply, 0, False);

        length = (int) reply.length;
        numbytes = (int) reply.n;
        be_extensions[s] = (char *) malloc(numbytes);
        if (!be_extensions[s]) {
            /* Throw data on the floor */
            _XEatDataWords(dpy, length);
        }
        else {
            _XReadPad(dpy, (char *) be_extensions[s], numbytes);
        }
        UnlockDisplay(dpy);
        SyncHandle();
    }

    /*
     * extensions string will include only extensions that our
     * server supports as well as all back-end servers supports.
     * extensions that are in the DMX_DENY_EXTENSIONS string will
     * not be supported.
     */
    denied_extensions = getenv("DMX_DENY_GLX_EXTENSIONS");
    ext = strtok(GLXServerExtensions, " ");
    while (ext) {
        int supported = 1;

        if (denied_extensions && strstr(denied_extensions, ext)) {
            supported = 0;
        }
        else {
            for (s = 0; s < __glXNumActiveScreens && supported; s++) {
                if (!strstr(be_extensions[s], ext)) {
                    supported = 0;
                }
            }
        }

        if (supported) {
            strcat(ExtensionsString, ext);
            strcat(ExtensionsString, " ");
        }

        ext = strtok(NULL, " ");
    }

    /*
     * release temporary storage
     */
    for (s = 0; s < __glXNumActiveScreens; s++) {
        free(be_extensions[s]);
    }
    free(be_extensions);

    if (dmxGLXSwapGroupSupport) {
        if (!denied_extensions ||
            !strstr(denied_extensions, "GLX_SGIX_swap_group")) {
            strcat(ExtensionsString, "GLX_SGIX_swap_group");
            if (!denied_extensions ||
                !strstr(denied_extensions, "GLX_SGIX_swap_barrier")) {
                strcat(ExtensionsString, " GLX_SGIX_swap_barrier");
            }
        }
    }

}
Ejemplo n.º 25
0
Archivo: XpJob.c Proyecto: aosm/X11libs
void
XpStartJob (
    Display    *dpy,
    XPSaveData save_data
)
{
    xPrintStartJobReq *req;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    XPContext    context;


    /****************************************************************
     *
     * PRIOR TO XPSTARTJOB, set the job attribute "job-owner"
     * which will be used by the X-Server when it spools the
     * output.  When XpStartJob completes, the job attribute
     * pool is frozen, disallowing "job-owner" to be modified.
     */
    {
	char            *joa;		/* job owner attribute */
 	char *PwName;
#ifndef WIN32
#ifdef X_NEEDS_PWPARAMS
	_Xgetpwparams pwparams;
#endif
	struct passwd *pw;
	pw = _XGetpwuid(getuid(),pwparams);

	if (pw && (PwName = pw->pw_name)) {
#else
	if ((PwName = getenv("USERNAME"))) {
#endif
	    joa = (char *) Xmalloc( strlen( PwName ) + 20 );
	    sprintf( joa, "*job-owner: %s", PwName );
            context = XpGetContext( dpy );
	    XpSetAttributes( dpy, context, XPJobAttr, joa, XPAttrMerge );

	    Xfree( joa );
	}
    }

    if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
	return; /* NoSuchExtension */

    LockDisplay (dpy);

    GetReq(PrintStartJob,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintStartJob;
    req->saveData = (CARD8) save_data;

    UnlockDisplay (dpy);
    SyncHandle ();
}


void
XpEndJob (
    Display  *dpy
)
{
    xPrintEndJobReq *req;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
	return; /* NoSuchExtension */

    LockDisplay (dpy);

    GetReq(PrintEndJob,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintEndJob;
    req->cancel = False;

    UnlockDisplay (dpy);
    SyncHandle ();
}
Ejemplo n.º 26
0
void
XRenderCompositeString8 (Display	    *dpy,
			 int		    op,
			 Picture	    src,
			 Picture	    dst,
			 _Xconst XRenderPictFormat  *maskFormat,
			 GlyphSet	    glyphset,
			 int		    xSrc,
			 int		    ySrc,
			 int		    xDst,
			 int		    yDst,
			 _Xconst char	    *string,
			 int		    nchar)
{
    XRenderExtDisplayInfo		*info = XRenderFindDisplay (dpy);
    xRenderCompositeGlyphs8Req	*req;
    long			len;
    xGlyphElt			*elt;
    int				nbytes;

    if (!nchar)
	return;

    RenderSimpleCheckExtension (dpy, info);
    LockDisplay(dpy);

    GetReq(RenderCompositeGlyphs8, req);
    req->reqType = info->codes->major_opcode;
    req->renderReqType = X_RenderCompositeGlyphs8;
    req->op = op;
    req->src = src;
    req->dst = dst;
    req->maskFormat = maskFormat ? maskFormat->id : None;
    req->glyphset = glyphset;
    req->xSrc = xSrc;
    req->ySrc = ySrc;

    /*
     * xGlyphElt must be aligned on a 32-bit boundary; this is
     * easily done by filling no more than 252 glyphs in each
     * bucket
     */

#define MAX_8 252

    len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar;

    req->length += (len + 3)>>2;  /* convert to number of 32-bit words */

    /*
     * If the entire request does not fit into the remaining space in the
     * buffer, flush the buffer first.
     */

    if (dpy->bufptr + len > dpy->bufmax)
    	_XFlush (dpy);

    while(nchar > MAX_8)
    {
	nbytes = MAX_8 + SIZEOF(xGlyphElt);
	BufAlloc (xGlyphElt *, elt, nbytes);
	elt->len = MAX_8;
	elt->deltax = xDst;
	elt->deltay = yDst;
	xDst = 0;
	yDst = 0;
	memcpy ((char *) (elt + 1), string, MAX_8);
	nchar = nchar - MAX_8;
	string += MAX_8;
    }

    if (nchar)
    {
	nbytes = (nchar + SIZEOF(xGlyphElt) + 3) & ~3;
	BufAlloc (xGlyphElt *, elt, nbytes);
	elt->len = nchar;
	elt->deltax = xDst;
	elt->deltay = yDst;
	memcpy ((char *) (elt + 1), string, nchar);
    }
#undef MAX_8

    UnlockDisplay(dpy);
    SyncHandle();
}
Ejemplo n.º 27
0
int
XIChangeHierarchy(Display* dpy,
                  XIAnyHierarchyChangeInfo* changes,
                  int num_changes)
{
    XIAnyHierarchyChangeInfo* any;
    xXIChangeHierarchyReq *req;
    XExtDisplayInfo *info = XInput_find_display(dpy);
    char *data = NULL, *dptr;
    int dlen = 0, i;

    LockDisplay(dpy);
    if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1)
        return (NoSuchExtension);

    if (num_changes <= 0)
        return Success;

    GetReq(XIChangeHierarchy, req);
    req->reqType = info->codes->major_opcode;
    req->ReqType = X_XIChangeHierarchy;
    req->num_changes = num_changes;

    /* alloc required memory */
    for (i = 0, any = changes; i < num_changes; i++, any++)
    {
        switch(any->type)
        {
        case XIAddMaster:
        {
            int slen = (strlen(any->add.name));
            dlen += sizeof(xXIAddMasterInfo) +
                    slen + (4 - (slen % 4));
        }
        break;
        case XIRemoveMaster:
            dlen += sizeof(xXIRemoveMasterInfo);
            break;
        case XIAttachSlave:
            dlen += sizeof(xXIAttachSlaveInfo);
            break;
        case XIDetachSlave:
            dlen += sizeof(xXIDetachSlaveInfo);
            break;
        default:
            return BadValue;
        }
    }

    req->length += dlen / 4; /* dlen is 4-byte aligned */
    data = Xmalloc(dlen);
    if (!data)
        return BadAlloc;

    dptr = data;
    for (i = 0, any = changes; i < num_changes; i++, any++)
    {
        switch(any->type)
        {
        case XIAddMaster:
        {
            XIAddMasterInfo* C = &any->add;
            xXIAddMasterInfo* c = (xXIAddMasterInfo*)dptr;
            c->type = C->type;
            c->send_core = C->send_core;
            c->enable = C->enable;
            c->name_len = strlen(C->name);
            c->length = (sizeof(xXIAddMasterInfo) + c->name_len + 3)/4;
            strncpy((char*)&c[1], C->name, c->name_len);
            dptr += c->length;
        }
        break;
        case XIRemoveMaster:
        {
            XIRemoveMasterInfo* R = &any->remove;
            xXIRemoveMasterInfo* r = (xXIRemoveMasterInfo*)dptr;
            r->type = R->type;
            r->return_mode = R->return_mode;
            r->deviceid = R->deviceid;
            r->length = sizeof(xXIRemoveMasterInfo)/4;
            if (r->return_mode == XIAttachToMaster)
            {
                r->return_pointer = R->return_pointer;
                r->return_keyboard = R->return_keyboard;
            }
            dptr += sizeof(xXIRemoveMasterInfo);
        }
        break;
        case XIAttachSlave:
        {
            XIAttachSlaveInfo* C = &any->attach;
            xXIAttachSlaveInfo* c = (xXIAttachSlaveInfo*)dptr;

            c->type = C->type;
            c->deviceid = C->deviceid;
            c->length = sizeof(xXIAttachSlaveInfo)/4;
            c->new_master = C->new_master;

            dptr += sizeof(xXIAttachSlaveInfo);
        }
        break;
        case XIDetachSlave:
        {
            XIDetachSlaveInfo *D = &any->detach;
            xXIDetachSlaveInfo *d = (xXIDetachSlaveInfo*)dptr;

            d->type = D->type;
            d->deviceid = D->deviceid;
            d->length = sizeof(xXIDetachSlaveInfo)/4;
            dptr += sizeof(xXIDetachSlaveInfo);
        }
        }
    }

    Data(dpy, data, dlen);
    Xfree(data);
    UnlockDisplay(dpy);
    SyncHandle();
    return Success;
}
Ejemplo n.º 28
0
void
XRenderCompositeString32 (Display	    *dpy,
			  int		    op,
			  Picture	    src,
			  Picture	    dst,
			  _Xconst XRenderPictFormat  *maskFormat,
			  GlyphSet	    glyphset,
			  int		    xSrc,
			  int		    ySrc,
			  int		    xDst,
			  int		    yDst,
			  _Xconst unsigned int	    *string,
			  int		    nchar)
{
    XRenderExtDisplayInfo		*info = XRenderFindDisplay (dpy);
    xRenderCompositeGlyphs8Req	*req;
    long			len;
    xGlyphElt			*elt;
    int				nbytes;

    if (!nchar)
	return;

    RenderSimpleCheckExtension (dpy, info);
    LockDisplay(dpy);

    GetReq(RenderCompositeGlyphs32, req);
    req->reqType = info->codes->major_opcode;
    req->renderReqType = X_RenderCompositeGlyphs32;
    req->op = op;
    req->src = src;
    req->dst = dst;
    req->maskFormat = maskFormat ? maskFormat->id : None;
    req->glyphset = glyphset;
    req->xSrc = xSrc;
    req->ySrc = ySrc;

#define MAX_32	254

    len = SIZEOF(xGlyphElt) * ((nchar + MAX_32-1) / MAX_32) + nchar * 4;

    req->length += (len + 3)>>2;  /* convert to number of 32-bit words */

    /*
     * If the entire request does not fit into the remaining space in the
     * buffer, flush the buffer first.
     */

    if (dpy->bufptr + len > dpy->bufmax)
    	_XFlush (dpy);

    while(nchar > MAX_32)
    {
	nbytes = MAX_32 * 4 + SIZEOF(xGlyphElt);
	BufAlloc (xGlyphElt *, elt, nbytes);
	elt->len = MAX_32;
	elt->deltax = xDst;
	elt->deltay = yDst;
	xDst = 0;
	yDst = 0;
	memcpy ((char *) (elt + 1), (char *) string, MAX_32 * 4);
	nchar = nchar - MAX_32;
	string += MAX_32;
    }

    if (nchar)
    {
	nbytes = nchar * 4 + SIZEOF(xGlyphElt);
	BufAlloc (xGlyphElt *, elt, nbytes);
	elt->len = nchar;
	elt->deltax = xDst;
	elt->deltay = yDst;
	memcpy ((char *) (elt + 1), (char *) string, nchar * 4);
    }
#undef MAX_32

    UnlockDisplay(dpy);
    SyncHandle();
}
Ejemplo n.º 29
0
int
XDrawString16(
    register Display *dpy,
    Drawable d,
    GC gc,
    int x,
    int y,
    _Xconst XChar2b *string,
    int length)
{
    int Datalength = 0;
    register xPolyText16Req *req;

    if (length <= 0)
       return 0;

    LockDisplay(dpy);
    FlushGC(dpy, gc);
    GetReq (PolyText16, req);
    req->drawable = d;
    req->gc = gc->gid;
    req->x = x;
    req->y = y;


    Datalength += SIZEOF(xTextElt) * ((length + 253) / 254) + (length << 1);


    req->length += (Datalength + 3)>>2;  /* convert to number of 32-bit words */


    /*
     * If the entire request does not fit into the remaining space in the
     * buffer, flush the buffer first.   If the request does fit into the
     * empty buffer, then we won't have to flush it at the end to keep
     * the buffer 32-bit aligned.
     */

    if (dpy->bufptr + Datalength > dpy->bufmax)
    	_XFlush (dpy);

    {
	int nbytes;
	int PartialNChars = length;
        register xTextElt *elt;
 	XChar2b *CharacterOffset = (XChar2b *)string;

	while(PartialNChars > 254)
        {
 	    nbytes = 254 * 2 + SIZEOF(xTextElt);
	    BufAlloc (xTextElt *, elt, nbytes);
	    elt->delta = 0;
	    elt->len = 254;
#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
	    {
		register int i;
		register unsigned char *cp;
		for (i = 0, cp = ((unsigned char *)elt) + 2; i < 254; i++) {
		    *cp++ = CharacterOffset[i].byte1;
		    *cp++ = CharacterOffset[i].byte2;
		}
	    }
#else
            memcpy (((char *) elt) + 2, (char *)CharacterOffset, 254 * 2);
#endif
	    PartialNChars = PartialNChars - 254;
	    CharacterOffset += 254;
	}

        if (PartialNChars)
        {
	    nbytes = PartialNChars * 2  + SIZEOF(xTextElt);
	    BufAlloc (xTextElt *, elt, nbytes);
	    elt->delta = 0;
	    elt->len = PartialNChars;
#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
	    {
		register int i;
		register unsigned char *cp;
		for (i = 0, cp = ((unsigned char *)elt) + 2; i < PartialNChars;
		     i++) {
		    *cp++ = CharacterOffset[i].byte1;
		    *cp++ = CharacterOffset[i].byte2;
		}
	    }
#else
            memcpy(((char *)elt) + 2, (char *)CharacterOffset, PartialNChars * 2);
#endif
	 }
    }

    /* Pad request out to a 32-bit boundary */

    if (Datalength &= 3) {
	char *pad;
	/*
	 * BufAlloc is a macro that uses its last argument more than
	 * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
	 */
	length = 4 - Datalength;
	BufAlloc (char *, pad, length);
	/*
	 * if there are 3 bytes of padding, the first byte MUST be 0
	 * so the pad bytes aren't mistaken for a final xTextElt
	 */
	*pad = 0;
        }

    /*
     * If the buffer pointer is not now pointing to a 32-bit boundary,
     * we must flush the buffer so that it does point to a 32-bit boundary
     * at the end of this routine.
     */

    if ((dpy->bufptr - dpy->buffer) & 3)
       _XFlush (dpy);
    UnlockDisplay(dpy);
    SyncHandle();
    return 0;
}
Ejemplo n.º 30
0
/**
 * Change a drawable's attribute.
 *
 * This function is used to implement \c glXSelectEvent and
 * \c glXSelectEventSGIX.
 *
 * \note
 * This function dynamically determines whether to use the SGIX_pbuffer
 * version of the protocol or the GLX 1.3 version of the protocol.
 */
static void
ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable,
                        const CARD32 * attribs, size_t num_attribs)
{
   struct glx_display *priv = __glXInitialize(dpy);
#ifdef GLX_DIRECT_RENDERING
   __GLXDRIdrawable *pdraw;
#endif
   CARD32 *output;
   CARD8 opcode;
   int i;

   if ((dpy == NULL) || (drawable == 0)) {
      return;
   }

   opcode = __glXSetupForCommand(dpy);
   if (!opcode)
      return;

   LockDisplay(dpy);

   if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
      xGLXChangeDrawableAttributesReq *req;

      GetReqExtra(GLXChangeDrawableAttributes, 8 * num_attribs, req);
      output = (CARD32 *) (req + 1);

      req->reqType = opcode;
      req->glxCode = X_GLXChangeDrawableAttributes;
      req->drawable = drawable;
      req->numAttribs = (CARD32) num_attribs;
   }
   else {
      xGLXVendorPrivateWithReplyReq *vpreq;

      GetReqExtra(GLXVendorPrivateWithReply, 8 + (8 * num_attribs), vpreq);
      output = (CARD32 *) (vpreq + 1);

      vpreq->reqType = opcode;
      vpreq->glxCode = X_GLXVendorPrivateWithReply;
      vpreq->vendorCode = X_GLXvop_ChangeDrawableAttributesSGIX;

      output[0] = (CARD32) drawable;
      output[1] = num_attribs;
      output += 2;
   }

   (void) memcpy(output, attribs, sizeof(CARD32) * 2 * num_attribs);

   UnlockDisplay(dpy);
   SyncHandle();

#ifdef GLX_DIRECT_RENDERING
   pdraw = GetGLXDRIDrawable(dpy, drawable);

   if (!pdraw)
      return;

   for (i = 0; i < num_attribs; i++) {
      switch(attribs[i * 2]) {
      case GLX_EVENT_MASK:
	 /* Keep a local copy for masking out DRI2 proto events as needed */
	 pdraw->eventMask = attribs[i * 2 + 1];
	 break;
      }
   }
#endif

   return;
}