changeset 15726:25ee208c6da9

do not realloc window while playing playlist
author nplourde
date Wed, 15 Jun 2005 14:48:33 +0000
parents 817442243b82
children dfe70cdbb699
files libvo/vo_macosx.h libvo/vo_macosx.m
diffstat 2 files changed, 52 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_macosx.h	Wed Jun 15 08:14:55 2005 +0000
+++ b/libvo/vo_macosx.h	Wed Jun 15 14:48:33 2005 +0000
@@ -49,7 +49,8 @@
 - (BOOL) resignFirstResponder;
 
 //window & rendering
-- (void) initView;
+- (id) preinit;
+- (id) config;
 - (void) prepareOpenGL;
 - (void) render;
 - (void) reshape;
--- a/libvo/vo_macosx.m	Wed Jun 15 08:14:55 2005 +0000
+++ b/libvo/vo_macosx.m	Wed Jun 15 14:48:33 2005 +0000
@@ -134,21 +134,11 @@
 	movie_aspect = (float)d_width/(float)d_height;
 	old_movie_aspect = movie_aspect;
 	
-	//init OpenGL View
-	mpGLView = [[MPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, d_width, d_height) pixelFormat:[MPlayerOpenGLView defaultPixelFormat]];
-	[mpGLView initView];
-	
 	vo_fs = flags & VOFLAG_FULLSCREEN;
-	
-	if(vo_rootwin)
-		[mpGLView rootwin];	
-
-	if(vo_fs)
-		[mpGLView fullscreen: NO];
-	
-	if(vo_ontop)
-		[mpGLView ontop];
-	
+		
+	//config OpenGL View
+	[mpGLView config];
+		
 	return 0;
 }
 
@@ -255,7 +245,11 @@
 
 	NSApplicationLoad();
 	autoreleasepool = [[NSAutoreleasePool alloc] init];
-		
+	
+	mpGLView = [[MPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 0, 0) pixelFormat:[MPlayerOpenGLView defaultPixelFormat]];
+	[mpGLView autorelease];
+	[mpGLView preinit];
+	
     return 0;
 }
 
@@ -279,30 +273,43 @@
 // NSOpenGLView Subclass
 //////////////////////////////////////////////////////////////////////////
 @implementation MPlayerOpenGLView
-- (void) initView
+- (id) preinit
 {
+	//init menu
+	[self initMenu];
+	
+	//create window
+	window = [[NSWindow alloc]	initWithContentRect:NSMakeRect(0, 0, 0, 0) 
+								styleMask:NSTitledWindowMask|NSTexturedBackgroundWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
+								backing:NSBackingStoreBuffered defer:NO];
+
+	[window autorelease];
+	[window setDelegate:mpGLView];
+	[window setContentView:mpGLView];
+	[window setInitialFirstResponder:mpGLView];
+	[window setAcceptsMouseMovedEvents:YES];
+    [window setTitle:@"MPlayer - The Movie Player"];
+	
+	isFullscreen = 0;
+}
+
+- (id) config
+{
+	uint32_t d_width;
+	uint32_t d_height;
+	
 	long swapInterval = 1;
-	NSRect frame = [self frame];
+	
+	NSRect frame;
 	CVReturn error = kCVReturnSuccess;
 	
-	//init menu
-	[self initMenu];
+	aspect((int *)&d_width, (int *)&d_height,A_NOZOOM);
+	frame = NSMakeRect(0, 0, d_width, d_height);
+	[window setContentSize: frame.size];
 	
 	//create OpenGL Context
 	glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil];	
-	
-	
-	//create window
-	window = [[NSWindow alloc]	initWithContentRect:NSMakeRect(0, 0, frame.size.width, frame.size.height) 
-								styleMask:NSTitledWindowMask|NSTexturedBackgroundWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
-								backing:NSBackingStoreBuffered defer:NO];
-
-	[window setDelegate:self];
-	[window setContentView:self];
-	[window setInitialFirstResponder:self];
-	[window setAcceptsMouseMovedEvents:YES];
-    [window setTitle:@"MPlayer - The Movie Player"];
-	[window center];	
+	[glContext autorelease];
 	
 	[self setOpenGLContext:glContext];
 	[glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
@@ -321,10 +328,18 @@
 	if(error != kCVReturnSuccess)
 		mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error);
 	
+	if(vo_rootwin)
+		[mpGLView rootwin];	
+
+	if(vo_fs)
+		[mpGLView fullscreen: NO];
+	
+	if(vo_ontop)
+		[mpGLView ontop];
+		
 	//show window
-	[window makeKeyAndOrderFront:self];
-	
-	isFullscreen = 0;
+	[window center];
+	[window makeKeyAndOrderFront:mpGLView];
 }
 
 /*