diff --git a/src/apps/mediaplayer/VideoView.cpp b/src/apps/mediaplayer/VideoView.cpp index 402dc922eb..876cd31423 100644 --- a/src/apps/mediaplayer/VideoView.cpp +++ b/src/apps/mediaplayer/VideoView.cpp @@ -8,10 +8,10 @@ #include -#include - #include +#include #include +#include #include #include "Settings.h" @@ -39,6 +39,8 @@ VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask) fHasSubtitle(false), fSubtitleChanged(false), + fScreen(NULL), + fGlobalSettingsListener(this) { SetViewColor(B_TRANSPARENT_COLOR); @@ -63,6 +65,15 @@ VideoView::~VideoView() { Settings::Default()->RemoveListener(&fGlobalSettingsListener); delete fSubtitleBitmap; + delete fScreen; +} + + +void +VideoView::AttachedToWindow() +{ + delete fScreen; + fScreen = new BScreen(Window()); } @@ -367,6 +378,11 @@ VideoView::_DrawBitmap(const BBitmap* bitmap) { 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); } diff --git a/src/apps/mediaplayer/VideoView.h b/src/apps/mediaplayer/VideoView.h index 4eb7372c79..35a207ec25 100644 --- a/src/apps/mediaplayer/VideoView.h +++ b/src/apps/mediaplayer/VideoView.h @@ -17,6 +17,7 @@ enum { }; +class BScreen; class SubtitleBitmap; @@ -27,6 +28,7 @@ public: virtual ~VideoView(); // BView interface + virtual void AttachedToWindow(); virtual void Draw(BRect updateRect); virtual void MessageReceived(BMessage* message); virtual void Pulse(); @@ -76,6 +78,8 @@ private: bool fHasSubtitle; bool fSubtitleChanged; + BScreen* fScreen; + // Settings values: ListenerAdapter fGlobalSettingsListener; bool fUseOverlays;