Commit f6451da5 authored by Tony Castley's avatar Tony Castley

Tidied code and prevented curruption on window not containing the video.

Video window now returns to correct size and position after toggling
full screen.
parent 2f4af9df
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* VideoWindow.h: BeOS video window class prototype * VideoWindow.h: BeOS video window class prototype
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: VideoWindow.h,v 1.10 2002/03/13 08:39:39 tcastley Exp $ * $Id: VideoWindow.h,v 1.11 2002/03/17 05:48:18 tcastley Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Tony Castley <tcastley@mail.powerup.com.au> * Tony Castley <tcastley@mail.powerup.com.au>
...@@ -29,6 +29,7 @@ public: ...@@ -29,6 +29,7 @@ public:
~VLCView(); ~VLCView();
void MouseDown(BPoint point); void MouseDown(BPoint point);
void Draw(BRect updateRect);
}; };
...@@ -40,16 +41,14 @@ public: ...@@ -40,16 +41,14 @@ public:
struct vout_thread_s *p_video_output); struct vout_thread_s *p_video_output);
~VideoWindow(); ~VideoWindow();
void resizeIfRequired(int newWidth, int newHeight);
void drawBuffer(int bufferIndex); void drawBuffer(int bufferIndex);
// this is the hook controling direct screen connection // this is the hook controling direct screen connection
int32 i_width; // incomming bitmap size int32 i_width; // incomming bitmap size
int32 i_height; int32 i_height;
float f_w_width; // current window size BRect winSize; // current window size
float f_w_height; float width_scale, height_scale;
bool resized; bool is_zoomed, resized;
bool is_zoomed;
BBitmap *bitmap[2]; BBitmap *bitmap[2];
VLCView *view; VLCView *view;
BWindow *voutWindow; BWindow *voutWindow;
...@@ -72,8 +71,6 @@ public: ...@@ -72,8 +71,6 @@ public:
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
virtual void Zoom(BPoint origin, float width, float height); virtual void Zoom(BPoint origin, float width, float height);
private: private:
bool is_zoomed;
BRect origRect;
VideoWindow *owner; VideoWindow *owner;
}; };
...@@ -90,7 +87,5 @@ public: ...@@ -90,7 +87,5 @@ public:
virtual void Zoom(BPoint origin, float width, float height); virtual void Zoom(BPoint origin, float width, float height);
virtual void DirectConnected(direct_buffer_info *info); virtual void DirectConnected(direct_buffer_info *info);
private: private:
bool is_zoomed;
BRect origRect;
VideoWindow *owner; VideoWindow *owner;
}; };
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_beos.cpp: beos video output display method * vout_beos.cpp: beos video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: vout_beos.cpp,v 1.45 2002/03/16 23:03:19 sam Exp $ * $Id: vout_beos.cpp,v 1.46 2002/03/17 05:48:18 tcastley Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -97,99 +97,82 @@ BWindow *beos_GetAppWindow(char *name) ...@@ -97,99 +97,82 @@ BWindow *beos_GetAppWindow(char *name)
} }
/**************************************************************************** /****************************************************************************
* DrawingThread : thread that really does the drawing * Modify Refresh : code to detect refresh changes
****************************************************************************/ ****************************************************************************/
int32 Draw(void *data) void waitForRefreshIfRequired(BScreen *screen)
{ {
//rudolf: sync init: //rudolf: sync init:
BScreen *screen;
display_mode disp_mode; display_mode disp_mode;
static uint32 refresh, oldrefresh = 0; static uint32 refresh, oldrefresh = 0;
static float out_top, out_left, out_height, out_width;
screen = new BScreen();
screen-> GetMode(&disp_mode); screen-> GetMode(&disp_mode);
refresh = refresh =
(disp_mode.timing.pixel_clock * 1000)/((disp_mode.timing.h_total)* (disp_mode.timing.pixel_clock * 1000)/((disp_mode.timing.h_total)*
(disp_mode.timing.v_total)); (disp_mode.timing.v_total));
if (!(refresh == oldrefresh)) if (!(refresh == oldrefresh))
{ {
intf_WarnMsg( 1, "vout info: new refreshrate is %ld:Hz", refresh );
oldrefresh = refresh; oldrefresh = refresh;
if (refresh < 61 )
{
intf_WarnMsg( 1, "vout info: enabling retrace sync" );
}
else
{
intf_WarnMsg( 1, "vout info: disabling retrace sync" );
}
} }
//rudolf: sync:
if (refresh < 61)
{
screen-> WaitForRetrace(22000);//set timeout for < 45 Hz...
}
}
/****************************************************************************
* DrawingThread : thread that really does the drawing
****************************************************************************/
int32 Draw(void *data)
{
static float out_top, out_left, out_height, out_width;
BScreen *screen;
VideoWindow* p_win; VideoWindow* p_win;
screen = new BScreen();
p_win = (VideoWindow *) data; p_win = (VideoWindow *) data;
if ( p_win-> voutWindow-> LockLooper() ) if ( p_win-> voutWindow-> LockLooper() )
{ {
//rudolf: sync: waitForRefreshIfRequired(screen);
if (refresh < 61)
{
screen-> WaitForRetrace(22000);//set timeout for < 45 Hz...
}
if (p_win->resized) if (p_win->resized)
{ {
float width_scale = 1; p_win->resized = false;
float height_scale = 1; p_win-> view-> FillRect(p_win-> voutWindow-> Bounds());
/* if the width is proportionally smaller */
p_win->resized = false; if (p_win->width_scale <= p_win->height_scale)
{
if (p_win-> is_zoomed) out_width = p_win->i_width * p_win->width_scale;
{ out_height = p_win->i_height * p_win->width_scale;
width_scale = screen-> Frame().Width() / p_win->i_width; out_left = 0;
height_scale = screen-> Frame().Height() / p_win->i_height; if (p_win-> is_zoomed)
} {
else out_top = (screen-> Frame().Height() - out_height) / 2;
{ }
width_scale = p_win->f_w_width / p_win->i_width; else
height_scale = p_win->f_w_height / p_win->i_height; {
} out_top = (p_win->winSize.Height() - out_height) / 2;
}
/* if the width is proportionally smaller */ }
if (width_scale <= height_scale) else /* if the height is proportionally smaller */
{ {
out_width = p_win->i_width * width_scale; out_width = p_win->i_width * p_win->height_scale;
out_height = p_win->i_height * width_scale; out_height = p_win->i_height * p_win->height_scale;
out_left = 0; out_top = 0;
if (p_win-> is_zoomed) if (p_win-> is_zoomed)
{ {
out_top = (screen-> Frame().Height() - out_height) / 2; out_left = (screen-> Frame().Width() - out_width) / 2;
} }
else else
{ {
out_top = (p_win->f_w_height - out_height) / 2; out_left = (p_win->winSize.Width() - out_width) /2;
} }
} }
else /* if the height is proportionally smaller */ }
{ p_win-> view-> DrawBitmap( p_win-> bitmap[p_win-> i_buffer],
out_width = p_win->i_width * height_scale; BRect(out_left, out_top,
out_height = p_win->i_height * height_scale; out_left + out_width, out_top + out_height) );
out_top = 0; p_win-> voutWindow-> UnlockLooper();
if (p_win-> is_zoomed)
{
out_left = (screen-> Frame().Width() - out_width) / 2;
}
else
{
out_left = (p_win->f_w_width - out_width) /2;
}
}
p_win-> view-> FillRect(p_win-> voutWindow-> Bounds());
}
p_win-> view-> DrawBitmap( p_win-> bitmap[p_win-> i_buffer],
BRect(out_left, out_top,
out_left + out_width, out_top + out_height) );
p_win-> voutWindow-> UnlockLooper();
} }
return B_OK; return B_OK;
} }
...@@ -201,8 +184,11 @@ bitmapWindow::bitmapWindow(BRect frame, VideoWindow *theOwner) ...@@ -201,8 +184,11 @@ bitmapWindow::bitmapWindow(BRect frame, VideoWindow *theOwner)
: BWindow( frame, NULL, B_TITLED_WINDOW, : BWindow( frame, NULL, B_TITLED_WINDOW,
B_NOT_CLOSABLE | B_NOT_MINIMIZABLE ) B_NOT_CLOSABLE | B_NOT_MINIMIZABLE )
{ {
origRect = frame;
owner = theOwner; owner = theOwner;
owner->winSize = frame;
owner->width_scale = frame.Width() / owner->i_width;
owner->height_scale = frame.Height() / owner->i_height;
owner->resized = true;
SetTitle(VOUT_TITLE " (BBitmap output)"); SetTitle(VOUT_TITLE " (BBitmap output)");
} }
...@@ -212,8 +198,9 @@ bitmapWindow::~bitmapWindow() ...@@ -212,8 +198,9 @@ bitmapWindow::~bitmapWindow()
void bitmapWindow::FrameResized( float width, float height ) void bitmapWindow::FrameResized( float width, float height )
{ {
owner->f_w_width = width; owner->winSize = Frame();
owner->f_w_height = height; owner->width_scale = width / owner->i_width;
owner->height_scale = height / owner->i_height;
owner->resized = true; owner->resized = true;
} }
...@@ -221,8 +208,10 @@ void bitmapWindow::Zoom(BPoint origin, float width, float height ) ...@@ -221,8 +208,10 @@ void bitmapWindow::Zoom(BPoint origin, float width, float height )
{ {
if(owner-> is_zoomed) if(owner-> is_zoomed)
{ {
MoveTo(origRect.left, origRect.top); MoveTo(owner->winSize.left, owner->winSize.top);
ResizeTo(origRect.IntegerWidth(), origRect.IntegerHeight()); ResizeTo(owner->winSize.IntegerWidth(), owner->winSize.IntegerHeight());
owner->width_scale = owner->winSize.IntegerWidth() / owner->i_width;
owner->height_scale = owner->winSize.IntegerHeight() / owner->i_height;
be_app->ShowCursor(); be_app->ShowCursor();
} }
else else
...@@ -233,10 +222,12 @@ void bitmapWindow::Zoom(BPoint origin, float width, float height ) ...@@ -233,10 +222,12 @@ void bitmapWindow::Zoom(BPoint origin, float width, float height )
delete screen; delete screen;
MoveTo(0,0); MoveTo(0,0);
ResizeTo(rect.IntegerWidth(), rect.IntegerHeight()); ResizeTo(rect.IntegerWidth(), rect.IntegerHeight());
owner->width_scale = rect.IntegerWidth() / owner->i_width;
owner->height_scale = rect.IntegerHeight() / owner->i_height;
be_app->HideCursor(); be_app->HideCursor();
} }
owner-> resized = true;
owner-> is_zoomed = !owner-> is_zoomed; owner-> is_zoomed = !owner-> is_zoomed;
owner->resized = true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -246,8 +237,11 @@ directWindow::directWindow(BRect frame, VideoWindow *theOwner) ...@@ -246,8 +237,11 @@ directWindow::directWindow(BRect frame, VideoWindow *theOwner)
: BDirectWindow( frame, NULL, B_TITLED_WINDOW, : BDirectWindow( frame, NULL, B_TITLED_WINDOW,
B_NOT_CLOSABLE | B_NOT_MINIMIZABLE ) B_NOT_CLOSABLE | B_NOT_MINIMIZABLE )
{ {
origRect = frame;
owner = theOwner; owner = theOwner;
owner->winSize = frame;
owner->width_scale = frame.Width() / owner->i_width;
owner->height_scale = frame.Height() / owner->i_height;
owner->resized = true;
SetTitle(VOUT_TITLE " (DirectWindow output)"); SetTitle(VOUT_TITLE " (DirectWindow output)");
} }
...@@ -261,8 +255,9 @@ void directWindow::DirectConnected(direct_buffer_info *info) ...@@ -261,8 +255,9 @@ void directWindow::DirectConnected(direct_buffer_info *info)
void directWindow::FrameResized( float width, float height ) void directWindow::FrameResized( float width, float height )
{ {
owner->f_w_width = width; owner->winSize = Frame();
owner->f_w_height = height; owner->width_scale = width / owner->i_width;
owner->height_scale = height / owner->i_height;
owner->resized = true; owner->resized = true;
} }
...@@ -271,23 +266,28 @@ void directWindow::Zoom(BPoint origin, float width, float height ) ...@@ -271,23 +266,28 @@ void directWindow::Zoom(BPoint origin, float width, float height )
if(owner-> is_zoomed) if(owner-> is_zoomed)
{ {
SetFullScreen(false); SetFullScreen(false);
MoveTo(origRect.left, origRect.top); MoveTo(owner->winSize.left, owner->winSize.top);
ResizeTo(origRect.IntegerWidth(), origRect.IntegerHeight()); ResizeTo(owner->winSize.Width(), owner->winSize.Height());
owner->width_scale = owner->winSize.Width() / owner->i_width;
owner->height_scale = owner->winSize.Height() / owner->i_height;
be_app->ShowCursor(); be_app->ShowCursor();
} }
else else
{ {
owner->winSize = Frame();
SetFullScreen(true); SetFullScreen(true);
BScreen *screen; BScreen *screen;
screen = new BScreen(this); screen = new BScreen(this);
BRect rect = screen->Frame(); BRect rect = screen->Frame();
delete screen; delete screen;
MoveTo(0,0); MoveTo(0,0);
ResizeTo(rect.IntegerWidth(), rect.IntegerHeight()); ResizeTo(rect.Width(), rect.Height());
owner->width_scale = rect.Width() / owner->i_width;
owner->height_scale = rect.Height() / owner->i_height;
be_app->HideCursor(); be_app->HideCursor();
} }
owner->resized = true;
owner-> is_zoomed = !owner-> is_zoomed; owner-> is_zoomed = !owner-> is_zoomed;
owner->resized = true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -326,8 +326,9 @@ VideoWindow::VideoWindow( int width, int height, ...@@ -326,8 +326,9 @@ VideoWindow::VideoWindow( int width, int height,
i_width = bitmap[0]->Bounds().IntegerWidth(); i_width = bitmap[0]->Bounds().IntegerWidth();
i_height = bitmap[0]->Bounds().IntegerHeight(); i_height = bitmap[0]->Bounds().IntegerHeight();
f_w_width = voutWindow->Bounds().Width(); winSize = voutWindow->Frame();
f_w_height = voutWindow->Bounds().Height(); width_scale = winSize.Width() / i_width;
height_scale = winSize.Height() / i_height;
voutWindow->Show(); voutWindow->Show();
} }
...@@ -336,33 +337,16 @@ VideoWindow::~VideoWindow() ...@@ -336,33 +337,16 @@ VideoWindow::~VideoWindow()
{ {
int32 result; int32 result;
teardownwindow = true;
wait_for_thread(fDrawThreadID, &result);
voutWindow->Hide(); voutWindow->Hide();
voutWindow->Sync(); voutWindow->Sync();
voutWindow->Lock(); voutWindow->Lock();
voutWindow->Quit(); voutWindow->Quit();
teardownwindow = true;
wait_for_thread(fDrawThreadID, &result);
delete bitmap[0]; delete bitmap[0];
delete bitmap[1]; delete bitmap[1];
} }
void VideoWindow::resizeIfRequired( int newWidth, int newHeight )
{
if (( newWidth != i_width + 1) &&
( newHeight != i_height + 1) &&
( newWidth != 0 ))
{
if ( voutWindow->Lock() )
{
view->ClearViewBitmap();
i_width = newWidth - 1;
i_height = newHeight -1;
voutWindow->ResizeTo((float) i_width, (float) i_height);
voutWindow->Unlock();
}
}
}
void VideoWindow::drawBuffer(int bufferIndex) void VideoWindow::drawBuffer(int bufferIndex)
{ {
status_t status; status_t status;
...@@ -390,7 +374,7 @@ VLCView::~VLCView() ...@@ -390,7 +374,7 @@ VLCView::~VLCView()
} }
/***************************************************************************** /*****************************************************************************
* VLCVIew::~VLCView * VLCVIew::MouseDown
*****************************************************************************/ *****************************************************************************/
void VLCView::MouseDown(BPoint point) void VLCView::MouseDown(BPoint point)
{ {
...@@ -398,6 +382,15 @@ void VLCView::MouseDown(BPoint point) ...@@ -398,6 +382,15 @@ void VLCView::MouseDown(BPoint point)
win->Zoom(); win->Zoom();
} }
/*****************************************************************************
* VLCVIew::Draw
*****************************************************************************/
void VLCView::Draw(BRect updateRect)
{
FillRect(updateRect);
}
extern "C" extern "C"
{ {
...@@ -479,6 +472,9 @@ int vout_Init( vout_thread_t *p_vout ) ...@@ -479,6 +472,9 @@ int vout_Init( vout_thread_t *p_vout )
return 0; return 0;
} }
p_vout->p_sys->pp_buffer[0] = (u8*)p_vout->p_sys->p_window->bitmap[0]->Bits();
p_vout->p_sys->pp_buffer[1] = (u8*)p_vout->p_sys->p_window->bitmap[1]->Bits();
p_vout->output.i_width = p_vout->p_sys->i_width; p_vout->output.i_width = p_vout->p_sys->i_width;
p_vout->output.i_height = p_vout->p_sys->i_height; p_vout->output.i_height = p_vout->p_sys->i_height;
p_vout->output.i_aspect = p_vout->p_sys->i_width p_vout->output.i_aspect = p_vout->p_sys->i_width
...@@ -551,11 +547,7 @@ void vout_Destroy( vout_thread_t *p_vout ) ...@@ -551,11 +547,7 @@ void vout_Destroy( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
int vout_Manage( vout_thread_t *p_vout ) int vout_Manage( vout_thread_t *p_vout )
{ {
// VideoWindow * p_win = p_vout->p_sys->p_window;
// p_win->resizeIfRequired(p_vout->p_sys->pp_buffer[p_vout->p_sys->i_index].i_pic_width,
// p_vout->p_sys->pp_buffer[p_vout->p_sys->i_index].i_pic_height);
return( 0 ); return( 0 );
} }
...@@ -604,12 +596,6 @@ static int BeosOpenDisplay( vout_thread_t *p_vout ) ...@@ -604,12 +596,6 @@ static int BeosOpenDisplay( vout_thread_t *p_vout )
return( 1 ); return( 1 );
} }
p_vout->p_sys->i_width = p_vout->p_sys->p_window->i_width + 1;
p_vout->p_sys->i_height = p_vout->p_sys->p_window->i_height + 1;
p_vout->p_sys->pp_buffer[0] = (u8*)p_vout->p_sys->p_window->bitmap[0]->Bits();
p_vout->p_sys->pp_buffer[1] = (u8*)p_vout->p_sys->p_window->bitmap[1]->Bits();
return( 0 ); return( 0 );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment