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).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38492 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2010-09-01 13:02:30 +00:00
parent 4edcbff706
commit ee891c8828
3 changed files with 42 additions and 18 deletions
+9 -4
View File
@@ -1666,11 +1666,16 @@ MainWin::_ResizeVideoView(int x, int y, int width, int height)
if (renderHeight > height) if (renderHeight > height)
renderHeight = height; renderHeight = height;
int xOffset = x + (width - renderWidth) / 2; int xOffset = (width - renderWidth) / 2;
int yOffset = y + (height - renderHeight) / 2; int yOffset = (height - renderHeight) / 2;
fVideoView->MoveTo(xOffset, yOffset); fVideoView->MoveTo(x, y);
fVideoView->ResizeTo(renderWidth - 1, renderHeight - 1); fVideoView->ResizeTo(width - 1, height - 1);
BRect videoFrame(xOffset, yOffset,
xOffset + renderWidth - 1, yOffset + renderHeight - 1);
fVideoView->SetVideoFrame(videoFrame);
} }
+29 -13
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2009 Stephan Aßmus <[email protected]> * Copyright 2006-2010 Stephan Aßmus <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
@@ -21,6 +21,7 @@
#endif #endif
#include <Application.h> #include <Application.h>
#include <Region.h>
#include <WindowScreen.h> #include <WindowScreen.h>
#include "Settings.h" #include "Settings.h"
@@ -30,6 +31,7 @@ VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask)
: :
BView(frame, name, resizeMask, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE BView(frame, name, resizeMask, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE
| B_PULSE_NEEDED), | B_PULSE_NEEDED),
fVideoFrame(Bounds()),
fOverlayMode(false), fOverlayMode(false),
fIsPlaying(false), fIsPlaying(false),
fIsFullscreen(false), fIsFullscreen(false),
@@ -37,7 +39,6 @@ VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask)
fGlobalSettingsListener(this) fGlobalSettingsListener(this)
{ {
SetViewColor(B_TRANSPARENT_COLOR); SetViewColor(B_TRANSPARENT_COLOR);
// might be reset to overlay key color if overlays are used
SetHighColor(0, 0, 0); SetHighColor(0, 0, 0);
// create some hopefully sensible default overlay restrictions // create some hopefully sensible default overlay restrictions
@@ -61,19 +62,21 @@ VideoView::~VideoView()
void void
VideoView::Draw(BRect updateRect) VideoView::Draw(BRect updateRect)
{ {
bool fillBlack = true; BRegion outSideVideoRegion(updateRect);
if (LockBitmap()) { if (LockBitmap()) {
if (const BBitmap* bitmap = GetBitmap()) { if (const BBitmap* bitmap = GetBitmap()) {
fillBlack = false; outSideVideoRegion.Exclude(fVideoFrame);
if (!fOverlayMode) if (!fOverlayMode)
_DrawBitmap(bitmap); _DrawBitmap(bitmap);
else
FillRect(fVideoFrame & updateRect, B_SOLID_LOW);
} }
UnlockBitmap(); UnlockBitmap();
} }
if (fillBlack) if (outSideVideoRegion.CountRects() > 0)
FillRect(updateRect); FillRegion(&outSideVideoRegion);
} }
@@ -147,15 +150,14 @@ VideoView::SetBitmap(const BBitmap* bitmap)
// init overlay // init overlay
rgb_color key; rgb_color key;
status_t ret = SetViewOverlay(bitmap, bitmap->Bounds(), status_t ret = SetViewOverlay(bitmap, bitmap->Bounds(),
Bounds(), &key, B_FOLLOW_ALL, fVideoFrame, &key, B_FOLLOW_ALL,
B_OVERLAY_FILTER_HORIZONTAL B_OVERLAY_FILTER_HORIZONTAL
| B_OVERLAY_FILTER_VERTICAL); | B_OVERLAY_FILTER_VERTICAL);
if (ret == B_OK) { if (ret == B_OK) {
fOverlayKeyColor = key; fOverlayKeyColor = key;
SetViewColor(key);
SetLowColor(key); SetLowColor(key);
snooze(20000); snooze(20000);
FillRect(Bounds(), B_SOLID_LOW); FillRect(fVideoFrame, B_SOLID_LOW);
Sync(); Sync();
// use overlay from here on // use overlay from here on
fOverlayMode = true; fOverlayMode = true;
@@ -168,13 +170,13 @@ VideoView::SetBitmap(const BBitmap* bitmap)
} else { } else {
// try again next time // try again next time
// synchronous draw // synchronous draw
FillRect(Bounds()); FillRect(fVideoFrame);
Sync(); Sync();
} }
} else { } else {
// transfer overlay channel // transfer overlay channel
rgb_color key; rgb_color key;
SetViewOverlay(bitmap, bitmap->Bounds(), Bounds(), SetViewOverlay(bitmap, bitmap->Bounds(), fVideoFrame,
&key, B_FOLLOW_ALL, B_OVERLAY_FILTER_HORIZONTAL &key, B_FOLLOW_ALL, B_OVERLAY_FILTER_HORIZONTAL
| B_OVERLAY_FILTER_VERTICAL | B_OVERLAY_FILTER_VERTICAL
| B_OVERLAY_TRANSFER_CHANNEL); | B_OVERLAY_TRANSFER_CHANNEL);
@@ -270,6 +272,20 @@ VideoView::SetFullscreen(bool fullScreen)
} }
void
VideoView::SetVideoFrame(const BRect& frame)
{
if (fVideoFrame == frame)
return;
BRegion invalid(fVideoFrame | frame);
invalid.Exclude(frame);
Invalidate(&invalid);
fVideoFrame = frame;
}
// #pragma mark - // #pragma mark -
@@ -278,9 +294,9 @@ VideoView::_DrawBitmap(const BBitmap* bitmap)
{ {
#ifdef __HAIKU__ #ifdef __HAIKU__
uint32 options = fUseBilinearScaling ? B_FILTER_BITMAP_BILINEAR : 0; uint32 options = fUseBilinearScaling ? B_FILTER_BITMAP_BILINEAR : 0;
DrawBitmap(bitmap, bitmap->Bounds(), Bounds(), options); DrawBitmap(bitmap, bitmap->Bounds(), fVideoFrame, options);
#else #else
DrawBitmap(bitmap, bitmap->Bounds(), Bounds()); DrawBitmap(bitmap, bitmap->Bounds(), fVideoFrame);
#endif #endif
} }
+4 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2009 Stephan Aßmus <[email protected]> * Copyright 2006-2010 Stephan Aßmus <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef VIDEO_VIEW_H #ifndef VIDEO_VIEW_H
@@ -46,11 +46,14 @@ public:
void SetPlaying(bool playing); void SetPlaying(bool playing);
void SetFullscreen(bool fullScreen); void SetFullscreen(bool fullScreen);
void SetVideoFrame(const BRect& frame);
private: private:
void _DrawBitmap(const BBitmap* bitmap); void _DrawBitmap(const BBitmap* bitmap);
void _AdoptGlobalSettings(); void _AdoptGlobalSettings();
private:
BRect fVideoFrame;
bool fOverlayMode; bool fOverlayMode;
overlay_restrictions fOverlayRestrictions; overlay_restrictions fOverlayRestrictions;
rgb_color fOverlayKeyColor; rgb_color fOverlayKeyColor;