sna/video: Keep a ref to the passthrough overlay bo

Otherwise we will destroy it at the end of the frame whilst it is still
meant to be shown. Not normally an issue as the next frame is show
before it vanishes, but is if the image is shown for an extended period
of time.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-08-16 21:55:16 +01:00
parent d8c9b2c852
commit 6692077aca
3 changed files with 28 additions and 1 deletions

View File

@ -98,6 +98,7 @@ struct sna_video {
bool textured;
Rotation rotation;
int plane;
struct kgem_bo *bo;
int SyncToVblank; /* -1: auto, 0: off, 1: on */
int AlwaysOnTop;

View File

@ -138,6 +138,10 @@ static int sna_video_overlay_stop(ClientPtr client,
DRM_IOCTL_I915_OVERLAY_PUT_IMAGE,
&request);
if (video->bo)
kgem_bo_destroy(&sna->kgem, video->bo);
video->bo = NULL;
sna_video_free_buffers(video);
sna_window_set_port((WindowPtr)draw, NULL);
return Success;
@ -445,7 +449,18 @@ sna_video_overlay_show(struct sna *sna,
DBG(("%s: flags=%x\n", __FUNCTION__, request.flags));
return drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_OVERLAY_PUT_IMAGE, &request) == 0;
if (drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_OVERLAY_PUT_IMAGE, &request)) {
DBG(("%s: Putimage failed\n", __FUNCTION__));
return false;
}
if (video->bo != frame->bo) {
if (video->bo)
kgem_bo_destroy(&sna->kgem, video->bo);
video->bo = kgem_bo_reference(frame->bo);
}
return true;
}
static int

View File

@ -72,8 +72,13 @@ static int sna_video_sprite_stop(ClientPtr client,
xf86DrvMsg(video->sna->scrn->scrnIndex, X_ERROR,
"failed to disable plane\n");
if (video->bo)
kgem_bo_destroy(&video->sna->kgem, video->bo);
video->bo = NULL;
video->plane = 0;
sna_window_set_port((WindowPtr)draw, NULL);
return Success;
}
@ -296,6 +301,12 @@ sna_video_sprite_show(struct sna *sna,
frame->bo->domain = DOMAIN_NONE;
video->plane = s.plane_id;
if (video->bo != frame->bo) {
if (video->bo)
kgem_bo_destroy(&sna->kgem, video->bo);
video->bo = kgem_bo_reference(frame->bo);
}
return true;
}