Colormap XCreateColormap( register Display *dpy, Window w, Visual *visual, int alloc) { register xCreateColormapReq *req; Colormap mid; LockDisplay(dpy); GetReq(CreateColormap, req); req->window = w; mid = req->mid = XAllocID(dpy); req->alloc = alloc; if (visual == CopyFromParent) req->visual = CopyFromParent; else req->visual = visual->visualid; UnlockDisplay(dpy); SyncHandle(); #ifdef XCMS _XcmsAddCmapRec(dpy, mid, w, visual); #endif return(mid); }
XFontStruct *XLoadQueryFont( register Display *dpy, _Xconst char *name) { XFontStruct *font_result; register long nbytes; Font fid; xOpenFontReq *req; unsigned long seq; #ifdef USE_XF86BIGFONT XF86BigfontCodes *extcodes = _XF86BigfontCodes(dpy); #endif if (_XF86LoadQueryLocaleFont(dpy, name, &font_result, (Font *)0)) return font_result; LockDisplay(dpy); GetReq(OpenFont, req); seq = dpy->request; nbytes = req->nbytes = name ? strlen(name) : 0; req->fid = fid = XAllocID(dpy); req->length += (nbytes+3)>>2; Data (dpy, name, nbytes); font_result = NULL; #ifdef USE_XF86BIGFONT if (extcodes) { font_result = _XF86BigfontQueryFont(dpy, extcodes, fid, seq); seq = 0; } #endif if (!font_result) font_result = _XQueryFont(dpy, fid, seq); UnlockDisplay(dpy); SyncHandle(); return font_result; }
Picture XRenderCreatePicture (Display *dpy, Drawable drawable, _Xconst XRenderPictFormat *format, unsigned long valuemask, _Xconst XRenderPictureAttributes *attributes) { XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); Picture pid; xRenderCreatePictureReq *req; RenderCheckExtension (dpy, info, 0); LockDisplay(dpy); GetReq(RenderCreatePicture, req); req->reqType = info->codes->major_opcode; req->renderReqType = X_RenderCreatePicture; req->pid = pid = XAllocID(dpy); req->drawable = drawable; req->format = format->id; if ((req->mask = valuemask)) _XRenderProcessPictureAttributes (dpy, (xRenderChangePictureReq *) req, valuemask, attributes); UnlockDisplay(dpy); SyncHandle(); return pid; }
Picture XRenderCreateConicalGradient(Display *dpy, const XConicalGradient *gradient, const XFixed *stops, const XRenderColor *colors, int nStops) { XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); Picture pid; xRenderCreateConicalGradientReq *req; long len; RenderCheckExtension (dpy, info, 0); LockDisplay(dpy); GetReq(RenderCreateConicalGradient, req); req->reqType = info->codes->major_opcode; req->renderReqType = X_RenderCreateConicalGradient; req->pid = pid = XAllocID(dpy); req->center.x = gradient->center.x; req->center.y = gradient->center.y; req->angle = gradient->angle; req->nStops = nStops; len = (long) nStops * 3; SetReqLen (req, len, 6); DataInt32(dpy, stops, nStops * 4); Data16(dpy, colors, nStops * 8); UnlockDisplay(dpy); SyncHandle(); return pid; }
XdbeBackBuffer XdbeAllocateBackBufferName( Display *dpy, Window window, XdbeSwapAction swap_action) { XExtDisplayInfo *info = find_display (dpy); register xDbeAllocateBackBufferNameReq *req; XdbeBackBuffer buffer; /* make sure extension is available; if not, return the * third parameter (0). */ DbeCheckExtension (dpy, info, (XdbeBackBuffer)0); /* allocate the id */ buffer = XAllocID (dpy); LockDisplay(dpy); DbeGetReq(DbeAllocateBackBufferName, req, info); req->window = window; req->swapAction = (unsigned char)swap_action; req->buffer = buffer; UnlockDisplay (dpy); SyncHandle (); return buffer; } /* XdbeAllocateBackBufferName() */
Colormap XDGACreateColormap( Display *dpy, int screen, XDGADevice *dev, int alloc ){ XExtDisplayInfo *info = xdga_find_display (dpy); xXDGACreateColormapReq *req; Colormap cid; XDGACheckExtension (dpy, info, -1); LockDisplay(dpy); GetReq(XDGACreateColormap, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGACreateColormap; req->screen = screen; req->mode = dev->mode.num; req->alloc = alloc; cid = req->id = XAllocID(dpy); UnlockDisplay(dpy); SyncHandle(); return cid; }
Cursor XCreateGlyphCursor( register Display *dpy, Font source_font, Font mask_font, unsigned int source_char, unsigned int mask_char, XColor _Xconst *foreground, XColor _Xconst *background) { Cursor cid; register xCreateGlyphCursorReq *req; #ifdef USE_DYNAMIC_XCURSOR cid = _XTryShapeCursor (dpy, source_font, mask_font, source_char, mask_char, foreground, background); if (cid) return cid; #endif LockDisplay(dpy); GetReq(CreateGlyphCursor, req); cid = req->cid = XAllocID(dpy); req->source = source_font; req->mask = mask_font; req->sourceChar = source_char; req->maskChar = mask_char; req->foreRed = foreground->red; req->foreGreen = foreground->green; req->foreBlue = foreground->blue; req->backRed = background->red; req->backGreen = background->green; req->backBlue = background->blue; UnlockDisplay(dpy); SyncHandle(); return (cid); }
/** * Create a non-pbuffer GLX drawable. */ static GLXDrawable CreateDrawable(Display *dpy, struct glx_config *config, Drawable drawable, const int *attrib_list, CARD8 glxCode) { xGLXCreateWindowReq *req; struct glx_drawable *glxDraw; CARD32 *data; unsigned int i; CARD8 opcode; GLXDrawable xid; i = 0; if (attrib_list) { while (attrib_list[i * 2] != None) i++; } opcode = __glXSetupForCommand(dpy); if (!opcode) return None; glxDraw = malloc(sizeof(*glxDraw)); if (!glxDraw) return None; LockDisplay(dpy); GetReqExtra(GLXCreateWindow, 8 * i, req); data = (CARD32 *) (req + 1); req->reqType = opcode; req->glxCode = glxCode; req->screen = config->screen; req->fbconfig = config->fbconfigID; req->window = drawable; req->glxwindow = xid = XAllocID(dpy); req->numAttribs = i; if (attrib_list) memcpy(data, attrib_list, 8 * i); UnlockDisplay(dpy); SyncHandle(); if (InitGLXDrawable(dpy, glxDraw, drawable, xid)) { free(glxDraw); return None; } if (!CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i)) { if (glxCode == X_GLXCreatePixmap) glxCode = X_GLXDestroyPixmap; else glxCode = X_GLXDestroyWindow; protocolDestroyDrawable(dpy, xid, glxCode); xid = None; } return xid; }
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, PIPE_VIDEO_PROFILE_MPEG2_MAIN, 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, PIPE_VIDEO_PROFILE_MPEG2_MAIN, PIPE_VIDEO_CAP_PREFERS_INTERLACED ); surface_priv->video_buffer = pipe->create_video_buffer(pipe, &tmpl); 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; }
XPContext XpCreateContext ( Display *dpy, char *printer_name ) { xPrintCreateContextReq *req; XExtensionVersion *ext; char *locale; int locale_len; XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy); if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1) return ( (XPContext) None ); /* No such extension */ /* * Fetch locale information. Note: XpGetLocaleNetString has * a thread-safe mutex on _Xglobal_lock. */ locale = XpGetLocaleNetString(); LockDisplay (dpy); GetReq(PrintCreateContext,req); req->reqType = info->codes->major_opcode; req->printReqType = X_PrintCreateContext; req->contextID = XAllocID(dpy); req->printerNameLen = strlen(printer_name); if ( locale == (char *) NULL ) req->localeLen = 0; else if ( *locale == (char) NULL ) req->localeLen = 0; else { locale_len = strlen( locale ); req->length += _XpPadOut(locale_len) >> 2; req->localeLen = (unsigned long) locale_len; } /* * Attach variable data */ req->length += _XpPadOut(req->printerNameLen) >> 2; Data( dpy, (char *) printer_name, (long) req->printerNameLen ); if (req->localeLen) Data( dpy, (char *) locale, (long) req->localeLen ); UnlockDisplay(dpy); SyncHandle(); XFree(locale); return ( (XPContext) req->contextID ); }
Status _xvmc_create_subpicture ( Display *dpy, XvMCContext *context, XvMCSubpicture *subpicture, int *priv_count, CARD32 **priv_data ) { XExtDisplayInfo *info = xvmc_find_display(dpy); xvmcCreateSubpictureReply rep; xvmcCreateSubpictureReq *req; *priv_count = 0; *priv_data = NULL; XvMCCheckExtension (dpy, info, BadImplementation); LockDisplay (dpy); XvMCGetReq (CreateSubpicture, req); subpicture->subpicture_id = XAllocID(dpy); subpicture->context_id = context->context_id; req->subpicture_id = subpicture->subpicture_id; req->context_id = subpicture->context_id; req->xvimage_id = subpicture->xvimage_id; req->width = subpicture->width; req->height = subpicture->height; if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { UnlockDisplay (dpy); SyncHandle (); return BadImplementation; } subpicture->width = rep.width_actual; subpicture->height = rep.height_actual; subpicture->num_palette_entries = rep.num_palette_entries; subpicture->entry_bytes = rep.entry_bytes; subpicture->component_order[0] = rep.component_order[0]; subpicture->component_order[1] = rep.component_order[1]; subpicture->component_order[2] = rep.component_order[2]; subpicture->component_order[3] = rep.component_order[3]; if(rep.length) { *priv_data = Xmalloc(rep.length << 2); if(*priv_data) { _XRead(dpy, (char*)(*priv_data), rep.length << 2); *priv_count = rep.length; } else _XEatData(dpy, rep.length << 2); } UnlockDisplay (dpy); SyncHandle (); return Success; }
Status _xvmc_create_surface ( Display *dpy, XvMCContext *context, XvMCSurface *surface, int *priv_count, CARD32 **priv_data ) { XExtDisplayInfo *info = xvmc_find_display(dpy); xvmcCreateSurfaceReply rep; xvmcCreateSurfaceReq *req; *priv_count = 0; *priv_data = NULL; XvMCCheckExtension (dpy, info, BadImplementation); LockDisplay (dpy); XvMCGetReq (CreateSurface, req); 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; req->surface_id = surface->surface_id; req->context_id = surface->context_id; if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { UnlockDisplay (dpy); SyncHandle (); return BadImplementation; } if(rep.length) { *priv_data = Xmalloc(rep.length << 2); if(*priv_data) { _XRead(dpy, (char*)(*priv_data), rep.length << 2); *priv_count = rep.length; } else _XEatData(dpy, rep.length << 2); } UnlockDisplay (dpy); SyncHandle (); return Success; }
GlyphSet XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format) { XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); GlyphSet gsid; xRenderCreateGlyphSetReq *req; RenderCheckExtension (dpy, info, 0); LockDisplay(dpy); GetReq(RenderCreateGlyphSet, req); req->reqType = info->codes->major_opcode; req->renderReqType = X_RenderCreateGlyphSet; req->gsid = gsid = XAllocID(dpy); req->format = format->id; UnlockDisplay(dpy); SyncHandle(); return gsid; }
GlyphSet XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing) { XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); GlyphSet gsid; xRenderReferenceGlyphSetReq *req; RenderCheckExtension (dpy, info, 0); LockDisplay(dpy); GetReq(RenderReferenceGlyphSet, req); req->reqType = info->codes->major_opcode; req->renderReqType = X_RenderReferenceGlyphSet; req->gsid = gsid = XAllocID(dpy); req->existing = existing; UnlockDisplay(dpy); SyncHandle(); return gsid; }
Pixmap XCompositeNameWindowPixmap (Display *dpy, Window window) { XCompositeExtDisplayInfo *info = XCompositeFindDisplay (dpy); xCompositeNameWindowPixmapReq *req; Pixmap pixmap; XCompositeCheckExtension (dpy, info, 0); LockDisplay (dpy); GetReq (CompositeNameWindowPixmap, req); req->reqType = info->codes->major_opcode; req->compositeReqType = X_CompositeNameWindowPixmap; req->window = window; pixmap = req->pixmap = XAllocID (dpy); UnlockDisplay (dpy); SyncHandle (); return pixmap; }
XserverRegion XCompositeCreateRegionFromBorderClip (Display *dpy, Window window) { XCompositeExtDisplayInfo *info = XCompositeFindDisplay (dpy); xCompositeCreateRegionFromBorderClipReq *req; XserverRegion region; XCompositeCheckExtension (dpy, info, 0); LockDisplay (dpy); GetReq (CompositeCreateRegionFromBorderClip, req); req->reqType = info->codes->major_opcode; req->compositeReqType = X_CompositeCreateRegionFromBorderClip; req->window = window; region = req->region = XAllocID (dpy); UnlockDisplay (dpy); SyncHandle (); return region; }
Damage XDamageCreate (Display *dpy, Drawable drawable, int level) { XDamageExtDisplayInfo *info = XDamageFindDisplay (dpy); xDamageCreateReq *req; Damage damage; XDamageCheckExtension (dpy, info, 0); LockDisplay (dpy); GetReq (DamageCreate, req); req->reqType = info->codes->major_opcode; req->damageReqType = X_DamageCreate; req->damage = damage = XAllocID (dpy); req->drawable = drawable; req->level = level; UnlockDisplay (dpy); SyncHandle (); return damage; }
/** * 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 = (GLXPbuffer) drawable; req->glxwindow = (GLXWindow) XAllocID(dpy); req->numAttribs = (CARD32) i; memcpy( data, attrib_list, 8 * i ); UnlockDisplay(dpy); SyncHandle(); return (GLXDrawable)req->glxwindow; }
PointerBarrier XFixesCreatePointerBarrier(Display *dpy, Window w, int x1, int y1, int x2, int y2, int directions, int num_devices, int *devices) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesCreatePointerBarrierReq *req; PointerBarrier barrier; int extra = 0; XFixesCheckExtension (dpy, info, 0); if (info->major_version < 5) return 0; if (num_devices) extra = (((2 * num_devices) + 3) / 4) * 4; LockDisplay (dpy); GetReqExtra (XFixesCreatePointerBarrier, extra, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesCreatePointerBarrier; barrier = req->barrier = XAllocID (dpy); req->window = w; req->x1 = x1; req->y1 = y1; req->x2 = x2; req->y2 = y2; req->directions = directions; if ((req->num_devices = num_devices)) { int i; CARD16 *devs = (CARD16 *)(req + 1); for (i = 0; i < num_devices; i++) devs[i] = (CARD16)(devices[i]); } UnlockDisplay (dpy); SyncHandle(); return barrier; }
Picture XRenderCreateSolidFill(Display *dpy, const XRenderColor *color) { XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); Picture pid; xRenderCreateSolidFillReq *req; RenderCheckExtension (dpy, info, 0); LockDisplay(dpy); GetReq(RenderCreateSolidFill, req); req->reqType = info->codes->major_opcode; req->renderReqType = X_RenderCreateSolidFill; req->pid = pid = XAllocID(dpy); req->color.red = color->red; req->color.green = color->green; req->color.blue = color->blue; req->color.alpha = color->alpha; UnlockDisplay(dpy); SyncHandle(); return pid; }
Font XLoadFont ( register Display *dpy, _Xconst char *name) { register long nbytes; Font fid; register xOpenFontReq *req; if (_XF86LoadQueryLocaleFont(dpy, name, (XFontStruct **)0, &fid)) return fid; LockDisplay(dpy); GetReq(OpenFont, req); nbytes = req->nbytes = name ? strlen(name) : 0; req->fid = fid = XAllocID(dpy); req->length += (nbytes+3)>>2; Data (dpy, name, nbytes); UnlockDisplay(dpy); SyncHandle(); return (fid); /* can't return (req->fid) since request may have already been sent */ }
/** * 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; }
/** * 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; }
int depth, unsigned int class, Visual *visual, unsigned long valuemask, XSetWindowAttributes *attr, Multibuffer *leftp, Multibuffer *rightp) { XExtDisplayInfo *info = find_display (dpy); Window wid; register xMbufCreateStereoWindowReq *req; MbufCheckExtension (dpy, info, None); LockDisplay(dpy); MbufGetReq(MbufCreateStereoWindow, req, info); wid = req->wid = XAllocID(dpy); req->parent = parent; req->left = *leftp = XAllocID (dpy); req->right = *rightp = XAllocID (dpy); req->x = x; req->y = y; req->width = width; req->height = height; req->borderWidth = border_width; req->depth = depth; req->class = class; if (visual == (Visual *)CopyFromParent) req->visual = CopyFromParent; else req->visual = visual->visualid; valuemask &= (CWBackPixmap|CWBackPixel|CWBorderPixmap|
XDGADevice * XDGASetMode( Display *dpy, int screen, int mode ){ XExtDisplayInfo *dinfo = xdga_find_display (dpy); xXDGASetModeReply rep; xXDGASetModeReq *req; XDGADevice *dev = NULL; Pixmap pid; XDGACheckExtension (dpy, dinfo, NULL); LockDisplay(dpy); GetReq(XDGASetMode, req); req->reqType = dinfo->codes->major_opcode; req->dgaReqType = X_XDGASetMode; req->screen = screen; req->mode = mode; req->pid = pid = XAllocID(dpy); if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if(rep.length) { xXDGAModeInfo info; int size; size = rep.length << 2; size -= sz_xXDGAModeInfo; /* get text size */ dev = (XDGADevice*)Xmalloc(sizeof(XDGADevice) + size); if(dev) { _XRead(dpy, (char*)(&info), sz_xXDGAModeInfo); dev->mode.num = info.num; dev->mode.verticalRefresh = (float)info.vsync_num / (float)info.vsync_den; dev->mode.flags = info.flags; dev->mode.imageWidth = info.image_width; dev->mode.imageHeight = info.image_height; dev->mode.pixmapWidth = info.pixmap_width; dev->mode.pixmapHeight = info.pixmap_height; dev->mode.bytesPerScanline = info.bytes_per_scanline; dev->mode.byteOrder = info.byte_order; dev->mode.depth = info.depth; dev->mode.bitsPerPixel = info.bpp; dev->mode.redMask = info.red_mask; dev->mode.greenMask = info.green_mask; dev->mode.blueMask = info.blue_mask; dev->mode.visualClass = info.visual_class; dev->mode.viewportWidth = info.viewport_width; dev->mode.viewportHeight = info.viewport_height; dev->mode.xViewportStep = info.viewport_xstep; dev->mode.yViewportStep = info.viewport_ystep; dev->mode.maxViewportX = info.viewport_xmax; dev->mode.maxViewportY = info.viewport_ymax; dev->mode.viewportFlags = info.viewport_flags; dev->mode.reserved1 = info.reserved1; dev->mode.reserved2 = info.reserved2; dev->mode.name = (char*)(&dev[1]); _XRead(dpy, dev->mode.name, info.name_size); dev->pixmap = (rep.flags & XDGAPixmap) ? pid : 0; dev->data = XDGAGetMappedMemory(screen); if(dev->data) dev->data += rep.offset; } /* not sure what to do if the allocation fails */ } } UnlockDisplay(dpy); SyncHandle(); return dev; }
PUBLIC Status XvMCCreateSubpicture(Display *dpy, XvMCContext *context, XvMCSubpicture *subpicture, unsigned short width, unsigned short height, int xvimage_id) { XvMCContextPrivate *context_priv; XvMCSubpicturePrivate *subpicture_priv; struct pipe_context *pipe; struct pipe_resource tex_templ, *tex; struct pipe_sampler_view sampler_templ; Status ret; XVMC_MSG(XVMC_TRACE, "[XvMC] Creating subpicture %p.\n", subpicture); assert(dpy); if (!context) return XvMCBadContext; context_priv = context->privData; pipe = context_priv->pipe; if (!subpicture) return XvMCBadSubpicture; if (width > context_priv->subpicture_max_width || height > context_priv->subpicture_max_height) return BadValue; ret = Validate(dpy, context->port, context->surface_type_id, xvimage_id); if (ret != Success) return ret; subpicture_priv = CALLOC(1, sizeof(XvMCSubpicturePrivate)); if (!subpicture_priv) return BadAlloc; memset(&tex_templ, 0, sizeof(tex_templ)); tex_templ.target = PIPE_TEXTURE_2D; tex_templ.format = XvIDToPipe(xvimage_id); tex_templ.last_level = 0; if (pipe->screen->get_video_param(pipe->screen, PIPE_VIDEO_PROFILE_UNKNOWN, PIPE_VIDEO_ENTRYPOINT_UNKNOWN, PIPE_VIDEO_CAP_NPOT_TEXTURES)) { tex_templ.width0 = width; tex_templ.height0 = height; } else { tex_templ.width0 = util_next_power_of_two(width); tex_templ.height0 = util_next_power_of_two(height); } tex_templ.depth0 = 1; tex_templ.array_size = 1; tex_templ.usage = PIPE_USAGE_DYNAMIC; tex_templ.bind = PIPE_BIND_SAMPLER_VIEW; tex_templ.flags = 0; tex = pipe->screen->resource_create(pipe->screen, &tex_templ); memset(&sampler_templ, 0, sizeof(sampler_templ)); u_sampler_view_default_template(&sampler_templ, tex, tex->format); subpicture_priv->sampler = pipe->create_sampler_view(pipe, tex, &sampler_templ); pipe_resource_reference(&tex, NULL); if (!subpicture_priv->sampler) { FREE(subpicture_priv); return BadAlloc; } subpicture_priv->context = context; subpicture->subpicture_id = XAllocID(dpy); subpicture->context_id = context->context_id; subpicture->xvimage_id = xvimage_id; subpicture->width = width; subpicture->height = height; subpicture->num_palette_entries = NumPaletteEntries4XvID(xvimage_id); subpicture->entry_bytes = PipeToComponentOrder(tex_templ.format, subpicture->component_order); subpicture->privData = subpicture_priv; if (subpicture->num_palette_entries > 0) { tex_templ.target = PIPE_TEXTURE_1D; tex_templ.format = PIPE_FORMAT_R8G8B8X8_UNORM; tex_templ.width0 = subpicture->num_palette_entries; tex_templ.height0 = 1; tex_templ.usage = PIPE_USAGE_DEFAULT; tex = pipe->screen->resource_create(pipe->screen, &tex_templ); memset(&sampler_templ, 0, sizeof(sampler_templ)); u_sampler_view_default_template(&sampler_templ, tex, tex->format); sampler_templ.swizzle_a = PIPE_SWIZZLE_ONE; subpicture_priv->palette = pipe->create_sampler_view(pipe, tex, &sampler_templ); pipe_resource_reference(&tex, NULL); if (!subpicture_priv->sampler) { FREE(subpicture_priv); return BadAlloc; } } SyncHandle(); XVMC_MSG(XVMC_TRACE, "[XvMC] Subpicture %p created.\n", subpicture); return Success; }
PUBLIC Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, int width, int height, int flags, XvMCContext *context) { bool found_port; int scrn = 0; int chroma_format = 0; int mc_type = 0; int surface_flags = 0; unsigned short subpic_max_w = 0; unsigned short subpic_max_h = 0; Status ret; struct vl_screen *vscreen; struct pipe_context *pipe; struct pipe_video_codec templat = {0}; XvMCContextPrivate *context_priv; vl_csc_matrix csc; XVMC_MSG(XVMC_TRACE, "[XvMC] Creating context %p.\n", context); assert(dpy); if (!context) return XvMCBadContext; ret = Validate(dpy, port, surface_type_id, width, height, flags, &found_port, &scrn, &chroma_format, &mc_type, &surface_flags, &subpic_max_w, &subpic_max_h); /* Success and XvBadPort have the same value */ if (ret != Success || !found_port) return ret; /* XXX: Current limits */ if (chroma_format != XVMC_CHROMA_FORMAT_420) { XVMC_MSG(XVMC_ERR, "[XvMC] Cannot decode requested surface type. Unsupported chroma format.\n"); return BadImplementation; } if ((mc_type & ~XVMC_IDCT) != (XVMC_MOCOMP | XVMC_MPEG_2)) { XVMC_MSG(XVMC_ERR, "[XvMC] Cannot decode requested surface type. Non-MPEG2/Mocomp/iDCT acceleration unsupported.\n"); return BadImplementation; } if (surface_flags & XVMC_INTRA_UNSIGNED) { XVMC_MSG(XVMC_ERR, "[XvMC] Cannot decode requested surface type. Unsigned intra unsupported.\n"); return BadImplementation; } context_priv = CALLOC(1, sizeof(XvMCContextPrivate)); if (!context_priv) return BadAlloc; /* TODO: Reuse screen if process creates another context */ vscreen = vl_screen_create(dpy, scrn); if (!vscreen) { XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL screen.\n"); FREE(context_priv); return BadAlloc; } pipe = vscreen->pscreen->context_create(vscreen->pscreen, vscreen, 0); if (!pipe) { XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL context.\n"); vl_screen_destroy(vscreen); FREE(context_priv); return BadAlloc; } templat.profile = ProfileToPipe(mc_type); templat.entrypoint = (mc_type & XVMC_IDCT) ? PIPE_VIDEO_ENTRYPOINT_IDCT : PIPE_VIDEO_ENTRYPOINT_MC; templat.chroma_format = FormatToPipe(chroma_format); templat.width = width; templat.height = height; templat.max_references = 2; templat.expect_chunked_decode = true; context_priv->decoder = pipe->create_video_codec(pipe, &templat); if (!context_priv->decoder) { XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL decoder.\n"); pipe->destroy(pipe); vl_screen_destroy(vscreen); FREE(context_priv); return BadAlloc; } if (!vl_compositor_init(&context_priv->compositor, pipe)) { XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor.\n"); context_priv->decoder->destroy(context_priv->decoder); pipe->destroy(pipe); vl_screen_destroy(vscreen); FREE(context_priv); return BadAlloc; } if (!vl_compositor_init_state(&context_priv->cstate, pipe)) { XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor state.\n"); vl_compositor_cleanup(&context_priv->compositor); context_priv->decoder->destroy(context_priv->decoder); pipe->destroy(pipe); vl_screen_destroy(vscreen); FREE(context_priv); return BadAlloc; } context_priv->color_standard = debug_get_bool_option("G3DVL_NO_CSC", FALSE) ? VL_CSC_COLOR_STANDARD_IDENTITY : VL_CSC_COLOR_STANDARD_BT_601; context_priv->procamp = vl_default_procamp; vl_csc_get_matrix ( context_priv->color_standard, &context_priv->procamp, true, &csc ); vl_compositor_set_csc_matrix(&context_priv->cstate, (const vl_csc_matrix *)&csc); context_priv->vscreen = vscreen; context_priv->pipe = pipe; context_priv->subpicture_max_width = subpic_max_w; context_priv->subpicture_max_height = subpic_max_h; context->context_id = XAllocID(dpy); context->surface_type_id = surface_type_id; context->width = width; context->height = height; context->flags = flags; context->port = port; context->privData = context_priv; SyncHandle(); XVMC_MSG(XVMC_TRACE, "[XvMC] Context %p created.\n", context); return Success; }
/** * 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; }