Commit d4ac5770 authored by Eric Petit's avatar Eric Petit

ALL: OS X OpenGL provider

  + vout.m contains the common code for the QT video output and the
    GL provider (window creation, events handling)
  + opengl.c: higher priority on OS X
 Things are a bit broken atm, any help to debug is welcome ;p
parent bb7f54bb
......@@ -25,6 +25,8 @@ SOURCES_macosx = \
output.h \
output.m \
vout.m \
voutqt.m \
voutgl.m \
vout.h \
$(NULL)
......@@ -291,7 +291,9 @@
}
else
{
[o_window toggleFullscreen];
vlc_value_t val;
var_Get( p_vout, "fullscreen", &val );
var_Set( p_vout, "fullscreen", (vlc_value_t)!val.b_bool );
}
break;
}
......
......@@ -38,8 +38,11 @@
int E_(OpenIntf) ( vlc_object_t * );
void E_(CloseIntf) ( vlc_object_t * );
int E_(OpenVideo) ( vlc_object_t * );
void E_(CloseVideo) ( vlc_object_t * );
int E_(OpenVideoQT) ( vlc_object_t * );
void E_(CloseVideoQT) ( vlc_object_t * );
int E_(OpenVideoGL) ( vlc_object_t * );
void E_(CloseVideoGL) ( vlc_object_t * );
/*****************************************************************************
* Module descriptor
......@@ -59,49 +62,28 @@ void E_(CloseVideo) ( vlc_object_t * );
"of the movie when resizing the video, stretch the video " \
"to fill the entire window." )
#define MACOSX_VOUT_TEXT N_("video rendering mode")
#define MACOSX_VOUT_LONGTEXT N_("The default method is OpenGL " \
"for Quartz Extreme machines and Quartz for the others.")
#define OPENGL_EFFECT_TEXT N_("OpenGL effect")
#define OPENGL_EFFECT_LONGTEXT N_("Use 'None' to display the video " \
"without any fantasy, 'Cube' to let the video play on " \
"the faces of a rotating cube, 'Transparent cube' do make this " \
"cube transparent." )
#define FILL_TEXT N_("Fill fullscreen")
#define FILL_LONGTEXT N_("In fullscreen mode, crop the picture if " \
"necessary in order to fill the screen without black " \
"borders (OpenGL only)." )
static char * effect_list[] = { "none", "cube", "transparent-cube" };
static char * effect_list_text[] = { N_("None"), N_("Cube"),
N_("Transparent cube") };
static char *ppsz_vout_list[] = { "auto", "quartz", "opengl" };
static char *ppsz_vout_list_text[] = { N_("Auto"), "Quartz", "OpenGL" };
vlc_module_begin();
set_description( _("Mac OS X interface, sound and video") );
set_capability( "interface", 100 );
set_callbacks( E_(OpenIntf), E_(CloseIntf) );
add_submodule();
set_capability( "video output", 200 );
set_callbacks( E_(OpenVideo), E_(CloseVideo) );
set_capability( "video output", 100 );
set_callbacks( E_(OpenVideoQT), E_(CloseVideoQT) );
add_integer( "macosx-vdev", 0, NULL, VDEV_TEXT, VDEV_LONGTEXT,
VLC_FALSE );
add_bool( "macosx-stretch", 0, NULL, STRETCH_TEXT, STRETCH_LONGTEXT,
VLC_FALSE );
add_float_with_range( "macosx-opaqueness", 1, 0, 1, NULL,
OPAQUENESS_TEXT, OPAQUENESS_LONGTEXT, VLC_TRUE );
add_string( "macosx-vout", "auto", NULL, MACOSX_VOUT_TEXT,
MACOSX_VOUT_LONGTEXT, VLC_TRUE );
change_string_list( ppsz_vout_list, ppsz_vout_list_text, 0 );
add_string( "macosx-opengl-effect", "none", NULL,
OPENGL_EFFECT_TEXT, OPENGL_EFFECT_LONGTEXT,
VLC_TRUE );
change_string_list( effect_list, effect_list_text, 0 );
add_bool( "macosx-fill", 0, NULL, FILL_TEXT, FILL_LONGTEXT,
VLC_TRUE );
add_submodule();
set_capability( "opengl provider", 100 );
set_callbacks( E_(OpenVideoGL), E_(CloseVideoGL) );
vlc_module_end();
......@@ -30,10 +30,18 @@
@interface VLCWindow : NSWindow
{
vout_thread_t * p_vout;
Ptr p_fullscreen_state;
mtime_t i_time_mouse_last_moved;
}
- (void)setVout:(vout_thread_t *)_p_vout;
- (vout_thread_t *)getVout;
- (id)initWithVout:(vout_thread_t *)_p_vout
frame:(NSRect *)s_frame;
- (void)close;
- (void)setOnTop:(bool)b_on_top;
- (void)hideMouse:(bool)b_hide;
- (void)manage;
- (void)scaleWindowWithFactor: (float)factor;
- (void)toggleFloatOnTop;
......@@ -44,65 +52,3 @@
- (BOOL)windowShouldClose:(id)sender;
@end
/*****************************************************************************
* VLCView interface
*****************************************************************************/
@interface VLCQTView : NSQuickDrawView
{
}
@end
/*****************************************************************************
* VLCView interface
*****************************************************************************/
@interface VLCGLView : NSOpenGLView
{
vout_thread_t * p_vout;
int i_effect;
unsigned long pi_textures[2];
float f_x;
float f_y;
int initDone;
}
- (id) initWithFrame: (NSRect) frame vout: (vout_thread_t*) p_vout;
- (void) initTextures;
- (void) reloadTexture: (int) index;
- (void) cleanUp;
@end
/*****************************************************************************
* vout_sys_t: MacOS X video output method descriptor
*****************************************************************************/
struct vout_sys_t
{
NSAutoreleasePool *o_pool;
NSRect s_rect;
VLCWindow * o_window;
VLCQTView * o_qtview;
int i_opengl;
int b_pos_saved;
vlc_bool_t b_mouse_moved;
mtime_t i_time_mouse_last_moved;
#ifdef __QUICKTIME__
CodecType i_codec;
CGrafPtr p_qdport;
ImageSequence i_seq;
MatrixRecordPtr p_matrix;
DecompressorComponent img_dc;
ImageDescriptionHandle h_img_descr;
Ptr p_fullscreen_state;
#endif
/* OpenGL */
VLCGLView * o_glview;
uint8_t * p_data[2];
uint8_t * p_data_orig[2];
int i_cur_pic;
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -87,6 +87,7 @@ static int Control ( vout_thread_t *, int, va_list );
static inline int GetAlignedSize( int );
static int InitTextures( vout_thread_t * );
static int SendEvents( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
......@@ -99,7 +100,11 @@ static int SendEvents( vlc_object_t *, char const *,
vlc_module_begin();
set_description( _("OpenGL video output") );
#ifdef SYS_DARWIN
set_capability( "video output", 200 );
#else
set_capability( "video output", 20 );
#endif
add_shortcut( "opengl" );
set_callbacks( CreateVout, DestroyVout );
......@@ -179,7 +184,7 @@ static int CreateVout( vlc_object_t *p_this )
module_Need( p_sys->p_vout, "opengl provider", NULL, 0 );
if( p_sys->p_vout->p_module == NULL )
{
msg_Err( p_vout, "No OpenGL provider found" );
msg_Warn( p_vout, "No OpenGL provider found" );
vlc_object_detach( p_sys->p_vout );
vlc_object_destroy( p_sys->p_vout );
return VLC_ENOOBJ;
......@@ -192,6 +197,8 @@ static int CreateVout( vlc_object_t *p_this )
p_vout->pf_display = DisplayVideo;
p_vout->pf_control = Control;
var_Create( p_sys->p_vout, "video-on-top", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
/* Forward events from the opengl provider */
var_AddCallback( p_sys->p_vout, "mouse-x", SendEvents, p_vout );
var_AddCallback( p_sys->p_vout, "mouse-y", SendEvents, p_vout );
......@@ -207,7 +214,7 @@ static int CreateVout( vlc_object_t *p_this )
static int Init( vout_thread_t *p_vout )
{
vout_sys_t *p_sys = p_vout->p_sys;
int i_pixel_pitch, i_index;
int i_pixel_pitch;
vlc_value_t val;
p_sys->p_vout->pf_init( p_sys->p_vout );
......@@ -281,45 +288,7 @@ static int Init( vout_thread_t *p_vout )
I_OUTPUTPICTURES = 1;
glGenTextures( 2, p_sys->p_textures );
for( i_index = 0; i_index < 2; i_index++ )
{
glBindTexture( VLCGL_TARGET, p_sys->p_textures[i_index] );
/* Set the texture parameters */
glTexParameterf( VLCGL_TARGET, GL_TEXTURE_PRIORITY, 1.0 );
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_WRAP_T, GL_CLAMP );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
#ifdef SYS_DARWIN
/* Tell the driver not to make a copy of the texture but to use
our buffer */
glEnable( GL_UNPACK_CLIENT_STORAGE_APPLE );
glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE );
#if 0
/* Use VRAM texturing */
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_STORAGE_HINT_APPLE,
GL_STORAGE_CACHED_APPLE );
#else
/* Use AGP texturing */
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_STORAGE_HINT_APPLE,
GL_STORAGE_SHARED_APPLE );
#endif
#endif
/* Call glTexImage2D only once, and use glTexSubImage2D later */
glTexImage2D( VLCGL_TARGET, 0, 3, p_sys->i_tex_width,
p_sys->i_tex_height, 0, VLCGL_FORMAT, VLCGL_TYPE,
p_sys->pp_buffer[i_index] );
}
InitTextures( p_vout );
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
......@@ -410,7 +379,49 @@ static void DestroyVout( vlc_object_t *p_this )
static int Manage( vout_thread_t *p_vout )
{
vout_sys_t *p_sys = p_vout->p_sys;
return p_sys->p_vout->pf_manage( p_sys->p_vout );
int i_ret, i_fullscreen_change;
i_fullscreen_change = ( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE );
p_sys->p_vout->i_changes = p_vout->i_changes;
i_ret = p_sys->p_vout->pf_manage( p_sys->p_vout );
p_vout->i_changes = p_sys->p_vout->i_changes;
#ifdef SYS_DARWIN
/* On OS X, we create the window and the GL view when entering
fullscreen - the textures have to be inited again */
if( i_fullscreen_change )
{
InitTextures( p_vout );
switch( p_sys->i_effect )
{
case OPENGL_EFFECT_CUBE:
glEnable( GL_CULL_FACE );
break;
case OPENGL_EFFECT_TRANSPARENT_CUBE:
glDisable( GL_DEPTH_TEST );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE );
break;
}
if( p_sys->i_effect & ( OPENGL_EFFECT_CUBE |
OPENGL_EFFECT_TRANSPARENT_CUBE ) )
{
/* Set the perpective */
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glFrustum( -1.0, 1.0, -1.0, 1.0, 3.0, 20.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0, 0.0, - 5.0 );
}
}
#endif
return i_ret;
}
/*****************************************************************************
......@@ -563,6 +574,55 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
return vout_vaControlDefault( p_vout, i_query, args );
}
static int InitTextures( vout_thread_t *p_vout )
{
vout_sys_t *p_sys = p_vout->p_sys;
int i_index;
glDeleteTextures( 2, p_sys->p_textures );
glGenTextures( 2, p_sys->p_textures );
for( i_index = 0; i_index < 2; i_index++ )
{
glBindTexture( VLCGL_TARGET, p_sys->p_textures[i_index] );
/* Set the texture parameters */
glTexParameterf( VLCGL_TARGET, GL_TEXTURE_PRIORITY, 1.0 );
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_WRAP_T, GL_CLAMP );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
#ifdef SYS_DARWIN
/* Tell the driver not to make a copy of the texture but to use
our buffer */
glEnable( GL_UNPACK_CLIENT_STORAGE_APPLE );
glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE );
#if 0
/* Use VRAM texturing */
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_STORAGE_HINT_APPLE,
GL_STORAGE_CACHED_APPLE );
#else
/* Use AGP texturing */
glTexParameteri( VLCGL_TARGET, GL_TEXTURE_STORAGE_HINT_APPLE,
GL_STORAGE_SHARED_APPLE );
#endif
#endif
/* Call glTexImage2D only once, and use glTexSubImage2D later */
glTexImage2D( VLCGL_TARGET, 0, 3, p_sys->i_tex_width,
p_sys->i_tex_height, 0, VLCGL_FORMAT, VLCGL_TYPE,
p_sys->pp_buffer[i_index] );
}
return 0;
}
/*****************************************************************************
* SendEvents: forward mouse and keyboard events to the parent p_vout
*****************************************************************************/
......
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