Commit 1ed62904 authored by Eric Petit's avatar Eric Petit

beos/Video*: try to fallback on single-buffered overlay when there's

              not enough VRAM for double-buffered ovelay
parent f9d403e9
...@@ -717,62 +717,81 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode) ...@@ -717,62 +717,81 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode)
_FreeBuffers(); _FreeBuffers();
// set default mode // set default mode
*mode = BITMAP; *mode = BITMAP;
bitmap_count = 3;
BRect bitmapFrame( 0, 0, width, height ); BRect bitmapFrame( 0, 0, width, height );
// read from config, if we are supposed to use overlay at all // read from config, if we are supposed to use overlay at all
int noOverlay = !config_GetInt( p_vout, "overlay" ); int noOverlay = !config_GetInt( p_vout, "overlay" );
// test for overlay capability
for (int i = 0; i < COLOR_COUNT; i++) /* Test for overlay capability: for every chroma in colspace,
we try to do double-buffered overlay, or we fallback on
single-buffered overlay. In nothing worked, we then have
to work with a non-overlay BBitmap. */
for( int i = 0; i < COLOR_COUNT; i++ )
{ {
if (noOverlay) break; if (noOverlay) break;
bitmap[0] = new BBitmap ( bitmapFrame,
B_BITMAP_WILL_OVERLAY |
B_BITMAP_RESERVE_OVERLAY_CHANNEL,
colspace[i].colspace);
if(bitmap[0] && bitmap[0]->InitCheck() == B_OK) bitmap[0] = new BBitmap( bitmapFrame,
B_BITMAP_WILL_OVERLAY |
B_BITMAP_RESERVE_OVERLAY_CHANNEL,
colspace[i].colspace );
if( bitmap[0] && bitmap[0]->InitCheck() == B_OK )
{ {
colspace_index = i; colspace_index = i;
bitmap[1] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY, bitmap[1] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY,
colspace[colspace_index].colspace); colspace[colspace_index].colspace);
bitmap[2] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY, if( bitmap[1] && bitmap[1]->InitCheck() == B_OK )
colspace[colspace_index].colspace);
if ( (bitmap[2] && bitmap[2]->InitCheck() == B_OK) )
{ {
*mode = OVERLAY; *mode = OVERLAY;
rgb_color key; rgb_color key;
view->SetViewOverlay(bitmap[0], view->SetViewOverlay( bitmap[0], bitmap[0]->Bounds(),
bitmap[0]->Bounds() , view->Bounds(), &key, B_FOLLOW_ALL,
view->Bounds(), B_OVERLAY_FILTER_HORIZONTAL |
&key, B_FOLLOW_ALL, B_OVERLAY_FILTER_VERTICAL );
B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL); view->SetViewColor( key );
view->SetViewColor(key); SetTitle( "VLC " PACKAGE_VERSION " (Overlay)" );
SetTitle("VLC " PACKAGE_VERSION " (Overlay)");
break; bitmap[2] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY,
colspace[colspace_index].colspace);
if( bitmap[2] && bitmap[2]->InitCheck() == B_OK )
{
msg_Dbg( p_vout, "using double-buffered overlay" );
}
else
{
msg_Dbg( p_vout, "using single-buffered overlay" );
bitmap_count = 2;
if( bitmap[2] ) delete bitmap[2];
}
break;
} }
else else
{ {
_FreeBuffers(); *mode = BITMAP;
*mode = BITMAP; // might want to try again with normal bitmaps _FreeBuffers();
} }
} }
else else
{
delete bitmap[0]; delete bitmap[0];
}
} }
if (*mode == BITMAP) if (*mode == BITMAP)
{ {
msg_Warn( p_vout, "no possible overlay" );
// fallback to RGB // fallback to RGB
colspace_index = DEFAULT_COL; // B_RGB32 colspace_index = DEFAULT_COL; // B_RGB32
SetTitle( "VLC " PACKAGE_VERSION " (Bitmap)" );
bitmap[0] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); bitmap[0] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace );
bitmap[1] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); bitmap[1] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace );
bitmap[2] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); bitmap[2] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace );
SetTitle( "VLC " PACKAGE_VERSION " (Bitmap)" );
} }
// see if everything went well // see if everything went well
status_t status = B_ERROR; status_t status = B_ERROR;
for (int32_t i = 0; i < 3; i++) for (int32_t i = 0; i < bitmap_count; i++)
{ {
if (bitmap[i]) if (bitmap[i])
status = bitmap[i]->InitCheck(); status = bitmap[i]->InitCheck();
...@@ -782,7 +801,7 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode) ...@@ -782,7 +801,7 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode)
if (status >= B_OK) if (status >= B_OK)
{ {
// clear bitmaps to black // clear bitmaps to black
for (int32_t i = 0; i < 3; i++) for (int32_t i = 0; i < bitmap_count; i++)
_BlankBitmap(bitmap[i]); _BlankBitmap(bitmap[i]);
} }
return status; return status;
...@@ -794,12 +813,9 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode) ...@@ -794,12 +813,9 @@ VideoWindow::_AllocateBuffers(int width, int height, int* mode)
void void
VideoWindow::_FreeBuffers() VideoWindow::_FreeBuffers()
{ {
delete bitmap[0]; if( bitmap[0] ) { delete bitmap[0]; bitmap[0] = NULL; }
bitmap[0] = NULL; if( bitmap[1] ) { delete bitmap[1]; bitmap[1] = NULL; }
delete bitmap[1]; if( bitmap[2] ) { delete bitmap[2]; bitmap[2] = NULL; }
bitmap[1] = NULL;
delete bitmap[2];
bitmap[2] = NULL;
fInitStatus = B_ERROR; fInitStatus = B_ERROR;
} }
...@@ -1448,7 +1464,9 @@ int Init( vout_thread_t *p_vout ) ...@@ -1448,7 +1464,9 @@ int Init( vout_thread_t *p_vout )
p_vout->output.i_gmask = 0x0000ff00; p_vout->output.i_gmask = 0x0000ff00;
p_vout->output.i_bmask = 0x000000ff; p_vout->output.i_bmask = 0x000000ff;
for (int buffer_index = 0 ; buffer_index < 3; buffer_index++) for( int buffer_index = 0 ;
buffer_index < p_vout->p_sys->p_window->bitmap_count;
buffer_index++ )
{ {
p_pic = NULL; p_pic = NULL;
/* Find an empty picture slot */ /* Find an empty picture slot */
...@@ -1536,7 +1554,8 @@ void Display( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -1536,7 +1554,8 @@ void Display( vout_thread_t *p_vout, picture_t *p_pic )
p_win->drawBuffer(p_vout->p_sys->i_index); p_win->drawBuffer(p_vout->p_sys->i_index);
} }
/* change buffer */ /* change buffer */
p_vout->p_sys->i_index = ++p_vout->p_sys->i_index % 3; p_vout->p_sys->i_index = ++p_vout->p_sys->i_index %
p_vout->p_sys->p_window->bitmap_count;
p_pic->p->p_pixels = (uint8_t*)p_vout->p_sys->p_window->bitmap[p_vout->p_sys->i_index]->Bits(); p_pic->p->p_pixels = (uint8_t*)p_vout->p_sys->p_window->bitmap[p_vout->p_sys->i_index]->Bits();
} }
......
...@@ -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.11 2003/12/28 01:49:12 titer Exp $ * $Id$
* *
* 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>
...@@ -178,6 +178,7 @@ public: ...@@ -178,6 +178,7 @@ public:
volatile bool teardownwindow; volatile bool teardownwindow;
thread_id fDrawThreadID; thread_id fDrawThreadID;
int mode; int mode;
int bitmap_count;
int colspace_index; int colspace_index;
private: private:
......
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