[haiku-commits] r39094 - haiku/trunk/src/apps/mediaplayer

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 23 Oct 2010 22:57:25 +0200 (CEST)

Author: stippi
Date: 2010-10-23 22:57:25 +0200 (Sat, 23 Oct 2010)
New Revision: 39094
Changeset: http://dev.haiku-os.org/changeset/39094

Modified:
   haiku/trunk/src/apps/mediaplayer/VideoView.cpp
   haiku/trunk/src/apps/mediaplayer/VideoView.h
Log:
Wait for the vertical retrace before blitting a bitmap,
should avoid tearing in the video on supported graphics
drivers.


Modified: haiku/trunk/src/apps/mediaplayer/VideoView.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/VideoView.cpp      2010-10-23 20:34:26 UTC 
(rev 39093)
+++ haiku/trunk/src/apps/mediaplayer/VideoView.cpp      2010-10-23 20:57:25 UTC 
(rev 39094)
@@ -8,10 +8,10 @@
 
 #include <stdio.h>
 
+#include <Application.h>
 #include <Bitmap.h>
-
-#include <Application.h>
 #include <Region.h>
+#include <Screen.h>
 #include <WindowScreen.h>
 
 #include "Settings.h"
@@ -39,6 +39,8 @@
        fHasSubtitle(false),
        fSubtitleChanged(false),
 
+       fScreen(NULL),
+
        fGlobalSettingsListener(this)
 {
        SetViewColor(B_TRANSPARENT_COLOR);
@@ -63,10 +65,19 @@
 {
        Settings::Default()->RemoveListener(&fGlobalSettingsListener);
        delete fSubtitleBitmap;
+       delete fScreen;
 }
 
 
 void
+VideoView::AttachedToWindow()
+{
+       delete fScreen;
+       fScreen = new BScreen(Window());
+}
+
+
+void
 VideoView::Draw(BRect updateRect)
 {
        BRegion outSideVideoRegion(updateRect);
@@ -367,6 +378,11 @@
 {
        SetDrawingMode(B_OP_COPY);
        uint32 options = fUseBilinearScaling ? B_FILTER_BITMAP_BILINEAR : 0;
+
+       // We don't care if the graphics driver actually supports this.
+       // On supported graphics hardware, this should avoid tearing.
+       fScreen->WaitForRetrace();
+
        DrawBitmapAsync(bitmap, bitmap->Bounds(), fVideoFrame, options);
 }
 

Modified: haiku/trunk/src/apps/mediaplayer/VideoView.h
===================================================================
--- haiku/trunk/src/apps/mediaplayer/VideoView.h        2010-10-23 20:34:26 UTC 
(rev 39093)
+++ haiku/trunk/src/apps/mediaplayer/VideoView.h        2010-10-23 20:57:25 UTC 
(rev 39094)
@@ -17,6 +17,7 @@
 };
 
 
+class BScreen;
 class SubtitleBitmap;
 
 
@@ -27,6 +28,7 @@
        virtual                                         ~VideoView();
 
        // BView interface
+       virtual void                            AttachedToWindow();
        virtual void                            Draw(BRect updateRect);
        virtual void                            MessageReceived(BMessage* 
message);
        virtual void                            Pulse();
@@ -76,6 +78,8 @@
                        bool                            fHasSubtitle;
                        bool                            fSubtitleChanged;
 
+                       BScreen*                        fScreen;
+
                        // Settings values:
                        ListenerAdapter         fGlobalSettingsListener;
                        bool                            fUseOverlays;


Other related posts:

  • » [haiku-commits] r39094 - haiku/trunk/src/apps/mediaplayer - superstippi