Commit 0a2313a5 authored by Rafaël Carré's avatar Rafaël Carré

directfb: use triple buffering

parent 3f2ac49d
...@@ -66,6 +66,8 @@ struct vout_display_sys_t { ...@@ -66,6 +66,8 @@ struct vout_display_sys_t {
IDirectFBSurface *primary; IDirectFBSurface *primary;
picture_pool_t *pool; picture_pool_t *pool;
picture_t *pics[3];
int idx;
}; };
/* */ /* */
...@@ -85,11 +87,13 @@ static int Open(vlc_object_t *object) ...@@ -85,11 +87,13 @@ static int Open(vlc_object_t *object)
} }
DFBSurfaceDescription dsc; DFBSurfaceDescription dsc;
/*dsc.flags = DSDESC_CAPS | DSDESC_HEIGHT | DSDESC_WIDTH;*/
dsc.flags = DSDESC_CAPS; dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING; dsc.caps = DSCAPS_PRIMARY | DSCAPS_TRIPLE;
/*dsc.width = 352;*/ #if 0
/*dsc.height = 240;*/ dsc.flags |= DSDESC_HEIGHT | DSDESC_WIDTH;
dsc.width = 352;
dsc.height = 240;
#endif
IDirectFB *directfb = NULL; IDirectFB *directfb = NULL;
if (DirectFBCreate(&directfb) != DFB_OK || !directfb) if (DirectFBCreate(&directfb) != DFB_OK || !directfb)
...@@ -106,8 +110,6 @@ static int Open(vlc_object_t *object) ...@@ -106,8 +110,6 @@ static int Open(vlc_object_t *object)
int height; int height;
primary->GetSize(primary, &width, &height); primary->GetSize(primary, &width, &height);
primary->FillRectangle(primary, 0, 0, width, height);
primary->Flip(primary, NULL, 0);
vout_display_DeleteWindow(vd, NULL); vout_display_DeleteWindow(vd, NULL);
...@@ -183,42 +185,82 @@ static void Close(vlc_object_t *object) ...@@ -183,42 +185,82 @@ static void Close(vlc_object_t *object)
free(sys); free(sys);
} }
/* */ struct picture_sys_t {
static picture_pool_t *Pool(vout_display_t *vd, unsigned count) vout_display_sys_t *sys;
{ };
vout_display_sys_t *sys = vd->sys;
if (!sys->pool) static int Lock(picture_t *pic)
sys->pool = picture_pool_NewFromFormat(&vd->fmt, count); {
return sys->pool; vout_display_sys_t *sys = pic->p_sys->sys;
return sys->pics[sys->idx] == pic ? VLC_SUCCESS : VLC_EGENERIC;
} }
static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture) /* */
static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
{ {
VLC_UNUSED(count);
vout_display_sys_t *sys = vd->sys; vout_display_sys_t *sys = vd->sys;
IDirectFBSurface *primary = sys->primary; IDirectFBSurface *primary = sys->primary;
void *pixels; if (!sys->pool) {
int pitch;
if (primary->Lock(primary, DSLF_WRITE, &pixels, &pitch) == DFB_OK) {
picture_resource_t rsc; picture_resource_t rsc;
memset(&rsc, 0, sizeof(rsc)); memset(&rsc, 0, sizeof(rsc));
rsc.p[0].p_pixels = pixels;
rsc.p[0].i_lines = vd->fmt.i_height; rsc.p[0].i_lines = vd->fmt.i_height;
for (int i = 0; i < 3; i++) {
rsc.p_sys = malloc(sizeof(*rsc.p_sys));
if (!rsc.p_sys)
goto cleanup;
rsc.p_sys->sys = sys;
void *pixels;
int pitch;
if (primary->Lock(primary, DSLF_WRITE, &pixels, &pitch) != DFB_OK)
goto cleanup;
rsc.p[0].i_pitch = pitch; rsc.p[0].i_pitch = pitch;
rsc.p[0].p_pixels = pixels;
primary->Unlock(primary);
primary->Flip(primary, NULL, 0);
picture_t *direct = picture_NewFromResource(&vd->fmt, &rsc); sys->pics[i] = picture_NewFromResource(&vd->fmt, &rsc);
if (direct) { if (!sys->pics[i]) {
picture_Copy(direct, picture); free(rsc.p_sys);
picture_Release(direct); goto cleanup;
}
} }
if (primary->Unlock(primary) == DFB_OK) picture_pool_configuration_t cfg = {
primary->Flip(primary, NULL, 0); .picture_count = 3,
.picture = sys->pics,
.lock = Lock,
.unlock = NULL,
};
sys->pool = picture_pool_NewExtended(&cfg);
}
return sys->pool;
cleanup:
for (int i = 0; i < 2; i++) {
if (sys->pics[i]) {
free(sys->pics[i]->p_sys);
picture_Release(sys->pics[i]);
}
} }
return NULL;
}
static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
IDirectFBSurface *primary = sys->primary;
primary->Flip(primary, NULL, 0);
if (++sys->idx >= 3)
sys->idx = 0;
picture_Release(picture); picture_Release(picture);
VLC_UNUSED(subpicture); VLC_UNUSED(subpicture);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment