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

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 1 Sep 2010 15:02:30 +0200 (CEST)

Author: stippi
Date: 2010-09-01 15:02:30 +0200 (Wed, 01 Sep 2010)
New Revision: 38492
Changeset: http://dev.haiku-os.org/changeset/38492

Modified:
   haiku/trunk/src/apps/mediaplayer/MainWin.cpp
   haiku/trunk/src/apps/mediaplayer/VideoView.cpp
   haiku/trunk/src/apps/mediaplayer/VideoView.h
Log:
Do not resize the VideoView to the scaled size
of the video anymore, but tell the VideoView
the video frame size. So the outside regions of
the video are also painted by the VideoView. Not
tested with overlays, but should work. The side
effect is that the controls appear along the bottom
of the screen in full-screen mode. The controls
may need to be over the video, so they cannot be
attached to the parent of the VideoView (this was
already the case).


Modified: haiku/trunk/src/apps/mediaplayer/MainWin.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/MainWin.cpp        2010-09-01 12:56:27 UTC 
(rev 38491)
+++ haiku/trunk/src/apps/mediaplayer/MainWin.cpp        2010-09-01 13:02:30 UTC 
(rev 38492)
@@ -1666,11 +1666,16 @@
        if (renderHeight > height)
                renderHeight = height;
 
-       int xOffset = x + (width - renderWidth) / 2;
-       int yOffset = y + (height - renderHeight) / 2;
+       int xOffset = (width - renderWidth) / 2;
+       int yOffset = (height - renderHeight) / 2;
 
-       fVideoView->MoveTo(xOffset, yOffset);
-       fVideoView->ResizeTo(renderWidth - 1, renderHeight - 1);
+       fVideoView->MoveTo(x, y);
+       fVideoView->ResizeTo(width - 1, height - 1);
+
+       BRect videoFrame(xOffset, yOffset,
+               xOffset + renderWidth - 1, yOffset + renderHeight - 1);
+
+       fVideoView->SetVideoFrame(videoFrame);
 }
 
 

Modified: haiku/trunk/src/apps/mediaplayer/VideoView.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/VideoView.cpp      2010-09-01 12:56:27 UTC 
(rev 38491)
+++ haiku/trunk/src/apps/mediaplayer/VideoView.cpp      2010-09-01 13:02:30 UTC 
(rev 38492)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2009 Stephan Aßmus <superstippi@xxxxxx>
+ * Copyright 2006-2010 Stephan Aßmus <superstippi@xxxxxx>
  * All rights reserved. Distributed under the terms of the MIT license.
  */
 
@@ -21,6 +21,7 @@
 #endif
 
 #include <Application.h>
+#include <Region.h>
 #include <WindowScreen.h>
 
 #include "Settings.h"
@@ -30,6 +31,7 @@
        :
        BView(frame, name, resizeMask, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE
                | B_PULSE_NEEDED),
+       fVideoFrame(Bounds()),
        fOverlayMode(false),
        fIsPlaying(false),
        fIsFullscreen(false),
