]> git.vomp.tv Git - vompclient.git/commitdiff
*** empty log message ***
authorChris Tallon <chris@vomp.tv>
Mon, 20 Nov 2006 18:08:34 +0000 (18:08 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 20 Nov 2006 18:08:34 +0000 (18:08 +0000)
osdwin.cc
osdwin.h
surfacewin.cc

index e3d04cfee2392b9dfce8ce75f46668c9e5150207..7d89c79870e368ba0bea22ebb86ef3c013b24d65 100644 (file)
--- a/osdwin.cc
+++ b/osdwin.cc
@@ -38,6 +38,7 @@ OsdWin::OsdWin()
   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
@@ -170,7 +171,15 @@ void OsdWin::Render()
        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
@@ -184,6 +193,7 @@ void OsdWin::RenderDS(LPDIRECT3DSURFACE9 present){
 \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
@@ -244,6 +254,7 @@ void OsdWin::InternalRendering(LPDIRECT3DSURFACE9 present){
                }\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
index ad0b89c931a79b53a3fbb25dbf15e957f8e23cb3..e52dc766699b23979d562b1a20a3cbdb727b307e 100644 (file)
--- 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\r
        bool external_driving;\r
        HANDLE d3dmutex;\r
+       DWORD lastrendertime;\r
        void InternalRendering(LPDIRECT3DSURFACE9 present);\r
        void DoLost();\r
        int InitVertexBuffer();\r
index 0cb251e99108f6cbe043978a72f1fc33bbc3fc2b..e6b486a43d8ce20abe557c7fe4dd2f7f3d2a59ef 100644 (file)
@@ -99,8 +99,8 @@ int SurfaceWin::fillblt(int x, int y, int width, int height, unsigned int c)
     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
@@ -137,7 +137,7 @@ void SurfaceWin::drawPixel(int x, int y, unsigned int c)
   }\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
@@ -267,3 +267,4 @@ void SurfaceWin::drawJpeg(char *fileName,DWORD x, DWORD y,DWORD *width, DWORD *h
 \r
 }\r
 \r
+\r