void _fillDeviceLocalAlphaBuf (VideoDevice * vd, char *lbuf0, char *lbuf1) { VideoSurface *vs = DEVICE2HEADSURFACE (vd); int stride = vd->disp.right - vd->disp.left; while (vs) { int xoff, yoff; int width, height; int i; char *bufp0, *bufp1; xoff = vs->adjustdesrect.left - vd->disp.left; yoff = vs->adjustdesrect.top - vd->disp.top; width = vs->adjustdesrect.right - vs->adjustdesrect.left; height = vs->adjustdesrect.bottom - vs->adjustdesrect.top; bufp0 = lbuf0 + stride * yoff + xoff; bufp1 = lbuf1 + stride * yoff + xoff; for (i = 0; i < height; i++) { memset (bufp0, ALPHA_SOLID, width); bufp0 += stride; memset (bufp1, ALPHA_SOLID, width); bufp1 += stride; } vs = NEXTSURFACE (vs); }; }
void _destroyVideoSurface (void *vshandle, int force) { VideoSurface *vs, *vs1; VideoDevice *vd; vs = (VideoSurface *) vshandle; if (vs == NULL) return; VS_LOCK (gVSlock); if (force == 0) { vs1 = gvslocal; if (vs1 == vs) { gvslocal = vs->next; } else { while (vs1->next != vs) vs1 = vs1->next; vs1->next = vs->next; } } vd = SURFACE2DEVICE (vs); _removeVideoSurfaceFromDevice (vd, vs); // _clearBackground(vd, vs); _destroySubFrameBuffer (vs); vd->cleanmask = 0xffffffff; vd->cnt--; if (DEVICE2HEADSURFACE (vd) == NULL) { _closeDevice (vd); vd->init = 0; } else { if (_checkOnDevice (vd)) { _reconfigAllVideoSurfaces (vd); _setDeviceConfig (vd); } if (vd->setalpha) _setAlpha (vd); _refreshOnDevice (vd); } VS_MESSAGE ("VS%d destroyed, force=%d!\n", vs->id - 1, force); vs->status = VS_STATUS_IDLE; VS_UNLOCK (gVSlock); }
static void _reconfigAllVideoSurfaces (VideoDevice * vd) { VS_FLOW ("Fun %s in\n", __FUNCTION__); VideoSurface *vs = DEVICE2HEADSURFACE (vd); while (vs) { _initVSIPUTask (vs); vs = NEXTSURFACE (vs); } }
/*============================================================================= 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); }
static void _removeVideoSurfaceFromDevice (VideoDevice * vd, VideoSurface * vs) { VS_FLOW ("Fun %s in\n", __FUNCTION__); VideoSurface *pvs = DEVICE2HEADSURFACE (vd); if (pvs == vs) { SET_DEVICEHEADSURFACE (vd, NEXTSURFACE (vs)); } else { while (NEXTSURFACE (pvs) != vs) { pvs = NEXTSURFACE (pvs); } SET_NEXTSURFACE (pvs, NEXTSURFACE (vs)); } }
static void _addVideoSurface2Device (VideoDevice * vd, VideoSurface * vs) { VS_FLOW ("Fun %s in\n", __FUNCTION__); VideoSurface *pvs = DEVICE2HEADSURFACE (vd); vs->nextid = 0; if (pvs) { while (NEXTSURFACE (pvs)) pvs = NEXTSURFACE (pvs); SET_NEXTSURFACE (pvs, vs); } else { SET_DEVICEHEADSURFACE (vd, vs); } }