Commit 4f553677 authored by Vincent Seguin's avatar Vincent Seguin

IMPORTANT:

	p_vout->i_depth est maintenant la profondeur SIGNIFICATIVE de
		l'�cran (8, 15, 16 ou 24)
	p_vout->i_bytes_per_pixel est la profondeur r�elle (1, 2, 3 ou 4)

Ajout du calcul des d�calages � video_output.
Refonte de l'initialisation des tables.
D�tection correcte des profondeurs 24/24 et 24/32 en X11
Correction de bugs dans le scaling en 1, 3 et 4 Bpp.
R�cup�ration des masques depuis le materiel en X11 et GGI.

FrameBuffer cass� pour le moment: il faut rajouter les masques de couleur
(des valeurs par d�faut sont au d�but de video_yuv.c) et le calcul des
nouvelles profondeurs d'�cran.
parent fb0eb672
......@@ -103,10 +103,27 @@ typedef struct vout_thread_s
int i_width; /* current output method width */
int i_height; /* current output method height */
int i_bytes_per_line; /* bytes per line (incl. virtual) */
int i_screen_depth; /* bits per pixel */
int i_bytes_per_pixel; /* real screen depth */
int i_screen_depth; /* significant bpp: 8, 15, 16 or 24 */
int i_bytes_per_pixel; /* real screen depth: 1, 2, 3 or 4 */
float f_gamma; /* gamma */
/* Color masks and shifts in RGB mode - masks are set by system
* initialization, shifts are calculated. A pixel color value can be
* obtained using the formula ((value >> rshift) << lshift) */
u32 i_red_mask; /* red mask */
u32 i_green_mask; /* green mask */
u32 i_blue_mask; /* blue mask */
int i_red_lshift, i_red_rshift; /* red shifts */
int i_green_lshift, i_green_rshift; /* green shifts */
int i_blue_lshift, i_blue_rshift; /* blue shifts */
/* Usefull pre-calculated pixel values - these are not supposed to be
* accurate values, but rather values looking nice, given their usage. */
u32 i_white_pixel; /* white */
u32 i_black_pixel; /* black */
u32 i_gray_pixel; /* gray */
u32 i_blue_pixel; /* blue */
/* Pictures and rendering properties */
boolean_t b_grayscale; /* color or grayscale display */
boolean_t b_info; /* print additionnal informations */
......@@ -151,6 +168,17 @@ typedef struct vout_thread_s
#define VOUT_YUV_CHANGE 0x0800 /* change yuv tables */
#define VOUT_NODISPLAY_CHANGE 0xff00 /* changes which forbidden display */
/*******************************************************************************
* Macros
*******************************************************************************/
/* RGB2PIXEL: assemble RGB components to a pixel value, returns a u32 */
#define RGB2PIXEL( p_vout, i_red, i_green, i_blue ) \
(((((u32)i_red) >> p_vout->i_red_rshift) << p_vout->i_red_lshift) | \
((((u32)i_green) >> p_vout->i_green_rshift) << p_vout->i_green_lshift) | \
((((u32)i_blue) >> p_vout->i_blue_rshift) << p_vout->i_blue_lshift))
/*******************************************************************************
* Prototypes
*******************************************************************************/
......@@ -169,3 +197,4 @@ void vout_DestroySubPicture ( vout_thread_t *p_vout, subpicture_t *p
void vout_DisplaySubPicture ( vout_thread_t *p_vout, subpicture_t *p_subpic );
void vout_SetBuffers ( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 );
......@@ -119,6 +119,7 @@ void vout_SysDestroy( vout_thread_t *p_vout )
*******************************************************************************/
int vout_SysManage( vout_thread_t *p_vout )
{
//?? 8bpp: change palette
return( 0 );
}
......@@ -286,32 +287,13 @@ static int GGIOpenDisplay( vout_thread_t *p_vout, char *psz_display )
p_vout->i_width = mode.visible.x;
p_vout->i_height = mode.visible.y;
p_vout->i_bytes_per_line = p_vout->p_sys->p_buffer[ 0 ]->buffer.plb.stride;
switch( mode.graphtype )
{
case GT_15BIT:
p_vout->i_screen_depth = 15;
p_vout->i_bytes_per_pixel = 2;
break;
case GT_16BIT:
p_vout->i_screen_depth = 16;
p_vout->i_bytes_per_pixel = 2;
break;
case GT_24BIT:
p_vout->i_screen_depth = 24;
p_vout->i_bytes_per_pixel = 3;
break;
case GT_32BIT:
p_vout->i_screen_depth = 32;
p_vout->i_bytes_per_pixel = 4;
break;
default:
intf_ErrMsg("error: unsupported screen depth\n");
ggiClose( p_vout->p_sys->p_display );
ggiExit();
return( 1 );
break;
}
p_vout->i_screen_depth = p_vout->p_sys->p_buffer[ 0 ]->buffer.plb->pixelformat.depth;
p_vout->i_bytes_per_pixel = p_vout->p_sys->p_buffer[ 0 ]->buffer.plb->pixelformat.size / 8;
p_vout->i_red_mask = p_vout->p_sys->p_buffer[ 0 ]->buffer.plb->pixelformat.red_mask;
p_vout->i_green_mask = p_vout->p_sys->p_buffer[ 0 ]->buffer.plb->pixelformat.green_mask;
p_vout->i_blue_mask = p_vout->p_sys->p_buffer[ 0 ]->buffer.plb->pixelformat.blue_mask;
//?? palette in 8bpp
/* Set and initialize buffers */
vout_SetBuffers( p_vout, p_vout->p_sys->p_buffer[ 0 ]->write, p_vout->p_sys->p_buffer[ 1 ]->write );
......
......@@ -30,6 +30,8 @@
/******************************************************************************
* Local prototypes
******************************************************************************/
static int BinaryLog ( u32 i );
static void MaskToShift ( int *pi_left, int *pi_right, u32 i_mask );
static int InitThread ( vout_thread_t *p_vout );
static void RunThread ( vout_thread_t *p_vout );
static void ErrorThread ( vout_thread_t *p_vout );
......@@ -95,15 +97,14 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_
p_vout->i_bytes_per_pixel = 2;
p_vout->f_gamma = VOUT_GAMMA;
p_vout->b_grayscale = main_GetIntVariable( VOUT_GRAYSCALE_VAR,
VOUT_GRAYSCALE_DEFAULT );
p_vout->b_grayscale = main_GetIntVariable( VOUT_GRAYSCALE_VAR, VOUT_GRAYSCALE_DEFAULT );
p_vout->b_info = 0;
p_vout->b_interface = 0;
p_vout->b_scale = 0;
intf_DbgMsg("wished configuration: %dx%d,%d (%d bytes/pixel, %d bytes/line)\n",
intf_DbgMsg("wished configuration: %dx%d, %d/%d bpp (%d Bpl)\n",
p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line );
p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line );
/* Initialize idle screen */
p_vout->last_display_date = mdate();
......@@ -135,9 +136,21 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_
free( p_vout );
return( NULL );
}
intf_DbgMsg("actual configuration: %dx%d,%d (%d bytes/pixel, %d bytes/line)\n",
intf_DbgMsg("actual configuration: %dx%d, %d/%d bpp (%d Bpl), masks: 0x%x/0x%x/0x%x\n",
p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line );
p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
p_vout->i_red_mask, p_vout->i_green_mask, p_vout->i_blue_mask );
/* Calculate shifts from system-updated masks */
MaskToShift( &p_vout->i_red_lshift, &p_vout->i_red_rshift, p_vout->i_red_mask );
MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift, p_vout->i_green_mask );
MaskToShift( &p_vout->i_blue_lshift, &p_vout->i_blue_rshift, p_vout->i_blue_mask );
/* Set some usefull colors */
p_vout->i_white_pixel = RGB2PIXEL( p_vout, 255, 255, 255 );
p_vout->i_black_pixel = RGB2PIXEL( p_vout, 0, 0, 0 );
p_vout->i_gray_pixel = RGB2PIXEL( p_vout, 128, 128, 128 );
p_vout->i_blue_pixel = RGB2PIXEL( p_vout, 0, 0, 50 );
/* Load fonts - fonts must be initialized after the systme method since
* they may be dependant of screen depth and other thread properties */
......@@ -172,8 +185,8 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_
return( NULL );
}
intf_Msg("Video display initialized (%dx%d, %d bpp)\n",
p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth );
intf_Msg("Video display initialized (%dx%d, %d/%d bpp)\n", p_vout->i_width,
p_vout->i_height, p_vout->i_screen_depth, p_vout->i_bytes_per_pixel * 8 );
/* If status is NULL, wait until the thread is created */
if( pi_status == NULL )
......@@ -717,8 +730,82 @@ void vout_SetBuffers( vout_thread_t *p_vout, void *p_buf1, void *p_buf2 )
p_vout->p_buffer[1].p_data = p_buf2;
}
/*****************************************************************************
* vout_Pixel2RGB: return red, green and blue from pixel value
*****************************************************************************
* Return color values, in 0-255 range, of the decomposition of a pixel. This
* is a slow routine and should only be used for initialization phase.
*****************************************************************************/
void vout_Pixel2RGB( vout_thread_t *p_vout, u32 i_pixel, int *pi_red, int *pi_green, int *pi_blue )
{
*pi_red = i_pixel & p_vout->i_red_mask;
*pi_green = i_pixel & p_vout->i_green_mask;
*pi_blue = i_pixel & p_vout->i_blue_mask;
}
/* following functions are local */
/*****************************************************************************
* BinaryLog: computes the base 2 log of a binary value
*****************************************************************************
* This functions is used by MaskToShift, to get a bit index from a binary
* value.
*****************************************************************************/
static int BinaryLog(u32 i)
{
int i_log;
i_log = 0;
if (i & 0xffff0000)
{
i_log = 16;
}
if (i & 0xff00ff00)
{
i_log += 8;
}
if (i & 0xf0f0f0f0)
{
i_log += 4;
}
if (i & 0xcccccccc)
{
i_log += 2;
}
if (i & 0xaaaaaaaa)
{
i_log++;
}
if (i != ((u32)1 << i_log))
{
intf_ErrMsg("internal error: binary log overflow\n");
}
return( i_log );
}
/*****************************************************************************
* MaskToShift: transform a color mask into right and left shifts
*****************************************************************************
* This function is used for obtaining color shifts from masks.
*****************************************************************************/
static void MaskToShift( int *pi_left, int *pi_right, u32 i_mask )
{
u32 i_low, i_high; /* lower hand higher bits of the mask */
/* Get bits */
i_low = i_mask & (- i_mask); /* lower bit of the mask */
i_high = i_mask + i_low; /* higher bit of the mask */
/* Transform bits into an index */
i_low = BinaryLog (i_low);
i_high = BinaryLog (i_high);
/* Update pointers and return */
*pi_left = i_low;
*pi_right = (8 - i_high + i_low);
}
/******************************************************************************
* InitThread: initialize video output thread
******************************************************************************
......@@ -1093,7 +1180,8 @@ void Print( vout_thread_t *p_vout, int i_x, int i_y, int i_h_align, int i_v_alig
vout_Print( p_vout->p_default_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
i_y * p_vout->i_bytes_per_line + i_x * p_vout->i_bytes_per_pixel,
p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
0xffffffff, 0x00000000, 0x00000000, 0, psz_text );
p_vout->i_white_pixel, 0, 0,
0, psz_text );
}
}
......@@ -1397,34 +1485,6 @@ static void SetBufferPicture( vout_thread_t *p_vout, picture_t *p_pic )
* Clear areas array
*/
p_buffer->i_areas = 0;
#ifdef DEBUG_VIDEO
/*
* In DEBUG_VIDEO mode, draw white pixels at the beginning and the end of
* the picture area. These pixels should not be erased by rendering functions,
* otherwise segmentation fault is menacing !
*/
if( i_pic_x > 0 )
{
*(u16*)(p_buffer->p_data + p_vout->i_bytes_per_line * i_pic_y +
p_vout->i_bytes_per_pixel * (i_pic_x - 1)) = 0xffff;
}
if( i_pic_y > 0 )
{
*(u16*)(p_buffer->p_data + p_vout->i_bytes_per_line * (i_pic_y - 1) +
p_vout->i_bytes_per_pixel * i_pic_x ) = 0xffff;
}
if( i_pic_x + i_pic_width < p_vout->i_width )
{
*(u16*)(p_buffer->p_data + p_vout->i_bytes_per_line * (i_pic_y + i_pic_height - 1) +
p_vout->i_bytes_per_pixel * (i_pic_x + i_pic_width) ) = 0xffff;
}
if( i_pic_y + i_pic_height < p_vout->i_height )
{
*(u16*)(p_buffer->p_data + p_vout->i_bytes_per_line * (i_pic_y + i_pic_height) +
p_vout->i_bytes_per_pixel * (i_pic_x + i_pic_width - 1) ) = 0xffff;
}
#endif
}
/******************************************************************************
......@@ -1583,7 +1643,7 @@ static int RenderIdle( vout_thread_t *p_vout )
p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
i_x * p_vout->i_bytes_per_pixel + i_y * p_vout->i_bytes_per_line,
p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
0xffffffff, 0x33333333, 0,
p_vout->i_white_pixel, p_vout->i_gray_pixel, 0,
WIDE_TEXT | OUTLINED_TEXT, psz_text );
SetBufferArea( p_vout, i_x, i_y, i_width, i_height );
}
......@@ -1683,7 +1743,7 @@ static void RenderInterface( vout_thread_t *p_vout )
{
int i_height, i_text_height; /* total and text height */
int i_width_1, i_width_2; /* text width */
int i_byte; /* byte index */
int i_byte; /* byte index */
const char *psz_text_1 = "[1-9] Channel [i]nfo [c]olor [g/G]amma";
const char *psz_text_2 = "[+/-] Volume [m]ute [s]caling [Q]uit";
......@@ -1692,13 +1752,13 @@ static void RenderInterface( vout_thread_t *p_vout )
vout_TextSize( p_vout->p_large_font, OUTLINED_TEXT, psz_text_2, &i_width_2, &i_text_height );
i_height += i_text_height;
/* Render background - effective background color will depend of the screen
* depth */
/* Render background */
for( i_byte = (p_vout->i_height - i_height) * p_vout->i_bytes_per_line;
i_byte < p_vout->i_height * p_vout->i_bytes_per_line;
i_byte++ )
{
p_vout->p_buffer[ p_vout->i_buffer_index ].p_data[ i_byte ] = 0x33;
//?? noooo !
p_vout->p_buffer[ p_vout->i_buffer_index ].p_data[ i_byte ] = p_vout->i_blue_pixel;
}
/* Render text, if not larger than screen */
......@@ -1707,7 +1767,7 @@ static void RenderInterface( vout_thread_t *p_vout )
vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
(p_vout->i_height - i_height) * p_vout->i_bytes_per_line,
p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
0xffffffff, 0x00000000, 0x00000000,
p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
OUTLINED_TEXT, psz_text_1 );
}
if( i_width_2 < p_vout->i_width )
......@@ -1715,7 +1775,7 @@ static void RenderInterface( vout_thread_t *p_vout )
vout_Print( p_vout->p_large_font, p_vout->p_buffer[ p_vout->i_buffer_index ].p_data +
(p_vout->i_height - i_height + i_text_height) * p_vout->i_bytes_per_line,
p_vout->i_bytes_per_pixel, p_vout->i_bytes_per_line,
0xffffffff, 0x00000000, 0x00000000,
p_vout->i_white_pixel, p_vout->i_black_pixel, 0,
OUTLINED_TEXT, psz_text_2 );
}
......
......@@ -60,8 +60,9 @@ typedef void (vout_put_byte_t)( void *p_pic, int i_byte, int i_char, int i_borde
*******************************************************************************/
/* PUT_BYTE_MASK: put pixels from a byte-wide mask. It uses a branching tree
* to optimize the number of tests. It is used in the PutByte functions. */
#define TREE( i_mask, i_mask_color ) \
* to optimize the number of tests. It is used in the PutByte functions.
* This macro works for 1, 2 and 4 Bpp. */
#define PUT_BYTE_MASK( i_mask, i_mask_color ) \
if( i_mask & 0xf0 ) /* one from 1111 */ \
{ \
if( i_mask & 0xc0 ) /* one from 1100 */ \
......@@ -364,17 +365,9 @@ void vout_Print( vout_font_t *p_font, byte_t *p_pic, int i_bytes_per_pixel, int
p_PutByte = (vout_put_byte_t *) PutByte24;
break;
case 4:
#ifndef DEBUG
default:
#endif
p_PutByte = (vout_put_byte_t *) PutByte32;
break;
#ifdef DEBUG
default:
intf_DbgMsg("error: invalid bytes per pixel %d\n", i_bytes_per_pixel );
p_PutByte = NULL;
break;
#endif
}
/* Choose masks and copy font data to local variables */
......@@ -447,7 +440,7 @@ void vout_Print( vout_font_t *p_font, byte_t *p_pic, int i_bytes_per_pixel, int
/* following functions are local */
/*****************************************************************************
* PutByte8: print a fixed width font character byte in 15 or 16 bpp
* PutByte8: print a fixed width font character byte in 1 Bpp
*****************************************************************************/
static void PutByte8( u8 *p_pic, int i_byte, int i_char, int i_border,
int i_bg, u32 i_char_color, u32 i_border_color,
......@@ -458,13 +451,13 @@ static void PutByte8( u8 *p_pic, int i_byte, int i_char, int i_border,
i_bg &= ~(i_char | i_border);
/* Put character bits */
TREE(i_char, i_char_color);
TREE(i_border, i_border_color);
TREE(i_bg, i_bg_color);
PUT_BYTE_MASK(i_char, i_char_color);
PUT_BYTE_MASK(i_border, i_border_color);
PUT_BYTE_MASK(i_bg, i_bg_color);
}
/*****************************************************************************
* PutByte16: print a fixed width font character byte in 15 or 16 bpp
* PutByte16: print a fixed width font character byte in 2 Bpp
*****************************************************************************/
static void PutByte16( u16 *p_pic, int i_byte, int i_char, int i_border,
int i_bg, u32 i_char_color, u32 i_border_color,
......@@ -475,13 +468,13 @@ static void PutByte16( u16 *p_pic, int i_byte, int i_char, int i_border,
i_bg &= ~(i_char | i_border);
/* Put character bits */
TREE(i_char, i_char_color);
TREE(i_border, i_border_color);
TREE(i_bg, i_bg_color);
PUT_BYTE_MASK(i_char, i_char_color);
PUT_BYTE_MASK(i_border, i_border_color);
PUT_BYTE_MASK(i_bg, i_bg_color);
}
/*****************************************************************************
* PutByte24: print a fixed width font character byte in 24 bpp
* PutByte24: print a fixed width font character byte in 3 Bpp
*****************************************************************************/
static void PutByte24( void *p_pic, int i_byte, byte_t i_char, byte_t i_border, byte_t i_bg,
u32 i_char_color, u32 i_border_color, u32 i_bg_color )
......@@ -490,7 +483,7 @@ static void PutByte24( void *p_pic, int i_byte, byte_t i_char, byte_t i_border,
}
/*****************************************************************************
* PutByte32: print a fixed width font character byte in 32 bpp
* PutByte32: print a fixed width font character byte in 4 Bpp
*****************************************************************************/
static void PutByte32( u32 *p_pic, int i_byte, byte_t i_char, byte_t i_border, byte_t i_bg,
u32 i_char_color, u32 i_border_color, u32 i_bg_color )
......@@ -500,8 +493,8 @@ static void PutByte32( u32 *p_pic, int i_byte, byte_t i_char, byte_t i_border, b
i_bg &= ~(i_char | i_border);
/* Put character bits */
TREE(i_char, i_char_color);
TREE(i_border, i_border_color);
TREE(i_bg, i_bg_color);
PUT_BYTE_MASK(i_char, i_char_color);
PUT_BYTE_MASK(i_border, i_border_color);
PUT_BYTE_MASK(i_bg, i_bg_color);
}
......@@ -25,6 +25,7 @@
#include "video.h"
#include "video_output.h"
#include "video_sys.h"
#include "video_yuv.h"
#include "intf_msg.h"
/*******************************************************************************
......@@ -38,23 +39,25 @@
typedef struct vout_sys_s
{
/* User settings */
boolean_t b_shm; /* shared memory extension flag */
boolean_t b_shm; /* shared memory extension flag */
/* Internal settings and properties */
Display * p_display; /* display pointer */
int i_screen; /* screen number */
Window root_window; /* root window */
Window window; /* window instance handler */
GC gc; /* graphic context instance handler */
Display * p_display; /* display pointer */
Visual * p_visual; /* visual pointer */
int i_screen; /* screen number */
Window root_window; /* root window */
Window window; /* window instance handler */
GC gc; /* graphic context instance handler */
Colormap colormap; /* colormap used (8bpp only) */
/* Display buffers and shared memory information */
XImage * p_ximage[2]; /* XImage pointer */
XShmSegmentInfo shm_info[2]; /* shared memory zone information */
XImage * p_ximage[2]; /* XImage pointer */
XShmSegmentInfo shm_info[2]; /* shared memory zone information */
} vout_sys_t;
/*******************************************************************************
/*****************************************************************************
* Local prototypes
*******************************************************************************/
*****************************************************************************/
static int X11OpenDisplay ( vout_thread_t *p_vout, char *psz_display, Window root_window );
static void X11CloseDisplay ( vout_thread_t *p_vout );
static int X11CreateWindow ( vout_thread_t *p_vout );
......@@ -66,7 +69,6 @@ static int X11CreateShmImage ( vout_thread_t *p_vout, XImage **pp_ximage,
static void X11DestroyShmImage ( vout_thread_t *p_vout, XImage *p_ximage,
XShmSegmentInfo *p_shm_info );
/*******************************************************************************
* vout_SysCreate: allocate X11 video thread output method
*******************************************************************************
......@@ -202,6 +204,18 @@ void vout_SysDestroy( vout_thread_t *p_vout )
*******************************************************************************/
int vout_SysManage( vout_thread_t *p_vout )
{
/*
* Color/Grayscale or gamma change: in 8bpp, just change the colormap
*/
if( (p_vout->i_changes & VOUT_GRAYSCALE_CHANGE) && (p_vout->i_screen_depth == 8) )
{
//??
//?? clear flags
}
/*
* Size change
*/
if( p_vout->i_changes & VOUT_SIZE_CHANGE )
{
intf_DbgMsg("resizing window\n");
......@@ -265,14 +279,19 @@ void vout_SysDisplay( vout_thread_t *p_vout )
/* following functions are local */
/*******************************************************************************
/*****************************************************************************
* X11OpenDisplay: open and initialize X11 device
*******************************************************************************
*****************************************************************************
* Create a window according to video output given size, and set other
* properties according to the display properties.
*******************************************************************************/
*****************************************************************************/
static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display, Window root_window )
{
XPixmapFormatValues * p_xpixmap_format; /* pixmap formats */
XVisualInfo * p_xvisual; /* visuals informations */
XVisualInfo xvisual_template; /* visual template */
int i_count; /* array size */
/* Open display */
p_vout->p_sys->p_display = XOpenDisplay( psz_display );
if( p_vout->p_sys->p_display == NULL )
......@@ -290,31 +309,65 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display, Window root
intf_Msg("XShm video extension is not available\n");
}
/* Get the screen depth */
p_vout->i_screen_depth = DefaultDepth( p_vout->p_sys->p_display,
p_vout->p_sys->i_screen );
/* Get screen depth */
p_vout->i_screen_depth = XDefaultDepth( p_vout->p_sys->p_display, p_vout->p_sys->i_screen );
switch( p_vout->i_screen_depth )
{
case 8: /* 24 bpp (millions of colors) */
p_vout->i_bytes_per_pixel = 1;
break;
case 15: /* 15 bpp (16bpp with a missing green bit) */
case 16: /* 16 bpp (65536 colors) */
p_vout->i_bytes_per_pixel = 2;
break;
case 24: /* 24 bpp (millions of colors) */
p_vout->i_bytes_per_pixel = 3;
break;
case 32: /* 32 bpp (millions of colors) */
p_vout->i_bytes_per_pixel = 4;
case 8:
/*
* Screen depth is 8bpp. Use PseudoColor visual with private colormap.
*/
xvisual_template.screen = p_vout->p_sys->i_screen;
xvisual_template.class = DirectColor;
p_xvisual = XGetVisualInfo( p_vout->p_sys->p_display, VisualScreenMask | VisualClassMask,
&xvisual_template, &i_count );
if( p_xvisual == NULL )
{
intf_ErrMsg("error: no PseudoColor visual available\n");
XCloseDisplay( p_vout->p_sys->p_display );
return( 1 );
}
//??
//?? SetColormap;
p_vout->i_bytes_per_pixel = 1;
break;
default: /* unsupported screen depth */
intf_ErrMsg("error: screen depth %d is not supported\n",
p_vout->i_screen_depth);
XCloseDisplay( p_vout->p_sys->p_display );
return( 1 );
case 15:
case 16:
case 24:
default:
/*
* Screen depth is higher than 8bpp. TrueColor visual is used.
*/
xvisual_template.screen = p_vout->p_sys->i_screen;
xvisual_template.class = TrueColor;
p_xvisual = XGetVisualInfo( p_vout->p_sys->p_display, VisualScreenMask | VisualClassMask,
&xvisual_template, &i_count );
if( p_xvisual == NULL )
{
intf_ErrMsg("error: no TrueColor visual available\n");
XCloseDisplay( p_vout->p_sys->p_display );
return( 1 );
}
p_vout->i_red_mask = p_xvisual->red_mask;
p_vout->i_green_mask = p_xvisual->green_mask;
p_vout->i_blue_mask = p_xvisual->blue_mask;
/* There is no difference yet between 3 and 4 Bpp. The only way to find
* the actual number of bytes per pixel is to list supported pixmap
* formats. */
p_xpixmap_format = XListPixmapFormats( p_vout->p_sys->p_display, &i_count );
p_vout->i_bytes_per_pixel = 0;
for( ; i_count--; p_xpixmap_format++ )
{
if( p_xpixmap_format->bits_per_pixel / 8 > p_vout->i_bytes_per_pixel )
{
p_vout->i_bytes_per_pixel = p_xpixmap_format->bits_per_pixel / 8;
}
}
break;
}
}
p_vout->p_sys->p_visual = p_xvisual->visual;
XFree( p_xvisual );
/* Create a window */
if( X11CreateWindow( p_vout ) )
......@@ -334,29 +387,35 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display, Window root
*******************************************************************************/
static void X11CloseDisplay( vout_thread_t *p_vout )
{
/* Destroy colormap */
if( p_vout->i_screen_depth == 8 )
{
XFreeColormap( p_vout->p_sys->p_display, p_vout->p_sys->colormap );
}
/* Destroy window and close display */
X11DestroyWindow( p_vout );
XCloseDisplay( p_vout->p_sys->p_display );
}
/*******************************************************************************
/******************************************************************************
* X11CreateWindow: create X11 vout window
*******************************************************************************
******************************************************************************
* The video output window will be created. Normally, this window is wether
* full screen or part of a parent window. Therefore, it does not need a
* title or other hints. Thery are still supplied in case the window would be
* spawned as a standalone one by the interface.
*******************************************************************************/
******************************************************************************/
static int X11CreateWindow( vout_thread_t *p_vout )
{