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:
parent
4edcbff706
commit
ee891c8828
@ -1666,11 +1666,16 @@ MainWin::_ResizeVideoView(int x, int y, int width, int height)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 Stephan Aßmus <superstippi@gmx.de>
|
||||
* Copyright 2006-2010 Stephan Aßmus <superstippi@gmx.de>
|
||||
* 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 @@ VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask)
|
||||
:
|
||||
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 @@ VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask)
|
||||
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 @@ VideoView::~VideoView()
|
||||
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 @@ VideoView::SetBitmap(const BBitmap* bitmap)
|
||||
// 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 @@ VideoView::SetBitmap(const BBitmap* bitmap)
|
||||
} 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 @@ 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 -
|
||||
|
||||
|
||||
@ -278,9 +294,9 @@ VideoView::_DrawBitmap(const BBitmap* bitmap)
|
||||
{
|
||||
#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
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 Stephan Aßmus <superstippi@gmx.de>
|
||||
* Copyright 2006-2010 Stephan Aßmus <superstippi@gmx.de>
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*/
|
||||
#ifndef VIDEO_VIEW_H
|
||||
@ -46,11 +46,14 @@ public:
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user