@@ -37,7 +39,6 @@
        fGlobalSettingsListener(this)
 {
        SetViewColor(B_TRANSPARENT_COLOR);
-               // might be reset to overlay key color if overlays are used
        SetHighColor(0, 0, 0);
 
        // create some hopefully sensible default overlay restrictions
@@ -61,19 +62,21 @@
 void
 VideoView::Draw(BRect updateRect)
 {
-       bool fillBlack = true;
+       BRegion outSideVideoRegion(updateRect);
 
        if (LockBitmap()) {
                if (const BBitmap* bitmap = GetBitmap()) {
-                       fillBlack = false;
+                       outSideVideoRegion.Exclude(fVideoFrame);
                        if (!fOverlayMode)
                                _DrawBitmap(bitmap);
+                       else
+                               FillRect(fVideoFrame & updateRect, B_SOLID_LOW);
                }
                UnlockBitmap();
        }
 
-       if (fillBlack)
-               FillRect(updateRect);
+       if (outSideVideoRegion.CountRects() > 0)
+               FillRegion(&outSideVideoRegion);
 }
 
 
@@ -147,15 +150,14 @@
                                // init overlay
                                rgb_color key;
                                status_t ret = SetViewOverlay(bitmap, 
bitmap->Bounds(),
-                                       Bounds(), &key, B_FOLLOW_ALL,
+                                       fVideoFrame, &key, B_FOLLOW_ALL,
                                        B_OVERLAY_FILTER_HORIZONTAL
                                        | B_OVERLAY_FILTER_VERTICAL);
                                if (ret == B_OK) {
                                        fOverlayKeyColor = key;
-                                       SetViewColor(key);
                                        SetLowColor(key);
                                        snooze(20000);
-                                       FillRect(Bounds(), B_SOLID_LOW);
+                                       FillRect(fVideoFrame, B_SOLID_LOW);
                                        Sync();
                                        // use overlay from here on
                                        fOverlayMode = true;
@@ -168,13 +170,13 @@
                                } else {
                                        // try again next time
                                        // synchronous draw
-                                       FillRect(Bounds());
+                                       FillRect(fVideoFrame);
                                        Sync();
                                }
                        } else {
                                // transfer overlay channel
                                rgb_color key;
-                               SetViewOverlay(bitmap, bitmap->Bounds(), 
Bounds(),
+                               SetViewOverlay(bitmap, bitmap->Bounds(), 
fVideoFrame,
                                        &key, B_FOLLOW_ALL, 
B_OVERLAY_FILTER_HORIZONTAL
                                                | B_OVERLAY_FILTER_VERTICAL
                                                | B_OVERLAY_TRANSFER_CHANNEL);
@@ -270,6 +272,20 @@
 }
 
 
+void
+VideoView::SetVideoFrame(const BRect& frame)
+{
+       if (fVideoFrame == frame)
+               return;
+
+       BRegion invalid(fVideoFrame | frame);
+       invalid.Exclude(frame);
+       Invalidate(&invalid);
+
+       fVideoFrame = frame;
+}
+
+
 // #pragma mark -
 
 
@@ -278,9 +294,9 @@
 {
 #ifdef __HAIKU__
        uint32 options = fUseBilinearScaling ? B_FILTER_BITMAP_BILINEAR : 0;
-       DrawBitmap(bitmap, bitmap->Bounds(), Bounds(), options);
+       DrawBitmap(bitmap, bitmap->Bounds(), fVideoFrame, options);
 #else
-       DrawBitmap(bitmap, bitmap->Bounds(), Bounds());
+       DrawBitmap(bitmap, bitmap->Bounds(), fVideoFrame);
 #endif
 }
 

Modified: haiku/trunk/src/apps/mediaplayer/VideoView.h
===================================================================
--- haiku/trunk/src/apps/mediaplayer/VideoView.h        2010-09-01 12:56:27 UTC 
(rev 38491)
+++ haiku/trunk/src/apps/mediaplayer/VideoView.h        2010-09-01 13:02:30 UTC 
(rev 38492)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2009 Stephan Aßmus <superstippi@xxxxxx>
+ * Copyright 2006-2010 Stephan Aßmus <superstippi@xxxxxx>
  * All rights reserved. Distributed under the terms of the MIT license.
  */
 #ifndef VIDEO_VIEW_H
@@ -46,11 +46,14 @@
 
                        void                            SetPlaying(bool 
playing);
                        void                            SetFullscreen(bool 
fullScreen);
+                       void                            SetVideoFrame(const 
BRect& frame);
 
 private:
                        void                            _DrawBitmap(const 
BBitmap* bitmap);
                        void                            _AdoptGlobalSettings();
 
+private:
+                       BRect                           fVideoFrame;
                        bool                            fOverlayMode;
                        overlay_restrictions fOverlayRestrictions;
                        rgb_color                       fOverlayKeyColor;


Other related posts:

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