d3drtsurf=NULL;\r
external_driving=false;\r
dsallocator=NULL;\r
+ lastrendertime=timeGetTime();\r
event = CreateEvent(NULL,/*FALSE*/TRUE,FALSE,NULL);\r
d3dmutex = CreateMutex(NULL,FALSE,NULL);\r
\r
if (external_driving) {\r
Sleep(5); //Sleep for 5 ms, in order to avoid blocking the other threads\r
} else {\r
- InternalRendering(NULL);\r
+ DWORD time1=timeGetTime();\r
+ if ((time1-lastrendertime)>50) {//10 fps for OSD updates are enough, avoids tearing\r
+ InternalRendering(NULL);\r
+ lastrendertime=timeGetTime();\r
+ } else {\r
+ Sleep(5);\r
+ \r
+ }\r
+ \r
}\r
}\r
\r
\r
void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){\r
WaitForSingleObject(event,INFINITE);\r
+ WaitForSingleObject(d3dmutex,INFINITE);\r
BeginPainting();\r
if (external_driving) {\r
//Copy video to Backbuffer\r
}\r
EndPainting();\r
}\r
+ ReleaseMutex(d3dmutex);\r
if (!external_driving) {\r
Sleep(4);//The User can wait for 4 milliseconds to see his changes\r
}\r
// This indicates, that currently a video is played, thus the osd updates are driven by the Directshow Filtersystem\r
bool external_driving;\r
HANDLE d3dmutex;\r
+ DWORD lastrendertime;\r
void InternalRendering(LPDIRECT3DSURFACE9 present);\r
void DoLost();\r
int InitVertexBuffer();\r
osd->BeginPainting();\r
D3DLOCKED_RECT lockrect;\r
int cx,cy,cwidth,cheight;\r
- cx=min(max(x,0),swidth);\r
- cy=min(max(y,0),sheight);\r
+ cx=min(max(x,0),swidth-1);\r
+ cy=min(max(y,0),sheight-1);\r
cwidth=min(width,swidth-x);\r
cheight=min(height,sheight-y);\r
RECT rect={cx,cy,cwidth,cheight};\r
}\r
OsdWin* osd=((OsdWin*)(Osd::getInstance()));\r
LPDIRECT3DDEVICE9 d3ddev=osd->getD3dDev();\r
- if (x>swidth || y>sheight) return; //do not draw outside the surface\r
+ if (x>=swidth || y>=sheight) return; //do not draw outside the surface\r
if (screen==this) {\r
//This should not happen!\r
return ;\r
\r
}\r
\r
+\r