diff options
-rw-r--r-- | src/video_out/macosx/XineOpenGLView.h | 20 | ||||
-rw-r--r-- | src/video_out/macosx/XineOpenGLView.m | 500 |
2 files changed, 323 insertions, 197 deletions
diff --git a/src/video_out/macosx/XineOpenGLView.h b/src/video_out/macosx/XineOpenGLView.h index 9e53a6c69..063a33eb2 100644 --- a/src/video_out/macosx/XineOpenGLView.h +++ b/src/video_out/macosx/XineOpenGLView.h @@ -46,6 +46,9 @@ extern NSString *XineViewDidResizeNotification; BOOL resizeViewOnVideoSizeChange; NSCursor *currentCursor; id <NSObject, XineOpenGLViewDelegate> _xineController; + NSColor *initialColor; + unsigned int initialColorYUV; + BOOL initialColorYUVIsSet; } - (void) displayTexture; @@ -58,22 +61,26 @@ extern NSString *XineViewDidResizeNotification; - (void) initTextures; - (void) reloadTexture; - (char *) getTextureBuffer; -- (void) setVideoSize:(NSSize)size; - (void) setViewSizeInMainThread:(NSSize)size; // TODO: replace set...Size below with setSize:(double)videoSizeMultiplier - (void) setNormalSize; - (void) setHalfSize; - (void) setDoubleSize; +- (void) setResizeViewOnVideoSizeChange:(BOOL)flag; +- (BOOL) resizeViewOnVideoSizeChange; +- (void) resetCursorRectsInMainThread; + +// Accessors +- (void) setVideoSize:(NSSize)size; - (NSSize) videoSize; - (void) setKeepsVideoAspectRatio:(BOOL)flag; - (BOOL) keepsVideoAspectRatio; -- (void) setResizeViewOnVideoSizeChange:(BOOL)flag; -- (BOOL) resizeViewOnVideoSizeChange; - (void) setCurrentCursor:(NSCursor *)cursor; - (NSCursor *) currentCursor; -- (void) resetCursorRectsInMainThread; - (void) setXineController:(id)controller; - (id) xineController; +- (void) setInitialColor:(NSColor *)color; +- (NSColor *) initialColor; // Delegate Methods - (id) delegate; @@ -90,10 +97,11 @@ extern NSString *XineViewDidResizeNotification; - (void) mouseDown:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; - (void) mouseMoved:(NSEvent *)theEvent inXineView:(XineOpenGLView *)theView; - (void) otherMouseDown:(NSEvent *)theEvent - inXineView:(XineOpenGLView *)theView; + inXineView:(XineOpenGLView *)theView; - (void) rightMouseDown:(NSEvent *)theEvent - inXineView:(XineOpenGLView *)theView; + inXineView:(XineOpenGLView *)theView; @end #endif /* __HAVE_XINE_OPENGL_VIEW_H__ */ + diff --git a/src/video_out/macosx/XineOpenGLView.m b/src/video_out/macosx/XineOpenGLView.m index d8155dd55..7d3c26418 100644 --- a/src/video_out/macosx/XineOpenGLView.m +++ b/src/video_out/macosx/XineOpenGLView.m @@ -22,7 +22,7 @@ /* #define LOG - */ +*/ #import <Cocoa/Cocoa.h> #import <OpenGL/OpenGL.h> @@ -31,6 +31,7 @@ #import "XineOpenGLView.h" +#include <xine/xineutils.h> NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; @@ -49,6 +50,9 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; @end +static uint32_t NSColorToYUV (NSColor *color); + + @implementation XineOpenGLView - (void) setKeepsVideoAspectRatio:(BOOL)flag @@ -80,19 +84,19 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; { NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil]; - + if (!NSMouseInRect(point, [self bounds], [self isFlipped])) return; - + if ([delegate respondsToSelector:selector]) - { + { [delegate performSelector:selector withObject:theEvent withObject:self]; return; } - + if ([_xineController respondsToSelector:selector]) - { + { [_xineController performSelector:selector withObject:theEvent withObject:self]; @@ -104,7 +108,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; { [self passEventToDelegate:theEvent withSelector:@selector(mouseMoved:inXineView:)]; - + [super mouseMoved:theEvent]; } @@ -112,7 +116,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; { [self passEventToDelegate:theEvent withSelector:@selector(mouseDown:inXineView:)]; - + [super mouseDown:theEvent]; } @@ -120,7 +124,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; { [self passEventToDelegate:theEvent withSelector:@selector(rightMouseDown:inXineView:)]; - + [super rightMouseDown:theEvent]; } @@ -128,7 +132,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; { [self passEventToDelegate:theEvent withSelector:@selector(otherMouseDown:inXineView:)]; - + [super otherMouseDown:theEvent]; } @@ -139,7 +143,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; - (void) displayTexture { if ([self lockFocusIfCanDraw]) - { + { [self drawRect: [self bounds]]; [self reloadTexture]; [self unlockFocus]; @@ -158,24 +162,24 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; NSOpenGLPFAWindow, 0 }; - + NSOpenGLPixelFormat * fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; - + if (!fmt) - { + { NSLog (@"Cannot create NSOpenGLPixelFormat\n"); return nil; } - + self = [super initWithFrame:frame pixelFormat:fmt]; - + currentContext = [self openGLContext]; [currentContext makeCurrentContext]; [mutex lock]; [currentContext update]; [mutex unlock]; - + i_texture = 0; initDone = NO; isFullScreen = NO; @@ -183,71 +187,92 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; video_height = frame.size.height; texture_buffer = nil; mutex = [[NSLock alloc] init]; - currentCursor = [NSCursor arrowCursor]; + currentCursor = [[NSCursor arrowCursor] retain]; + initialColor = nil; + initialColorYUV = 0; + initialColorYUVIsSet = NO; _xineController = nil; - + [self initTextures]; - - /* Black background */ + + /* Set GL_COLOR_BUFFER_BIT to black */ glClearColor (0.0, 0.0, 0.0, 0.0); - + #ifdef LOG NSLog(@"XineOpenGLView: initWithFrame called"); #endif - + return self; } -- (id) initWithCoder:(NSCoder *)coder +- (void) awakeFromNib { #ifdef LOG - NSLog(@"XineOpenGLView: initWithCoder called"); + NSLog(@"XineOpenGLView: awakeFromNib called"); #endif - +} + +- (id) initWithCoder:(NSCoder *)coder +{ self = [super initWithCoder:coder]; - + self = [self initWithFrame:[self frame]]; - + if ([coder allowsKeyedCoding]) - { + { keepsVideoAspectRatio = [coder decodeBoolForKey:@"keepsVideoAspectRatio"]; resizeViewOnVideoSizeChange = [coder decodeBoolForKey: @"resizeViewOnVideoSizeChange"]; + + NSColor *color = [coder decodeObjectForKey:@"initialColor"]; + if (color) + initialColor = [color copy]; } - else - { + else + { /* Must decode values in the same order as encodeWithCoder: */ [coder decodeValueOfObjCType:@encode(BOOL) at:&keepsVideoAspectRatio]; [coder decodeValueOfObjCType:@encode(BOOL) at:&resizeViewOnVideoSizeChange]; + + NSColor *color = [coder decodeObject]; + if (color) + initialColor = [color copy]; } - + + [self initTextures]; + +#ifdef LOG + NSLog(@"XineOpenGLView: initWithCoder called"); +#endif + return self; } - (void) encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; - + if ([coder allowsKeyedCoding]) - { + { [coder encodeBool:keepsVideoAspectRatio forKey:@"keepsVideoAspectRatio"]; [coder encodeBool:resizeViewOnVideoSizeChange forKey:@"resizeViewOnVideoSizeChange"]; + [coder encodeObject:initialColor forKey:@"initialColor"]; } - else - { + else + { [coder encodeValueOfObjCType:@encode(BOOL) at:&keepsVideoAspectRatio]; [coder encodeValueOfObjCType:@encode(BOOL) at:&resizeViewOnVideoSizeChange]; + [coder encodeObject:initialColor]; } - } - (void) dealloc { if (texture_buffer) free (texture_buffer); - + if (fullScreenContext) - { + { [NSOpenGLContext clearCurrentContext]; [mutex lock]; [fullScreenContext clearDrawable]; @@ -256,9 +281,9 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; if (currentContext == fullScreenContext) currentContext = nil; fullScreenContext = nil; } - + if (currentContext) - { + { [NSOpenGLContext clearCurrentContext]; [mutex lock]; [currentContext clearDrawable]; @@ -266,9 +291,21 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; [mutex unlock]; currentContext = nil; } - + [mutex dealloc]; - + + if (currentCursor) + { + [currentCursor release]; + currentCursor = NULL; + } + + if (initialColor) + { + [initialColor release]; + initialColor = NULL; + } + // Enabling the [super dealloc] below (which should be correct behaviour) // crashes -- not sure why ... // @@ -280,18 +317,31 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; - (void) reshape { [mutex lock]; - + if (!initDone) - { + { [mutex unlock]; return; } - + [currentContext makeCurrentContext]; - + NSRect bounds = [self bounds]; glViewport (0, 0, bounds.size.width, bounds.size.height); - + +#ifdef LOG + NSLog(@"XineOpenGLView: Reshape: %x%x%x%x%x%x%x%x", + texture_buffer[0], + texture_buffer[1], + texture_buffer[2], + texture_buffer[3], + texture_buffer[4], + texture_buffer[5], + texture_buffer[6], + texture_buffer[7] + ); +#endif + [mutex unlock]; } @@ -304,7 +354,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; size.width = video_width; size.height = video_height; - + [self setViewSizeInMainThread:size]; } @@ -317,7 +367,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; size.width = video_width / 2; size.height = video_height / 2; - + [self setViewSizeInMainThread:size]; } @@ -330,143 +380,177 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; size.width = video_width * 2; size.height = video_height * 2; - + [self setViewSizeInMainThread:size]; } - (void) initTextures { [mutex lock]; - + [currentContext makeCurrentContext]; - + /* Free previous texture if any */ if (i_texture) glDeleteTextures (1, &i_texture); - + if (texture_buffer) - { + { texture_buffer = realloc (texture_buffer, sizeof (char) * video_width * video_height * 3); - } + } else - { + { texture_buffer = malloc (sizeof (char) * video_width * video_height * 3); - } - + + } + + if (!initialColorYUVIsSet && initialColor) + { + initialColorYUV = NSColorToYUV(initialColor); + initialColorYUVIsSet = YES; + } + + { + // There _has_ to be a better way of doing this ... + + uint32_t *p, *q; + p = (uint32_t *) texture_buffer; + q = (uint32_t *) (char *) (texture_buffer + (sizeof(char) * video_width * video_height * 3)); + + for (; p < q; p++) *p = initialColorYUV; + } + /* Create textures */ glGenTextures (1, &i_texture); - + glEnable (GL_TEXTURE_RECTANGLE_EXT); glEnable (GL_UNPACK_CLIENT_STORAGE_APPLE); - + glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glPixelStorei (GL_UNPACK_ROW_LENGTH, video_width); - + glBindTexture (GL_TEXTURE_RECTANGLE_EXT, i_texture); glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - + /* Use VRAM texturing */ glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, - GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE); - + GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE); + /* Tell the driver not to make a copy of the texture but to use - our buffer */ + our buffer */ glPixelStorei (GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); - + /* Linear interpolation */ glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, - GL_TEXTURE_MIN_FILTER, GL_LINEAR); + GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, - GL_TEXTURE_MAG_FILTER, GL_LINEAR); - + GL_TEXTURE_MAG_FILTER, GL_LINEAR); + /* I have no idea what this exactly does, but it seems to be - necessary for scaling */ + necessary for scaling */ glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, - GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, - GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - + GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexImage2D (GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA, - video_width, video_height, 0, - GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, - texture_buffer); - + video_width, video_height, 0, + GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, + texture_buffer); + initDone = YES; [mutex unlock]; + +#ifdef LOG + NSLog(@"XineOpenGLView: initTextures called: %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx", + texture_buffer[0], + texture_buffer[1], + texture_buffer[2], + texture_buffer[3], + texture_buffer[4], + texture_buffer[5], + texture_buffer[6], + texture_buffer[7] + ); +#endif } - (void) reloadTexture { if (!initDone) - { + { return; } [mutex lock]; - + [currentContext makeCurrentContext]; - + glBindTexture (GL_TEXTURE_RECTANGLE_EXT, i_texture); glPixelStorei (GL_UNPACK_ROW_LENGTH, video_width); - + // glTexSubImage2D is faster than glTexImage2D - // http://developer.apple.com/samplecode/Sample_Code/Graphics_3D/TextureRange/MainOpenGLView.m.htm + // http://developer.apple.com/samplecode/Sample_Code/Graphics_3D/TextureRange/MainOpenGLView.m.htm glTexSubImage2D (GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, - video_width, video_height, - GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, - texture_buffer); - + video_width, video_height, + GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, + texture_buffer); + [mutex unlock]; + +#ifdef LOG + NSLog(@"reloadTexture called"); +#endif } - (void) calcFullScreenAspect { int fs_width, fs_height, x = 0, y = 0, w = 0, h = 0; - + fs_width = CGDisplayPixelsWide (kCGDirectMainDisplay); fs_height = CGDisplayPixelsHigh (kCGDirectMainDisplay); - + switch (fullscreen_mode) { - case XINE_FULLSCREEN_OVERSCAN: - if (((float) fs_width / (float) fs_height) > ((float) video_width / (float) video_height)) - { - w = (float) video_width * ((float) fs_height / (float) video_height); - h = fs_height; - x = (fs_width - w) / 2; - y = 0; - } - else - { - w = fs_width; - h = (float) video_height * ((float) fs_width / (float) video_width); - x = 0; - y = (fs_height - h) / 2; - } - break; - - case XINE_FULLSCREEN_CROP: - if (((float) fs_width / (float) fs_height) > ((float) video_width / (float) video_height)) - { - w = fs_width; - h = (float) video_height * ((float) fs_width / (float) video_width); - x = 0; - y = (fs_height - h) / 2; - } - else - { - w = (float) video_width * ((float) fs_height / (float) video_height); - h = fs_height; - x = (fs_width - w) / 2; - y = 0; - } - break; + case XINE_FULLSCREEN_OVERSCAN: + if (((float) fs_width / (float) fs_height) > ((float) video_width / (float) video_height)) + { + w = (float) video_width * ((float) fs_height / (float) video_height); + h = fs_height; + x = (fs_width - w) / 2; + y = 0; + } + else + { + w = fs_width; + h = (float) video_height * ((float) fs_width / (float) video_width); + x = 0; + y = (fs_height - h) / 2; + } + break; + + case XINE_FULLSCREEN_CROP: + if (((float) fs_width / (float) fs_height) > ((float) video_width / (float) video_height)) + { + w = fs_width; + h = (float) video_height * ((float) fs_width / (float) video_width); + x = 0; + y = (fs_height - h) / 2; + } + else + { + w = (float) video_width * ((float) fs_height / (float) video_height); + h = fs_height; + x = (fs_width - w) / 2; + y = 0; + } + break; } - + NSLog(@"MacOSX fullscreen mode: %dx%d => %dx%d @ %d,%d\n", - video_width, video_height, w, h, x, y); - + video_width, video_height, w, h, x, y); + [mutex lock]; glViewport (x, y, w, h); [mutex unlock]; @@ -478,7 +562,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; /* Create the new pixel format */ NSOpenGLPixelFormatAttribute attribs[] = - { + { NSOpenGLPFAAccelerated, NSOpenGLPFANoRecovery, NSOpenGLPFADoubleBuffer, @@ -493,43 +577,43 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; NSOpenGLPixelFormat * fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; - + if (!fmt) - { + { NSLog (@"Cannot create NSOpenGLPixelFormat\n"); return; } - + /* Create the new OpenGL context */ fullScreenContext = [[NSOpenGLContext alloc] initWithFormat: fmt shareContext: nil]; - + if (!fullScreenContext) - { + { NSLog(@"Failed to create new NSOpenGLContext\n"); return; } currentContext = fullScreenContext; - + /* Capture display, switch to fullscreen */ if (CGCaptureAllDisplays() != CGDisplayNoErr) - { + { NSLog(@"CGCaptureAllDisplays() failed\n"); return; } - + [fullScreenContext setFullScreen]; [fullScreenContext makeCurrentContext]; [mutex unlock]; - + fullscreen_mode = mode; - + [self initTextures]; [self calcFullScreenAspect]; - + /* Redraw the last picture */ [self setNeedsDisplay: YES]; - + isFullScreen = YES; } @@ -547,13 +631,13 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; [fullScreenContext release]; fullScreenContext = nil; CGReleaseAllDisplays(); - + [self reshape]; [self initTextures]; - + /* Redraw the last picture */ [self setNeedsDisplay: YES]; - + isFullScreen = NO; initDone = YES; } @@ -563,18 +647,18 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; float f_x = 1.0, f_y = 1.0; glBegin (GL_QUADS); - /* Top left */ - glTexCoord2f (0.0, 0.0); - glVertex2f (-f_x, f_y); - /* Bottom left */ - glTexCoord2f (0.0, (float) video_height); - glVertex2f (-f_x, -f_y); - /* Bottom right */ - glTexCoord2f ((float) video_width, (float) video_height); - glVertex2f (f_x, -f_y); - /* Top right */ - glTexCoord2f ((float) video_width, 0.0); - glVertex2f (f_x, f_y); + /* Top left */ + glTexCoord2f (0.0, 0.0); + glVertex2f (-f_x, f_y); + /* Bottom left */ + glTexCoord2f (0.0, (float) video_height); + glVertex2f (-f_x, -f_y); + /* Bottom right */ + glTexCoord2f ((float) video_width, (float) video_height); + glVertex2f (f_x, -f_y); + /* Top right */ + glTexCoord2f ((float) video_width, 0.0); + glVertex2f (f_x, f_y); glEnd(); } @@ -584,25 +668,22 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; if (!initDone) return; - + [mutex lock]; - + // Swap buffers only during the vertical retrace of the monitor. - // http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL/chap5/chapter_5_section_44.html - + // 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); - + /* Draw */ glBindTexture (GL_TEXTURE_RECTANGLE_EXT, i_texture); [self drawQuad]; - + /* Wait for the job to be done */ [currentContext flushBuffer]; - + [mutex unlock]; } @@ -615,87 +696,83 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; { video_width = size.width; video_height = size.height; - + if (resizeViewOnVideoSizeChange) - [self setViewSizeInMainThread:size]; - -#ifdef LOG - NSLog(@"setVideoSize called"); -#endif - + [self setViewSizeInMainThread:size]; + [self initTextures]; } - (void) setViewSizeInMainThread:(NSSize)size { // Create an autorelease pool, since we're running in a xine thread that - // may not have a pool of its own */ + // may not have a pool of its own */ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - + NSValue *sizeWrapper = [NSValue valueWithBytes:&size objCType:@encode(NSSize)]; [self performSelectorOnMainThread:@selector(setViewSize:) withObject:sizeWrapper - waitUntilDone:NO]; - + waitUntilDone:NO]; + #ifdef LOG NSLog(@"setViewSizeInMainThread called"); #endif - + [pool release]; } - (void) setViewSize:(NSValue *)sizeWrapper { NSSize proposedSize, newSize, currentSize; - + [sizeWrapper getValue:&proposedSize]; newSize = proposedSize; - + currentSize = [self frame].size; if (proposedSize.width == currentSize.width && proposedSize.height == currentSize.height) - { + { return; } - + /* If our controller handles xineViewWillResize:toSize:, send the - * message to him first. Note that the delegate still has a chance - * to override the controller's resize preference ... */ + * message to him first. Note that the delegate still has a chance + * to override the controller's resize preference ... */ if ([_xineController respondsToSelector:@selector(xineViewWillResize:toSize:)]) - { + { NSSize oldSize = [self frame].size; newSize = [_xineController xineViewWillResize:oldSize toSize:proposedSize]; } - + /* If our delegate handles xineViewWillResize:toSize:, send the - * message to him; otherwise, just resize ourselves */ + * message to him; otherwise, just resize ourselves */ if ([delegate respondsToSelector:@selector(xineViewWillResize:toSize:)]) - { + { NSSize oldSize = [self frame].size; newSize = [delegate xineViewWillResize:oldSize toSize:proposedSize]; } - + [self setFrameSize:newSize]; [self setBoundsSize:newSize]; - + /* Post a notification that we resized and also notify our controller */ /* and delegate */ NSNotification *note = [NSNotification notificationWithName:XineViewDidResizeNotification object:self]; [[NSNotificationCenter defaultCenter] postNotification:note]; - + if ([_xineController respondsToSelector:@selector(xineViewDidResize:)]) [_xineController xineViewDidResize:note]; - + if ([delegate respondsToSelector:@selector(xineViewDidResize:)]) [delegate xineViewDidResize:note]; - + if (isFullScreen) [self calcFullScreenAspect]; - + [self initTextures]; } @@ -720,6 +797,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; - (void) setCurrentCursor:(NSCursor *)cursor { currentCursor = cursor; + [currentCursor retain]; [self resetCursorRectsInMainThread]; } @@ -744,7 +822,9 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; - (void) setXineController:(id)controller { + [_xineController autorelease]; _xineController = controller; + [_xineController retain]; } - (id) xineController @@ -752,4 +832,42 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; return _xineController; } +- (void) setInitialColor:(NSColor *)color +{ + [initialColor autorelease]; + initialColor = [color copy]; +} + +- (NSColor *) initialColor +{ + return initialColor; +} + @end /* XineOpenGLView */ + + +static uint32_t NSColorToYUV (NSColor *color) +{ + float red, green, blue, alpha; + unsigned char r, g, b; + unsigned char y, u, v; + uint32_t yuv; + + NSColor *calibratedColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; + [calibratedColor getRed:&red green:&green blue:&blue alpha:&alpha]; + + r = red * 255; + g = green * 255; + b = blue * 255; + + init_yuv_conversion(); + + y = COMPUTE_Y(r, g, b); + u = COMPUTE_U(r, g, b); + v = COMPUTE_V(r, g, b); + + yuv = y << 24 | u << 16 | y << 8 | v; + + return yuv; +} + |