From 2abb58a8c508cb460bb7e8df70e0019b0face3c3 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 20 Nov 2006 18:08:34 +0000 Subject: [PATCH] *** empty log message *** --- osdwin.cc | 13 ++++++++++++- osdwin.h | 1 + surfacewin.cc | 7 ++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/osdwin.cc b/osdwin.cc index e3d04cf..7d89c79 100644 --- a/osdwin.cc +++ b/osdwin.cc @@ -38,6 +38,7 @@ OsdWin::OsdWin() d3drtsurf=NULL; external_driving=false; dsallocator=NULL; + lastrendertime=timeGetTime(); event = CreateEvent(NULL,/*FALSE*/TRUE,FALSE,NULL); d3dmutex = CreateMutex(NULL,FALSE,NULL); @@ -170,7 +171,15 @@ void OsdWin::Render() if (external_driving) { Sleep(5); //Sleep for 5 ms, in order to avoid blocking the other threads } else { - InternalRendering(NULL); + DWORD time1=timeGetTime(); + if ((time1-lastrendertime)>50) {//10 fps for OSD updates are enough, avoids tearing + InternalRendering(NULL); + lastrendertime=timeGetTime(); + } else { + Sleep(5); + + } + } } @@ -184,6 +193,7 @@ void OsdWin::RenderDS(LPDIRECT3DSURFACE9 present){ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){ WaitForSingleObject(event,INFINITE); + WaitForSingleObject(d3dmutex,INFINITE); BeginPainting(); if (external_driving) { //Copy video to Backbuffer @@ -244,6 +254,7 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){ } EndPainting(); } + ReleaseMutex(d3dmutex); if (!external_driving) { Sleep(4);//The User can wait for 4 milliseconds to see his changes } diff --git a/osdwin.h b/osdwin.h index ad0b89c..e52dc76 100644 --- a/osdwin.h +++ b/osdwin.h @@ -71,6 +71,7 @@ private: // This indicates, that currently a video is played, thus the osd updates are driven by the Directshow Filtersystem bool external_driving; HANDLE d3dmutex; + DWORD lastrendertime; void InternalRendering(LPDIRECT3DSURFACE9 present); void DoLost(); int InitVertexBuffer(); diff --git a/surfacewin.cc b/surfacewin.cc index 0cb251e..e6b486a 100644 --- a/surfacewin.cc +++ b/surfacewin.cc @@ -99,8 +99,8 @@ int SurfaceWin::fillblt(int x, int y, int width, int height, unsigned int c) osd->BeginPainting(); D3DLOCKED_RECT lockrect; int cx,cy,cwidth,cheight; - cx=min(max(x,0),swidth); - cy=min(max(y,0),sheight); + cx=min(max(x,0),swidth-1); + cy=min(max(y,0),sheight-1); cwidth=min(width,swidth-x); cheight=min(height,sheight-y); RECT rect={cx,cy,cwidth,cheight}; @@ -137,7 +137,7 @@ void SurfaceWin::drawPixel(int x, int y, unsigned int c) } OsdWin* osd=((OsdWin*)(Osd::getInstance())); LPDIRECT3DDEVICE9 d3ddev=osd->getD3dDev(); - if (x>swidth || y>sheight) return; //do not draw outside the surface + if (x>=swidth || y>=sheight) return; //do not draw outside the surface if (screen==this) { //This should not happen! return ; @@ -267,3 +267,4 @@ void SurfaceWin::drawJpeg(char *fileName,DWORD x, DWORD y,DWORD *width, DWORD *h } + -- 2.39.2