Commit 7cef32c0 authored by Eric Petit's avatar Eric Petit

macosx/vout* :

   + Unkludged a lot the way the OpenGL output was working until now
   + Optimized here and here. Please test!
parent 3122f7af
......@@ -2,7 +2,7 @@
* vout.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: vout.h,v 1.19 2004/01/28 21:31:15 titer Exp $
* $Id: vout.h,v 1.20 2004/01/29 02:01:49 titer Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
......@@ -58,13 +58,13 @@
*****************************************************************************/
@interface VLCGLView : NSOpenGLView
{
@public
int i_init_done;
int i_textures_loaded;
int i_index;
unsigned long i_texture;
}
- (void) initTexture;
- (void) reloadTexture: (uint8_t *) buffer;
@end
/*****************************************************************************
......@@ -89,7 +89,6 @@ struct vout_sys_t
NSRect s_rect;
int b_pos_saved;
VLCWindow * o_window;
VLCGLView * o_glview;
vlc_bool_t b_mouse_moved;
mtime_t i_time_mouse_last_moved;
......@@ -103,4 +102,6 @@ struct vout_sys_t
ImageDescriptionHandle h_img_descr;
Ptr p_fullscreen_state;
#endif
VLCGLView * o_glview;
};
......@@ -2,7 +2,7 @@
* vout.m: MacOS X video output module
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: vout.m,v 1.74 2004/01/28 21:31:15 titer Exp $
* $Id: vout.m,v 1.75 2004/01/29 02:01:49 titer Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
......@@ -291,8 +291,7 @@ static int vout_Init( vout_thread_t *p_vout )
}
/* Try to initialize up to QT_MAX_DIRECTBUFFERS direct buffers */
while( I_OUTPUTPICTURES <
( p_vout->p_sys->i_opengl ? 3 : QT_MAX_DIRECTBUFFERS ) )
while( I_OUTPUTPICTURES < QT_MAX_DIRECTBUFFERS )
{
p_pic = NULL;
......@@ -321,6 +320,8 @@ static int vout_Init( vout_thread_t *p_vout )
}
else
{
/* Nothing special to do, we just need a basic allocated
picture_t */
vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_chroma,
p_vout->output.i_width, p_vout->output.i_height,
p_vout->output.i_aspect );
......@@ -336,8 +337,9 @@ static int vout_Init( vout_thread_t *p_vout )
if( p_vout->p_sys->i_opengl )
{
p_vout->p_sys->o_glview->i_index = -1;
p_vout->p_sys->o_glview->i_init_done = 1;
/* Do this now instead of initWithFrame because we need a
first buffer for the glTexImage2D call */
[p_vout->p_sys->o_glview initTexture];
}
return( 0 );
......@@ -474,11 +476,8 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
}
else
{
p_vout->p_sys->o_glview->i_index++;
p_vout->p_sys->o_glview->i_index %= 3;
[p_vout->p_sys->o_glview setNeedsDisplay: YES];
p_pic->p->p_pixels =
PP_OUTPUTPICTURE[(p_vout->p_sys->o_glview->i_index+1)%3]->p_data;
/* Update the texture with our new picture */
[p_vout->p_sys->o_glview reloadTexture: p_pic->p->p_pixels];
}
}
......@@ -1272,7 +1271,6 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
NSOpenGLPFAAccelerated,
NSOpenGLPFANoRecovery,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAWindow,
0
};
......@@ -1295,7 +1293,6 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
glClearColor( 0.0, 0.0, 0.0, 0.0 );
i_init_done = 0;
i_textures_loaded = 0;
return self;
}
......@@ -1308,38 +1305,27 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
(GLint) bounds.size.height );
}
- (void)drawRect:(NSRect)rect
- (void) initTexture
{
vout_thread_t * p_vout;
id o_window = [self window];
p_vout = (vout_thread_t *)[o_window getVout];
/* Make this current context */
[self lockFocus];
[[self openGLContext] makeCurrentContext];
/* http://developer.apple.com/documentation/GraphicsImaging/
/* Swap buffers only during the vertical retrace of the monitor.
http://developer.apple.com/documentation/GraphicsImaging/
Conceptual/OpenGL/chap5/chapter_5_section_44.html */
long params[] = { 1 };
CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval,
params );
/* Black background */
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
if( !i_init_done )
{
return;
}
if( !i_textures_loaded )
{
/* Create the texture */
glGenTextures( 1, &i_texture );
glEnable( GL_TEXTURE_RECTANGLE_EXT );
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, i_texture);
glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA,
p_vout->output.i_width, p_vout->output.i_height, 0,
GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE,
PP_OUTPUTPICTURE[i_index]->p_data );
glBindTexture( GL_TEXTURE_RECTANGLE_EXT, i_texture );
/* Turn on AGP transferts */
glTexParameterf( GL_TEXTURE_RECTANGLE_EXT,
......@@ -1367,18 +1353,48 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
i_textures_loaded = 1;
}
else
{
/* glTexSubImage2D is supposed to be faster than glTexImage2D,
so we use it starting from the second frame */
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, i_texture);
glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA,
p_vout->output.i_width, p_vout->output.i_height, 0,
GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE,
PP_OUTPUTPICTURE[0]->p_data );
i_init_done = 1;
[self unlockFocus];
}
- (void) reloadTexture: (uint8_t *) buffer
{
vout_thread_t * p_vout;
id o_window = [self window];
p_vout = (vout_thread_t *)[o_window getVout];
[self lockFocus];
[[self openGLContext] makeCurrentContext];
glBindTexture( GL_TEXTURE_RECTANGLE_EXT, i_texture );
/* glTexSubImage2D is usually faster than glTexImage2D */
glTexSubImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0,
p_vout->output.i_width, p_vout->output.i_height,
GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE,
PP_OUTPUTPICTURE[i_index]->p_data );
}
buffer );
[self drawRect: [self bounds]];
[self unlockFocus];
}
- (void) drawRect: (NSRect) rect
{
vout_thread_t * p_vout;
id o_window = [self window];
p_vout = (vout_thread_t *)[o_window getVout];
/* Black background */
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
if( !i_init_done )
return;
/* Draw a quad with our texture on it. Quad size is set in order
to preserve the aspect ratio */
......@@ -1398,6 +1414,7 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
p_vout->output.i_aspect / bounds.size.height;
}
glBindTexture( GL_TEXTURE_RECTANGLE_EXT, i_texture );
glBegin( GL_QUADS );
/* Top left */
glTexCoord2f( 0.0f, 0.0f );
......
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