Commit 5d041ddd authored by Cyril Deguet's avatar Cyril Deguet

* glx.c: don't scale the image with the chroma (supposed to speed up

    the conversion ??)
parent d6cb888b
...@@ -57,8 +57,6 @@ static void SwitchContext( vout_thread_t *p_vout ); ...@@ -57,8 +57,6 @@ static void SwitchContext( vout_thread_t *p_vout );
static inline int GetAlignedSize( int i_size ); static inline int GetAlignedSize( int i_size );
#define MAX_TEXTURE_SIZE 512
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
...@@ -80,6 +78,9 @@ struct vout_sys_t ...@@ -80,6 +78,9 @@ struct vout_sys_t
uint8_t *p_buffer; uint8_t *p_buffer;
int i_index; int i_index;
int i_tex_width;
int i_tex_height;
int i_width; int i_width;
int i_height; int i_height;
int b_fullscreen; int b_fullscreen;
...@@ -132,16 +133,14 @@ static int Create( vlc_object_t *p_this ) ...@@ -132,16 +133,14 @@ static int Create( vlc_object_t *p_this )
p_vout->p_sys->i_height = p_vout->i_window_height; */ p_vout->p_sys->i_height = p_vout->i_window_height; */
p_vout->p_sys->i_width = 700; p_vout->p_sys->i_width = 700;
p_vout->p_sys->i_height = 700; p_vout->p_sys->i_height = 700;
p_vout->p_sys->b_fullscreen = 0; p_vout->p_sys->b_fullscreen = 0;
/* A texture must have a size aligned on a power of 2 */ /* A texture must have a size aligned on a power of 2 */
p_vout->output.i_width = GetAlignedSize( p_vout->render.i_width ); p_vout->p_sys->i_tex_width = GetAlignedSize( p_vout->render.i_width );
p_vout->output.i_height = GetAlignedSize( p_vout->render.i_height ); p_vout->p_sys->i_tex_height = GetAlignedSize( p_vout->render.i_height );
p_vout->output.i_aspect = p_vout->render.i_aspect;
msg_Dbg( p_vout, "Texture size: %dx%d", p_vout->output.i_width, msg_Dbg( p_vout, "Texture size: %dx%d", p_vout->p_sys->i_tex_width,
p_vout->output.i_height ); p_vout->p_sys->i_tex_height );
/* Open and initialize device */ /* Open and initialize device */
if( OpenDisplay( p_vout ) ) if( OpenDisplay( p_vout ) )
...@@ -174,6 +173,10 @@ static int Init( vout_thread_t *p_vout ) ...@@ -174,6 +173,10 @@ static int Init( vout_thread_t *p_vout )
p_vout->output.i_gmask = 0x0000ff00; p_vout->output.i_gmask = 0x0000ff00;
p_vout->output.i_bmask = 0x00ff0000; p_vout->output.i_bmask = 0x00ff0000;
p_vout->output.i_width = p_vout->render.i_width;
p_vout->output.i_height = p_vout->render.i_height;
p_vout->output.i_aspect = p_vout->render.i_aspect;
I_OUTPUTPICTURES = 0; I_OUTPUTPICTURES = 0;
p_pic = NULL; p_pic = NULL;
...@@ -197,9 +200,13 @@ static int Init( vout_thread_t *p_vout ) ...@@ -197,9 +200,13 @@ static int Init( vout_thread_t *p_vout )
* directly by the decoder */ * directly by the decoder */
p_pic->i_planes = 1; p_pic->i_planes = 1;
p_pic->p->p_pixels = p_vout->p_sys->p_buffer;
p_pic->p->p_pixels = p_vout->p_sys->p_buffer
+ 2 * p_vout->p_sys->i_tex_width *
(p_vout->p_sys->i_tex_height - p_vout->output.i_height)
+ 2 * (p_vout->p_sys->i_tex_width - p_vout->output.i_width);
p_pic->p->i_lines = p_vout->output.i_height; p_pic->p->i_lines = p_vout->output.i_height;
p_pic->p->i_pitch = p_vout->output.i_width * 4; p_pic->p->i_pitch = p_vout->p_sys->i_tex_width * 4;
p_pic->p->i_pixel_pitch = 4; p_pic->p->i_pixel_pitch = 4;
p_pic->p->i_visible_pitch = p_vout->output.i_width * 4; p_pic->p->i_visible_pitch = p_vout->output.i_width * 4;
...@@ -311,8 +318,11 @@ static int Manage( vout_thread_t *p_vout ) ...@@ -311,8 +318,11 @@ static int Manage( vout_thread_t *p_vout )
static void Render( vout_thread_t *p_vout, picture_t *p_pic ) static void Render( vout_thread_t *p_vout, picture_t *p_pic )
{ {
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glTexImage2D (GL_TEXTURE_2D, 0, 3, p_vout->output.i_width, /*glTexImage2D (GL_TEXTURE_2D, 0, 3, p_vout->output.i_width,
p_vout->output.i_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, p_vout->output.i_height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
p_vout->p_sys->p_buffer);*/
glTexImage2D (GL_TEXTURE_2D, 0, 3, p_vout->p_sys->i_tex_width,
p_vout->p_sys->i_tex_height , 0, GL_RGBA, GL_UNSIGNED_BYTE,
p_vout->p_sys->p_buffer); p_vout->p_sys->p_buffer);
if( !p_vout->p_sys->i_effect ) if( !p_vout->p_sys->i_effect )
...@@ -327,74 +337,86 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -327,74 +337,86 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
} }
else else
{ {
glRotatef( 2.0, 3.3, 1.5, 2.7 ); glRotatef( 1.0, 0.3, 0.5, 0.7 );
glEnable( GL_TEXTURE_2D); glEnable( GL_TEXTURE_2D);
glBegin( GL_QUADS ); glBegin( GL_QUADS );
float f_width = p_vout->output.i_width;
float f_height = p_vout->output.i_height;
/* Correct the aspect ratio */
/* float f_aspect = (float)p_vout->output.i_aspect / VOUT_ASPECT_FACTOR;
if( f_aspect > 1.0 )
{
f_height *= f_aspect;
}
else
{
f_width *= f_aspect;
}*/
float f_offset_x = (1.0 - f_width / p_vout->p_sys->i_tex_width) / 2.0;
float f_offset_y = (1.0 - f_height / p_vout->p_sys->i_tex_height) / 2.0;
/* Front */ /* Front */
glTexCoord2f( 0.0, 0.0 ); glTexCoord2f( f_offset_x, f_offset_y );
glVertex3f( - 1.0, 1.0, 1.0 ); glVertex3f( - 1.0, 1.0, 1.0 );
glTexCoord2f( 0.0, 1.0 ); glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
glVertex3f( - 1.0, - 1.0, 1.0 ); glVertex3f( - 1.0, - 1.0, 1.0 );
glTexCoord2f( 1.0, glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
1.0 );
glVertex3f( 1.0, - 1.0, 1.0 ); glVertex3f( 1.0, - 1.0, 1.0 );
glTexCoord2f( 1.0, 0.0 ); glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
glVertex3f( 1.0, 1.0, 1.0 ); glVertex3f( 1.0, 1.0, 1.0 );
/* Left */ /* Left */
glTexCoord2f( 0.0, 0.0 ); glTexCoord2f( f_offset_x, f_offset_y );
glVertex3f( - 1.0, 1.0, - 1.0 ); glVertex3f( - 1.0, 1.0, - 1.0 );
glTexCoord2f( 0.0, 1.0 ); glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
glVertex3f( - 1.0, - 1.0, - 1.0 ); glVertex3f( - 1.0, - 1.0, - 1.0 );
glTexCoord2f( 1.0, glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
1.0 );
glVertex3f( - 1.0, - 1.0, 1.0 ); glVertex3f( - 1.0, - 1.0, 1.0 );
glTexCoord2f( 1.0, 0.0 ); glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
glVertex3f( - 1.0, 1.0, 1.0 ); glVertex3f( - 1.0, 1.0, 1.0 );
/* Back */ /* Back */
glTexCoord2f( 0.0, 0.0 ); glTexCoord2f( f_offset_x, f_offset_y );
glVertex3f( 1.0, 1.0, - 1.0 ); glVertex3f( 1.0, 1.0, - 1.0 );
glTexCoord2f( 0.0, 1.0 ); glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
glVertex3f( 1.0, - 1.0, - 1.0 ); glVertex3f( 1.0, - 1.0, - 1.0 );
glTexCoord2f( 1.0, glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
1.0 );
glVertex3f( - 1.0, - 1.0, - 1.0 ); glVertex3f( - 1.0, - 1.0, - 1.0 );
glTexCoord2f( 1.0, 0.0 ); glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
glVertex3f( - 1.0, 1.0, - 1.0 ); glVertex3f( - 1.0, 1.0, - 1.0 );
/* Right */ /* Right */
glTexCoord2f( 0.0, 0.0 ); glTexCoord2f( f_offset_x, f_offset_y );
glVertex3f( 1.0, 1.0, 1.0 ); glVertex3f( 1.0, 1.0, 1.0 );
glTexCoord2f( 0.0, 1.0 ); glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
glVertex3f( 1.0, - 1.0, 1.0 ); glVertex3f( 1.0, - 1.0, 1.0 );
glTexCoord2f( 1.0, glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
1.0 );
glVertex3f( 1.0, - 1.0, - 1.0 ); glVertex3f( 1.0, - 1.0, - 1.0 );
glTexCoord2f( 1.0, 0.0 ); glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
glVertex3f( 1.0, 1.0, - 1.0 ); glVertex3f( 1.0, 1.0, - 1.0 );
/* Top */ /* Top */
glTexCoord2f( 0.0, 0.0 ); glTexCoord2f( f_offset_x, f_offset_y );
glVertex3f( - 1.0, 1.0, - 1.0 ); glVertex3f( - 1.0, 1.0, - 1.0 );
glTexCoord2f( 0.0, 1.0 ); glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
glVertex3f( - 1.0, 1.0, 1.0 ); glVertex3f( - 1.0, 1.0, 1.0 );
glTexCoord2f( 1.0, glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
1.0 );
glVertex3f( 1.0, 1.0, 1.0 ); glVertex3f( 1.0, 1.0, 1.0 );
glTexCoord2f( 1.0, 0.0 ); glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
glVertex3f( 1.0, 1.0, - 1.0 ); glVertex3f( 1.0, 1.0, - 1.0 );
/* Bottom */ /* Bottom */
glTexCoord2f( 0.0, 0.0 ); glTexCoord2f( f_offset_x, f_offset_y );
glVertex3f( - 1.0, - 1.0, 1.0 ); glVertex3f( - 1.0, - 1.0, 1.0 );
glTexCoord2f( 0.0, 1.0 ); glTexCoord2f( f_offset_x, 1.0 - f_offset_y );
glVertex3f( - 1.0, - 1.0, - 1.0 ); glVertex3f( - 1.0, - 1.0, - 1.0 );
glTexCoord2f( 1.0, glTexCoord2f( 1.0 - f_offset_x, 1.0 - f_offset_y );
1.0 );
glVertex3f( 1.0, - 1.0, - 1.0 ); glVertex3f( 1.0, - 1.0, - 1.0 );
glTexCoord2f( 1.0, 0.0 ); glTexCoord2f( 1.0 - f_offset_x, f_offset_y );
glVertex3f( 1.0, - 1.0, 1.0 ); glVertex3f( 1.0, - 1.0, 1.0 );
glEnd(); glEnd();
} }
...@@ -486,7 +508,7 @@ static int OpenDisplay( vout_thread_t *p_vout ) ...@@ -486,7 +508,7 @@ static int OpenDisplay( vout_thread_t *p_vout )
/* Allocate the texture buffer */ /* Allocate the texture buffer */
p_vout->p_sys->p_buffer = p_vout->p_sys->p_buffer =
malloc( p_vout->output.i_width * p_vout->output.i_height * 4 ); malloc( p_vout->p_sys->i_tex_width * p_vout->p_sys->i_tex_height * 4 );
if( !p_vout->p_sys->p_buffer ) if( !p_vout->p_sys->p_buffer )
{ {
msg_Err( p_vout, "Out of memory" ); msg_Err( p_vout, "Out of memory" );
......
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