Bug 21143

Summary: Xorg server doesn't support XvPutImage drawing into a Pixmap
Product: xorg Reporter: Austin Yuan <yuanshengquan>
Component: Server/DDX/XorgAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED MOVED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: rstoddard, yann, yuanshengquan
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Patch to remove the limitation that XvPutImage can't draw into pixmap in Xserver
none
Patch to remove the limitation that XvPutImage can't draw into pixmap in Xserver
none
Allow XVideo to draw on a pixmap. none

Description Austin Yuan 2009-04-12 23:02:47 UTC
When using XvPutImage to draw into a pixmap, it always returns
error because hw/xfree86/common/xf86xv.c:xf86XVPutImage checks whether the drawable is WINDOW, if not, it returns BadAlloc directly, see bellow code:

> static int
> xf86XVPutImage(
>   ClientPtr client,
>   DrawablePtr pDraw,
>   XvPortPtr pPort,
>   GCPtr pGC,
>   INT16 src_x, INT16 src_y,
>   CARD16 src_w, CARD16 src_h,
>   INT16 drw_x, INT16 drw_y,
>   CARD16 drw_w, CARD16 drw_h,
>   XvImagePtr format,
>   unsigned char* data,
>   Bool sync,
>   CARD16 width, CARD16 height
> ){
>  XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
>  ScreenPtr pScreen;
>  RegionRec WinRegion;
>  RegionRec ClipRegion;
>  BoxRec WinBox;
>  int ret = Success;
>  Bool clippedAway = FALSE;
>
>  if (pDraw->type != DRAWABLE_WINDOW)
> =>    return BadAlloc;

But usually Xvideo implementation in Xserver video driver will handle WINDOW vs PIXMAP correctly, for example:

>    if (pDraw->type == DRAWABLE_WINDOW)
>        pPriv->pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
>    else
>        pPriv->pPixmap = (PixmapPtr)pDraw;
>
> #ifdef USE_EXA
>    if (info->useEXA) {
>        /* Force the pixmap into framebuffer so we can draw to it. */
>        exaMoveInPixmap(pPriv->pPixmap);
>    }
> #endif
>
Comment 1 Austin Yuan 2009-04-12 23:14:23 UTC
Created attachment 24740 [details]
Patch to remove the limitation that XvPutImage can't draw into pixmap in Xserver

Here it the patch to remove the limitation that XvPutImage can't draw into pixmap in Xserver
Comment 2 Austin Yuan 2009-04-12 23:14:30 UTC
Created attachment 24741 [details] [review]
Patch to remove the limitation that XvPutImage can't draw into pixmap in Xserver

Here it the patch to remove the limitation that XvPutImage can't draw into pixmap in Xserver
Comment 3 Michel Dänzer 2009-09-01 02:34:33 UTC
*** Bug 10994 has been marked as a duplicate of this bug. ***
Comment 4 Michel Dänzer 2009-09-01 02:37:14 UTC
My main concern is that XvPutImage to a pixmap won't do anything useful for an overlay based adaptor. (How) Does the patch handle this?
Comment 5 Austin Yuan 2010-01-08 01:01:40 UTC
(In reply to comment #4)
> My main concern is that XvPutImage to a pixmap won't do anything useful for an
> overlay based adaptor. (How) Does the patch handle this?

Xv Overlay should add something like (currently this check is in DIX, but blocks textured video to render into a pixmap)

  /* No dumping video to pixmaps... For now anyhow */
  if(pDraw->type != DRAWABLE_WINDOW) {
      pPort->pDraw = (DrawablePtr)NULL;
      return BadAlloc;
  }
Comment 6 Kusanagi Kouichi 2010-02-01 00:29:14 UTC
Created attachment 32958 [details] [review]
Allow XVideo to draw on a pixmap.

How about this patch? it checks whether an adaptor supports requested drawable type.
Comment 7 Michel Dänzer 2010-02-01 08:41:02 UTC
(In reply to comment #6)
> How about this patch? it checks whether an adaptor supports requested drawable
> type.

Kouichi-san, I think it's a step in the right direction.

In order to avoid changing the type of the XvAdaptorRec member (which would require bumping the video driver ABI major version), it may be better to keep the checks in the hw/xfree86/ code though.

You could also post the patch to the xorg-devel mailing list for (hopefully) broader review.
Comment 8 GitLab Migration User 2018-12-13 18:28:39 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/xserver/issues/147.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.