0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

vo_corevideo: use cocoa_common to display the window

Change vo_corevideo to use cocoa_common to create and manage the
window. This doesn't affect external OSX GUIs, since they don't use
vo_corevideo window management, but only read the image data from the
shared buffer.
This commit is contained in:
Stefano Pigozzi 2011-12-11 12:26:00 +01:00 committed by Uoti Urpala
parent 237f44db44
commit d12b9b611a
5 changed files with 185 additions and 863 deletions

44
configure vendored
View File

@ -4187,21 +4187,35 @@ else
fi
echores $quicktime
echocheck "CoreVideo"
if test "$_corevideo" = auto ; then
echocheck "Cocoa"
if test "$_cocoa" = auto ; then
cat > $TMPC <<EOF
#include <Carbon/Carbon.h>
#include <CoreServices/CoreServices.h>
#include <OpenGL/OpenGL.h>
int main(void) {
NSApplicationLoad();
}
EOF
_cocoa=no
cc_check -framework Cocoa -framework OpenGL && _cocoa=yes
fi
if test "$_cocoa" = yes ; then
libs_mplayer="$libs_mplayer -framework Cocoa -framework OpenGL"
fi
echores "$_cocoa"
echocheck "CoreVideo"
if test "$_cocoa" = yes && test "$_corevideo" = auto ; then
cat > $TMPC <<EOF
#include <QuartzCore/CoreVideo.h>
int main(void) { return 0; }
EOF
_corevideo=no
cc_check -framework Carbon -framework Cocoa -framework QuartzCore -framework OpenGL && _corevideo=yes
cc_check -framework Cocoa -framework QuartzCore -framework OpenGL && _corevideo=yes
fi
if test "$_corevideo" = yes ; then
vomodules="corevideo $vomodules"
libs_mplayer="$libs_mplayer -framework Carbon -framework Cocoa -framework QuartzCore -framework OpenGL"
libs_mplayer="$libs_mplayer -framework QuartzCore"
def_corevideo='#define CONFIG_COREVIDEO 1'
else
novomodules="corevideo $novomodules"
@ -4209,26 +4223,6 @@ else
fi
echores "$_corevideo"
echocheck "Cocoa"
if test "$_gl" = no ; then
# if _gl is not enabled there is no point to add potentially unused linker flags
_cocoa=no
fi
if test "$_cocoa" = auto ; then
cat > $TMPC <<EOF
#include <CoreServices/CoreServices.h>
#include <OpenGL/OpenGL.h>
#include <QuartzCore/CoreVideo.h>
int main(void) { return 0; }
EOF
_cocoa=no
cc_check -framework Cocoa -framework QuartzCore -framework OpenGL && _cocoa=yes
fi
if test "$_cocoa" = yes ; then
libs_mplayer="$libs_mplayer -framework Cocoa -framework QuartzCore -framework OpenGL"
fi
echores "$_cocoa"
fi #if darwin

View File

@ -39,4 +39,7 @@ void vo_cocoa_ontop(struct vo *vo);
// returns an int to conform to the gl extensions from other platforms
int vo_cocoa_swap_interval(int enabled);
void *vo_cocoa_cgl_context(void);
void *vo_cocoa_cgl_pixel_format(void);
#endif /* MPLAYER_COCOA_COMMON_H */

View File

@ -54,6 +54,7 @@ struct vo_cocoa_state {
NSAutoreleasePool *pool;
GLMPlayerWindow *window;
NSOpenGLContext *glContext;
NSOpenGLPixelFormat *pixelFormat;
NSSize current_video_size;
NSSize previous_video_size;
@ -212,8 +213,8 @@ int vo_cocoa_create_window(struct vo *vo, uint32_t d_width,
(NSOpenGLPixelFormatAttribute)0
};
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
s->glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
s->pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
s->glContext = [[NSOpenGLContext alloc] initWithFormat:s->pixelFormat shareContext:nil];
create_menu();
@ -345,6 +346,16 @@ int vo_cocoa_swap_interval(int enabled)
return 0;
}
void *vo_cocoa_cgl_context(void)
{
return [s->glContext CGLContextObj];
}
void *vo_cocoa_cgl_pixel_format(void)
{
return [s->pixelFormat CGLPixelFormatObj];
}
void create_menu()
{
NSMenu *menu;

View File

@ -39,77 +39,4 @@
- (void) ontop;
@end
@interface MPlayerOpenGLView : NSOpenGLView
{
//Cocoa
NSWindow *window;
//CoreVideo
CVPixelBufferRef frameBuffers[2];
CVOpenGLTextureCacheRef textureCache;
CVOpenGLTextureRef texture;
NSRect textureFrame;
GLfloat lowerLeft[2];
GLfloat lowerRight[2];
GLfloat upperRight[2];
GLfloat upperLeft[2];
BOOL mouseHide;
//menu command id
NSMenuItem *kHalfScreenCmd;
NSMenuItem *kNormalScreenCmd;
NSMenuItem *kDoubleScreenCmd;
NSMenuItem *kFullScreenCmd;
NSMenuItem *kKeepAspectCmd;
NSMenuItem *kAspectOrgCmd;
NSMenuItem *kAspectFullCmd;
NSMenuItem *kAspectWideCmd;
NSMenuItem *kPanScanCmd;
//timestamps for disabling screensaver and mouse hiding
int lastMouseHide;
int lastScreensaverUpdate;
@public
float winSizeMult;
}
- (BOOL) acceptsFirstResponder;
- (BOOL) becomeFirstResponder;
- (BOOL) resignFirstResponder;
//window & rendering
- (void) preinit;
- (void) config;
- (void) prepareOpenGL;
- (void) render;
- (void) reshape;
- (void) setCurrentTexture;
- (void) drawRect: (NSRect *) bounds;
//vo control
- (void) fullscreen: (BOOL) animate;
- (void) ontop;
- (void) panscan;
- (void) rootwin;
//menu
- (void) initMenu;
- (void) menuAction:(id)sender;
//event
- (void) keyDown: (NSEvent *) theEvent;
- (void) mouseMoved: (NSEvent *) theEvent;
- (void) mouseDown: (NSEvent *) theEvent;
- (void) mouseUp: (NSEvent *) theEvent;
- (void) rightMouseDown: (NSEvent *) theEvent;
- (void) rightMouseUp: (NSEvent *) theEvent;
- (void) otherMouseDown: (NSEvent *) theEvent;
- (void) otherMouseUp: (NSEvent *) theEvent;
- (void) scrollWheel: (NSEvent *) theEvent;
- (void) mouseEvent: (NSEvent *) theEvent;
- (void) check_events;
@end
#endif /* MPLAYER_VO_COREVIDEO_H */

File diff suppressed because it is too large Load Diff