/*============================================================================= FUNCTION: render2VideoSurface DESCRIPTION: This function render a new frame on specific video surface It also will refresh other video surfaces in same video device automaticallly. ==============================================================================*/ VSFlowReturn render2VideoSurface(void * vshandle, SourceFrame * frame, SourceFmt * srcfmt) { VS_FLOW("Fun %s in\n", __FUNCTION__); VideoDevice * vd; VideoSurface * vsurface, *vsurface1; Updated updated; if ((vshandle==NULL)||(frame==NULL)){ VS_ERROR("%s: parameters error!\n", __FUNCTION__); return VS_FLOW_PARAMETER_ERROR; } vsurface = (VideoSurface *)vshandle; if (vsurface->status == VS_STATUS_INVISIBLE) /* no need to render */ return VS_FLOW_OK; vsurface->paddr = frame->paddr; vsurface->rendmask = 0;/*clear mask*/ vd = SURFACE2DEVICE(vsurface); if (sem_trywait(gVSlock)) return VS_FLOW_PENDING; vsurface1 = DEVICE2HEADSURFACE(vd); memset((void *)(&updated), 0, sizeof(Updated)); while(vsurface1){ if (_needRender(vsurface1, &updated, vd->renderidx)){ _renderSuface(vsurface1, vd, &updated); } vsurface1 = NEXTSURFACE(vsurface1); }; _FlipOnDevice(vd); #if 0 /* no need to sleep anymore */ if (vd->cnt>1) usleep(10000); #endif done: VS_UNLOCK(gVSlock); VS_FLOW("Fun %s out\n", __FUNCTION__); return VS_FLOW_OK; err: return VS_FLOW_ERROR; }
static void _refreshOnDevice (VideoDevice * vd) { VideoSurface *vs = DEVICE2HEADSURFACE (vd); Updated update; while (vs) { vs->rendmask = 0; _renderSuface (vs, vd, &update); vs = NEXTSURFACE (vs); } _FlipOnDevice (vd); }