aboutsummaryrefslogtreecommitdiffhomepage
path: root/libvo
diff options
context:
space:
mode:
Diffstat (limited to 'libvo')
-rw-r--r--libvo/cocoa_common.h12
-rw-r--r--libvo/cocoa_common.m537
-rw-r--r--libvo/gl_common.c31
-rw-r--r--libvo/gl_common.h2
-rw-r--r--libvo/gl_header_fixes.h12
-rw-r--r--libvo/video_out.h1
-rw-r--r--libvo/vo_corevideo.m14
-rw-r--r--libvo/vo_direct3d.c9
-rw-r--r--libvo/vo_opengl.c12
-rw-r--r--libvo/vo_opengl_old.c18
-rw-r--r--libvo/vo_vdpau.c57
-rw-r--r--libvo/vo_xv.c10
12 files changed, 422 insertions, 293 deletions
diff --git a/libvo/cocoa_common.h b/libvo/cocoa_common.h
index 943a5fb8ba..079e497441 100644
--- a/libvo/cocoa_common.h
+++ b/libvo/cocoa_common.h
@@ -22,6 +22,8 @@
#include "video_out.h"
+struct vo_cocoa_state;
+
bool vo_cocoa_gui_running(void);
void *vo_cocoa_glgetaddr(const char *s);
@@ -35,17 +37,19 @@ int vo_cocoa_create_window(struct vo *vo, uint32_t d_width,
uint32_t d_height, uint32_t flags,
int gl3profile);
-void vo_cocoa_swap_buffers(void);
+void vo_cocoa_swap_buffers(struct vo *vo);
int vo_cocoa_check_events(struct vo *vo);
void vo_cocoa_fullscreen(struct vo *vo);
void vo_cocoa_ontop(struct vo *vo);
+void vo_cocoa_pause(struct vo *vo);
+void vo_cocoa_resume(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);
+void *vo_cocoa_cgl_context(struct vo *vo);
+void *vo_cocoa_cgl_pixel_format(struct vo *vo);
-int vo_cocoa_cgl_color_size(void);
+int vo_cocoa_cgl_color_size(struct vo *vo);
#endif /* MPLAYER_COCOA_COMMON_H */
diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m
index 331072afcf..b220da8798 100644
--- a/libvo/cocoa_common.m
+++ b/libvo/cocoa_common.m
@@ -18,9 +18,8 @@
*/
#import <Cocoa/Cocoa.h>
-#import <OpenGL/OpenGL.h>
-#import <QuartzCore/QuartzCore.h>
#import <CoreServices/CoreServices.h> // for CGDisplayHideCursor
+#import <IOKit/pwr_mgt/IOPMLib.h>
#include <dlfcn.h>
#include "cocoa_common.h"
@@ -62,13 +61,22 @@
@end
#endif
-@interface GLMPlayerWindow : NSWindow <NSWindowDelegate>
-- (BOOL) canBecomeKeyWindow;
-- (BOOL) canBecomeMainWindow;
-- (void) fullscreen;
-- (void) mouseEvent:(NSEvent *)theEvent;
-- (void) mulSize:(float)multiplier;
-- (void) setContentSize:(NSSize)newSize keepCentered:(BOOL)keepCentered;
+// add power management assertion not available on OSX versions prior to 10.7
+#ifndef kIOPMAssertionTypePreventUserIdleDisplaySleep
+#define kIOPMAssertionTypePreventUserIdleDisplaySleep \
+ CFSTR("PreventUserIdleDisplaySleep")
+#endif
+
+@interface GLMPlayerWindow : NSWindow <NSWindowDelegate> {
+ struct vo *_vo;
+}
+- (void)setVideoOutput:(struct vo *)vo;
+- (BOOL)canBecomeKeyWindow;
+- (BOOL)canBecomeMainWindow;
+- (void)fullscreen;
+- (void)mouseEvent:(NSEvent *)theEvent;
+- (void)mulSize:(float)multiplier;
+- (void)setContentSize:(NSSize)newSize keepCentered:(BOOL)keepCentered;
@end
@interface GLMPlayerOpenGLView : NSView
@@ -94,44 +102,39 @@ struct vo_cocoa_state {
NSString *window_title;
- NSInteger windowed_window_level;
+ NSInteger window_level;
NSInteger fullscreen_window_level;
- int last_screensaver_update;
-
int display_cursor;
int cursor_timer;
int cursor_autohide_delay;
bool did_resize;
bool out_fs_resize;
-};
-struct vo_cocoa_state *s;
+ IOPMAssertionID power_mgmt_assertion;
+};
-struct vo *l_vo;
+static int _instances = 0;
-// local function definitions
-struct vo_cocoa_state *vo_cocoa_init_state(void);
-void vo_set_level(int ontop);
-void update_screen_info(void);
-void resize_window(struct vo *vo);
-void vo_cocoa_display_cursor(int requested_state);
-void create_menu(void);
+static void create_menu(void);
-struct vo_cocoa_state *vo_cocoa_init_state(void)
+static struct vo_cocoa_state *vo_cocoa_init_state(struct vo *vo)
{
- struct vo_cocoa_state *s = talloc_ptrtype(NULL, s);
+ struct vo_cocoa_state *s = talloc_ptrtype(vo, s);
*s = (struct vo_cocoa_state){
+ .pool = [[NSAutoreleasePool alloc] init],
.did_resize = NO,
.current_video_size = {0,0},
.previous_video_size = {0,0},
- .windowed_mask = NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask,
+ .windowed_mask = NSTitledWindowMask|NSClosableWindowMask|
+ NSMiniaturizableWindowMask|NSResizableWindowMask,
.fullscreen_mask = NSBorderlessWindowMask,
- .fullscreen_window_level = NSNormalWindowLevel + 1,
.windowed_frame = {{0,0},{0,0}},
.out_fs_resize = NO,
.display_cursor = 1,
+ .cursor_autohide_delay = vo->opts->cursor_autohide_delay,
+ .power_mgmt_assertion = kIOPMNullAssertionID,
};
return s;
}
@@ -145,7 +148,7 @@ static bool supports_hidpi(NSView *view)
bool vo_cocoa_gui_running(void)
{
- return !!s;
+ return _instances > 0;
}
void *vo_cocoa_glgetaddr(const char *s)
@@ -161,21 +164,45 @@ void *vo_cocoa_glgetaddr(const char *s)
return ret;
}
+static void enable_power_management(struct vo *vo)
+{
+ struct vo_cocoa_state *s = vo->cocoa;
+ if (!s->power_mgmt_assertion) return;
+ IOPMAssertionRelease(s->power_mgmt_assertion);
+ s->power_mgmt_assertion = kIOPMNullAssertionID;
+}
+
+static void disable_power_management(struct vo *vo)
+{
+ struct vo_cocoa_state *s = vo->cocoa;
+ if (s->power_mgmt_assertion) return;
+
+ CFStringRef assertion_type = kIOPMAssertionTypeNoDisplaySleep;
+ if (is_osx_version_at_least(10, 7, 0))
+ assertion_type = kIOPMAssertionTypePreventUserIdleDisplaySleep;
+
+ IOPMAssertionCreateWithName(assertion_type, kIOPMAssertionLevelOn,
+ CFSTR("org.mplayer2.power_mgmt"), &s->power_mgmt_assertion);
+}
+
int vo_cocoa_init(struct vo *vo)
{
- s = vo_cocoa_init_state();
- s->pool = [[NSAutoreleasePool alloc] init];
- s->cursor_autohide_delay = vo->opts->cursor_autohide_delay;
+ vo->cocoa = vo_cocoa_init_state(vo);
+ _instances++;
+
NSApplicationLoad();
NSApp = [NSApplication sharedApplication];
[NSApp setActivationPolicy: NSApplicationActivationPolicyRegular];
+ disable_power_management(vo);
return 1;
}
void vo_cocoa_uninit(struct vo *vo)
{
+ struct vo_cocoa_state *s = vo->cocoa;
CGDisplayShowCursor(kCGDirectMainDisplay);
+ enable_power_management(vo);
[NSApp setPresentationOptions:NSApplicationPresentationDefault];
[s->window release];
@@ -185,22 +212,34 @@ void vo_cocoa_uninit(struct vo *vo)
[s->pool release];
s->pool = nil;
- talloc_free(s);
- s = nil;
+ _instances--;
+}
+
+void vo_cocoa_pause(struct vo *vo)
+{
+ enable_power_management(vo);
}
-static int current_screen_has_dock_or_menubar(void)
+void vo_cocoa_resume(struct vo *vo)
{
+ disable_power_management(vo);
+}
+
+static int current_screen_has_dock_or_menubar(struct vo *vo)
+{
+ struct vo_cocoa_state *s = vo->cocoa;
NSRect f = s->screen_frame;
NSRect vf = [s->screen_handle visibleFrame];
return f.size.height > vf.size.height || f.size.width > vf.size.width;
}
-void update_screen_info(void)
+static void update_screen_info(struct vo *vo)
{
+ struct vo_cocoa_state *s = vo->cocoa;
s->screen_array = [NSScreen screens];
if (xinerama_screen >= (int)[s->screen_array count]) {
- mp_msg(MSGT_VO, MSGL_INFO, "[cocoa] Device ID %d does not exist, falling back to main device\n", xinerama_screen);
+ mp_msg(MSGT_VO, MSGL_INFO, "[cocoa] Device ID %d does not exist, "
+ "falling back to main device\n", xinerama_screen);
xinerama_screen = -1;
}
@@ -216,8 +255,10 @@ void update_screen_info(void)
void vo_cocoa_update_xinerama_info(struct vo *vo)
{
- update_screen_info();
- aspect_save_screenres(vo, s->screen_frame.size.width, s->screen_frame.size.height);
+ struct vo_cocoa_state *s = vo->cocoa;
+ update_screen_info(vo);
+ aspect_save_screenres(vo, s->screen_frame.size.width,
+ s->screen_frame.size.height);
}
int vo_cocoa_change_attributes(struct vo *vo)
@@ -225,8 +266,9 @@ int vo_cocoa_change_attributes(struct vo *vo)
return 0;
}
-void resize_window(struct vo *vo)
+static void resize_window(struct vo *vo)
{
+ struct vo_cocoa_state *s = vo->cocoa;
NSView *view = [s->window contentView];
NSRect frame;
@@ -241,106 +283,147 @@ void resize_window(struct vo *vo)
[s->glContext update];
}
-void vo_set_level(int ontop)
+static void vo_set_level(struct vo *vo, int ontop)
{
+ struct vo_cocoa_state *s = vo->cocoa;
if (ontop) {
- s->windowed_window_level = NSNormalWindowLevel + 1;
+ s->window_level = NSNormalWindowLevel + 1;
} else {
- s->windowed_window_level = NSNormalWindowLevel;
+ s->window_level = NSNormalWindowLevel;
}
if (!vo_fs)
- [s->window setLevel:s->windowed_window_level];
+ [s->window setLevel:s->window_level];
}
void vo_cocoa_ontop(struct vo *vo)
{
struct MPOpts *opts = vo->opts;
opts->vo_ontop = !opts->vo_ontop;
- vo_set_level(opts->vo_ontop);
+ vo_set_level(vo, opts->vo_ontop);
}
-int vo_cocoa_create_window(struct vo *vo, uint32_t d_width,
- uint32_t d_height, uint32_t flags,
- int gl3profile)
+static void update_state_sizes(struct vo_cocoa_state *s,
+ uint32_t d_width, uint32_t d_height)
{
- struct MPOpts *opts = vo->opts;
if (s->current_video_size.width > 0 || s->current_video_size.height > 0)
s->previous_video_size = s->current_video_size;
s->current_video_size = NSMakeSize(d_width, d_height);
+}
- if (!(s->window || s->glContext)) { // keep using the same window
- s->window = [[GLMPlayerWindow alloc] initWithContentRect:NSMakeRect(0, 0, d_width, d_height)
- styleMask:s->windowed_mask
- backing:NSBackingStoreBuffered defer:NO];
-
- GLMPlayerOpenGLView *glView = [[GLMPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
-
- // check for HiDPI support and enable it (available on 10.7 +)
- if (supports_hidpi(glView))
- [glView setWantsBestResolutionOpenGLSurface:YES];
-
- int i = 0;
- NSOpenGLPixelFormatAttribute attr[32];
- if (is_osx_version_at_least(10, 7, 0)) {
- attr[i++] = NSOpenGLPFAOpenGLProfile;
- attr[i++] = (gl3profile ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy);
- } else if(gl3profile) {
- mp_msg(MSGT_VO, MSGL_ERR,
- "[cocoa] Invalid pixel format attribute "
- "(GL3 is not supported on OSX versions prior to 10.7)\n");
- return -1;
- }
- attr[i++] = NSOpenGLPFADoubleBuffer; // double buffered
- attr[i] = (NSOpenGLPixelFormatAttribute)0;
-
- s->pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease];
- if (!s->pixelFormat) {
- mp_msg(MSGT_VO, MSGL_ERR,
- "[cocoa] Invalid pixel format attribute "
- "(GL3 not supported?)\n");
- return -1;
- }
- s->glContext = [[NSOpenGLContext alloc] initWithFormat:s->pixelFormat shareContext:nil];
+static int create_window(struct vo *vo, uint32_t d_width, uint32_t d_height,
+ uint32_t flags, int gl3profile)
+{
+ struct vo_cocoa_state *s = vo->cocoa;
+ struct MPOpts *opts = vo->opts;
+
+ const NSRect window_rect = NSMakeRect(0, 0, d_width, d_height);
+ const NSRect glview_rect = NSMakeRect(0, 0, 100, 100);
+
+ s->window =
+ [[GLMPlayerWindow alloc] initWithContentRect:window_rect
+ styleMask:s->windowed_mask
+ backing:NSBackingStoreBuffered
+ defer:NO];
+
+ GLMPlayerOpenGLView *glView =
+ [[GLMPlayerOpenGLView alloc] initWithFrame:glview_rect];
+
+ // check for HiDPI support and enable it (available on 10.7 +)
+ if (supports_hidpi(glView))
+ [glView setWantsBestResolutionOpenGLSurface:YES];
+
+ int i = 0;
+ NSOpenGLPixelFormatAttribute attr[32];
+ if (is_osx_version_at_least(10, 7, 0)) {
+ attr[i++] = NSOpenGLPFAOpenGLProfile;
+ if (gl3profile) {
+ attr[i++] = NSOpenGLProfileVersion3_2Core;
+ } else {
+ attr[i++] = NSOpenGLProfileVersionLegacy;
+ }
+ } else if(gl3profile) {
+ mp_msg(MSGT_VO, MSGL_ERR,
+ "[cocoa] Invalid pixel format attribute "
+ "(GL3 is not supported on OSX versions prior to 10.7)\n");
+ return -1;
+ }
+ attr[i++] = NSOpenGLPFADoubleBuffer; // double buffered
+ attr[i] = (NSOpenGLPixelFormatAttribute)0;
+
+ s->pixelFormat =
+ [[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease];
+ if (!s->pixelFormat) {
+ mp_msg(MSGT_VO, MSGL_ERR,
+ "[cocoa] Invalid pixel format attribute "
+ "(GL3 not supported?)\n");
+ return -1;
+ }
+ s->glContext =
+ [[NSOpenGLContext alloc] initWithFormat:s->pixelFormat
+ shareContext:nil];
+
+ create_menu();
+
+ [s->window setContentView:glView];
+ [glView release];
+ [s->window setAcceptsMouseMovedEvents:YES];
+ [s->glContext setView:glView];
+ [s->glContext makeCurrentContext];
+
+ [NSApp setDelegate:s->window];
+ [s->window setDelegate:s->window];
+ [s->window setContentSize:s->current_video_size];
+ [s->window setContentAspectRatio:s->current_video_size];
+ [s->window center];
+
+ if (flags & VOFLAG_HIDDEN) {
+ [s->window orderOut:nil];
+ } else {
+ [s->window makeKeyAndOrderFront:nil];
+ [NSApp activateIgnoringOtherApps:YES];
+ }
- create_menu();
+ if (flags & VOFLAG_FULLSCREEN)
+ vo_cocoa_fullscreen(vo);
- [s->window setContentView:glView];
- [glView release];
- [s->window setAcceptsMouseMovedEvents:YES];
- [s->glContext setView:glView];
- [s->glContext makeCurrentContext];
+ vo_set_level(vo, opts->vo_ontop);
- [NSApp setDelegate:s->window];
- [s->window setDelegate:s->window];
- [s->window setContentSize:s->current_video_size];
- [s->window setContentAspectRatio:s->current_video_size];
- [s->window center];
+ return 0;
+}
+
+static void update_window(struct vo *vo)
+{
+ struct vo_cocoa_state *s = vo->cocoa;
- if (flags & VOFLAG_HIDDEN) {
- [s->window orderOut:nil];
+ if (s->current_video_size.width != s->previous_video_size.width ||
+ s->current_video_size.height != s->previous_video_size.height) {
+ if (vo_fs) {
+ // we will resize as soon as we get out of fullscreen
+ s->out_fs_resize = YES;
} else {
- [s->window makeKeyAndOrderFront:nil];
- [NSApp activateIgnoringOtherApps:YES];
+ // only if we are not in fullscreen and the video size did
+ // change we resize the window and set a new aspect ratio
+ [s->window setContentSize:s->current_video_size
+ keepCentered:YES];
+ [s->window setContentAspectRatio:s->current_video_size];
}
+ }
+}
+
+int vo_cocoa_create_window(struct vo *vo, uint32_t d_width,
+ uint32_t d_height, uint32_t flags,
+ int gl3profile)
+{
+ struct vo_cocoa_state *s = vo->cocoa;
- if (flags & VOFLAG_FULLSCREEN)
- vo_cocoa_fullscreen(vo);
+ update_state_sizes(s, d_width, d_height);
- vo_set_level(opts->vo_ontop);
+ if (!(s->window || s->glContext)) {
+ if (create_window(vo, d_width, d_height, flags, gl3profile) < 0)
+ return -1;
} else {
- if (s->current_video_size.width != s->previous_video_size.width ||
- s->current_video_size.height != s->previous_video_size.height) {
- if (vo_fs) {
- // we will resize as soon as we get out of fullscreen
- s->out_fs_resize = YES;
- } else {
- // only if we are not in fullscreen and the video size did change
- // we actually resize the window and set a new aspect ratio
- [s->window setContentSize:s->current_video_size keepCentered:YES];
- [s->window setContentAspectRatio:s->current_video_size];
- }
- }
+ update_window(vo);
}
resize_window(vo);
@@ -348,19 +431,22 @@ int vo_cocoa_create_window(struct vo *vo, uint32_t d_width,
if (s->window_title)
[s->window_title release];
- s->window_title = [[NSString alloc] initWithUTF8String:vo_get_window_title(vo)];
+ s->window_title =
+ [[NSString alloc] initWithUTF8String:vo_get_window_title(vo)];
[s->window setTitle: s->window_title];
return 0;
}
-void vo_cocoa_swap_buffers()
+void vo_cocoa_swap_buffers(struct vo *vo)
{
+ struct vo_cocoa_state *s = vo->cocoa;
[s->glContext flushBuffer];
}
-void vo_cocoa_display_cursor(int requested_state)
+static void vo_cocoa_display_cursor(struct vo *vo, int requested_state)
{
+ struct vo_cocoa_state *s = vo->cocoa;
if (requested_state) {
if (!vo_fs || s->cursor_autohide_delay > -2) {
s->display_cursor = requested_state;
@@ -376,30 +462,22 @@ void vo_cocoa_display_cursor(int requested_state)
int vo_cocoa_check_events(struct vo *vo)
{
+ struct vo_cocoa_state *s = vo->cocoa;
NSEvent *event;
- float curTime = TickCount()/60;
- int msCurTime = (int) (curTime * 1000);
+ int ms_time = (int) ([[NSProcessInfo processInfo] systemUptime] * 1000);
// automatically hide mouse cursor
if (vo_fs && s->display_cursor &&
- (msCurTime - s->cursor_timer >= s->cursor_autohide_delay)) {
- vo_cocoa_display_cursor(0);
- s->cursor_timer = msCurTime;
- }
-
- //update activity every 30 seconds to prevent
- //screensaver from starting up.
- if ((int)curTime - s->last_screensaver_update >= 30 || s->last_screensaver_update == 0)
- {
- UpdateSystemActivity(UsrActivity);
- s->last_screensaver_update = (int)curTime;
+ (ms_time - s->cursor_timer >= s->cursor_autohide_delay)) {
+ vo_cocoa_display_cursor(vo, 0);
+ s->cursor_timer = ms_time;
}
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil
inMode:NSEventTrackingRunLoopMode dequeue:YES];
if (event == nil)
return 0;
- l_vo = vo;
+ [s->window setVideoOutput:vo];
[NSApp sendEvent:event];
if (s->did_resize) {
@@ -420,30 +498,33 @@ int vo_cocoa_check_events(struct vo *vo)
void vo_cocoa_fullscreen(struct vo *vo)
{
+ struct vo_cocoa_state *s = vo->cocoa;
[s->window fullscreen];
resize_window(vo);
}
int vo_cocoa_swap_interval(int enabled)
{
- [s->glContext setValues:&enabled forParameter:NSOpenGLCPSwapInterval];
+ [[NSOpenGLContext currentContext] setValues:&enabled
+ forParameter:NSOpenGLCPSwapInterval];
return 0;
}
-void *vo_cocoa_cgl_context(void)
+void *vo_cocoa_cgl_context(struct vo *vo)
{
+ struct vo_cocoa_state *s = vo->cocoa;
return [s->glContext CGLContextObj];
}
-void *vo_cocoa_cgl_pixel_format(void)
+void *vo_cocoa_cgl_pixel_format(struct vo *vo)
{
- return CGLGetPixelFormat(vo_cocoa_cgl_context());
+ return CGLGetPixelFormat(vo_cocoa_cgl_context(vo));
}
-int vo_cocoa_cgl_color_size(void)
+int vo_cocoa_cgl_color_size(struct vo *vo)
{
GLint value;
- CGLDescribePixelFormat(vo_cocoa_cgl_pixel_format(), 0,
+ CGLDescribePixelFormat(vo_cocoa_cgl_pixel_format(vo), 0,
kCGLPFAColorSize, &value);
switch (value) {
case 32:
@@ -459,10 +540,9 @@ int vo_cocoa_cgl_color_size(void)
static NSMenuItem *new_menu_item(NSMenu *parent_menu, NSString *title,
SEL action, NSString *key_equivalent)
{
- NSMenuItem *new_item = [[NSMenuItem alloc]
- initWithTitle:title
- action:action
- keyEquivalent:key_equivalent];
+ NSMenuItem *new_item =
+ [[NSMenuItem alloc] initWithTitle:title action:action
+ keyEquivalent:key_equivalent];
[parent_menu addItem:new_item];
return [new_item autorelease];
}
@@ -470,10 +550,9 @@ static NSMenuItem *new_menu_item(NSMenu *parent_menu, NSString *title,
static NSMenuItem *new_main_menu_item(NSMenu *parent_menu, NSMenu *child_menu,
NSString *title)
{
- NSMenuItem *new_item = [[NSMenuItem alloc]
- initWithTitle:title
- action:nil
- keyEquivalent:@""];
+ NSMenuItem *new_item =
+ [[NSMenuItem alloc] initWithTitle:title action:nil
+ keyEquivalent:@""];
[new_item setSubmenu:child_menu];
[parent_menu addItem:new_item];
return [new_item autorelease];
@@ -506,26 +585,33 @@ void create_menu()
}
@implementation GLMPlayerWindow
+- (void)setVideoOutput:(struct vo *)vo
+{
+ _vo = vo;
+}
-- (void) windowDidResize:(NSNotification *) notification
+- (void)windowDidResize:(NSNotification *) notification
{
- if (l_vo)
+ if (_vo) {
+ struct vo_cocoa_state *s = _vo->cocoa;
s->did_resize = YES;
+ }
}
-- (void) fullscreen
+- (void)fullscreen
{
+ struct vo_cocoa_state *s = _vo->cocoa;
if (!vo_fs) {
- update_screen_info();
- if (current_screen_has_dock_or_menubar())
- [NSApp setPresentationOptions:NSApplicationPresentationHideDock|NSApplicationPresentationHideMenuBar];
+ update_screen_info(_vo);
+ if (current_screen_has_dock_or_menubar(_vo))
+ [NSApp setPresentationOptions:NSApplicationPresentationHideDock|
+ NSApplicationPresentationHideMenuBar];
s->windowed_frame = [self frame];
[self setHasShadow:NO];
[self setStyleMask:s->fullscreen_mask];
[self setFrame:s->screen_frame display:YES animate:NO];
- [self setLevel:s->fullscreen_window_level];
vo_fs = VO_TRUE;
- vo_cocoa_display_cursor(0);
+ vo_cocoa_display_cursor(_vo, 0);
[self setMovableByWindowBackground: NO];
} else {
[NSApp setPresentationOptions:NSApplicationPresentationDefault];
@@ -538,42 +624,44 @@ void create_menu()
s->out_fs_resize = NO;
}
[self setContentAspectRatio:s->current_video_size];
- [self setLevel:s->windowed_window_level];
vo_fs = VO_FALSE;
- vo_cocoa_display_cursor(1);
+ vo_cocoa_display_cursor(_vo, 1);
[self setMovableByWindowBackground: YES];
}
}
-- (BOOL) canBecomeMainWindow { return YES; }
-- (BOOL) canBecomeKeyWindow { return YES; }
-- (BOOL) acceptsFirstResponder { return YES; }
-- (BOOL) becomeFirstResponder { return YES; }
-- (BOOL) resignFirstResponder { return YES; }
-- (BOOL) windowShouldClose:(id)sender
+- (BOOL)canBecomeMainWindow { return YES; }
+- (BOOL)canBecomeKeyWindow { return YES; }
+- (BOOL)acceptsFirstResponder { return YES; }
+- (BOOL)becomeFirstResponder { return YES; }
+- (BOOL)resignFirstResponder { return YES; }
+- (BOOL)windowShouldClose:(id)sender
{
- mplayer_put_key(l_vo->key_fifo, KEY_CLOSE_WIN);
+ mplayer_put_key(_vo->key_fifo, KEY_CLOSE_WIN);
// We have to wait for MPlayer to handle this,
// otherwise we are in trouble if the
// KEY_CLOSE_WIN handler is disabled
return NO;
}
-- (BOOL) isMovableByWindowBackground
+- (BOOL)isMovableByWindowBackground
{
- // this is only valid as a starting value. it will be rewritten in the -fullscreen method.
+ // this is only valid as a starting value. it will be rewritten in the
+ // -fullscreen method.
return !vo_fs;
}
-- (void) handleQuitEvent:(NSAppleEventDescriptor*)e withReplyEvent:(NSAppleEventDescriptor*)r
+- (void)handleQuitEvent:(NSAppleEventDescriptor*)e
+ withReplyEvent:(NSAppleEventDescriptor*)r
{
- mplayer_put_key(l_vo->key_fifo, KEY_CLOSE_WIN);
+ mplayer_put_key(_vo->key_fifo, KEY_CLOSE_WIN);
}
-- (void) keyDown:(NSEvent *)theEvent
+- (void)keyDown:(NSEvent *)theEvent
{
unsigned char charcode;
- if (([theEvent modifierFlags] & NSRightAlternateKeyMask) == NSRightAlternateKeyMask)
+ if (([theEvent modifierFlags] & NSRightAlternateKeyMask) ==
+ NSRightAlternateKeyMask)
charcode = *[[theEvent characters] UTF8String];
else
charcode = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
@@ -585,64 +673,65 @@ void create_menu()
key |= KEY_MODIFIER_SHIFT;
if ([theEvent modifierFlags] & NSControlKeyMask)
key |= KEY_MODIFIER_CTRL;
- if (([theEvent modifierFlags] & NSLeftAlternateKeyMask) == NSLeftAlternateKeyMask)
+ if (([theEvent modifierFlags] & NSLeftAlternateKeyMask) ==
+ NSLeftAlternateKeyMask)
key |= KEY_MODIFIER_ALT;
if ([theEvent modifierFlags] & NSCommandKeyMask)
key |= KEY_MODIFIER_META;
- mplayer_put_key(l_vo->key_fifo, key);
+ mplayer_put_key(_vo->key_fifo, key);
}
}
-- (void) mouseMoved: (NSEvent *) theEvent
+- (void)mouseMoved: (NSEvent *) theEvent
{
if (vo_fs)
- vo_cocoa_display_cursor(1);
+ vo_cocoa_display_cursor(_vo, 1);
}
-- (void) mouseDragged:(NSEvent *)theEvent
+- (void)mouseDragged:(NSEvent *)theEvent
{
[self mouseEvent: theEvent];
}
-- (void) mouseDown:(NSEvent *)theEvent
+- (void)mouseDown:(NSEvent *)theEvent
{
[self mouseEvent: theEvent];
}
-- (void) mouseUp:(NSEvent *)theEvent
+- (void)mouseUp:(NSEvent *)theEvent
{
[self mouseEvent: theEvent];
}
-- (void) rightMouseDown:(NSEvent *)theEvent
+- (void)rightMouseDown:(NSEvent *)theEvent
{
[self mouseEvent: theEvent];
}
-- (void) rightMouseUp:(NSEvent *)theEvent
+- (void)rightMouseUp:(NSEvent *)theEvent
{
[self mouseEvent: theEvent];
}
-- (void) otherMouseDown:(NSEvent *)theEvent
+- (void)otherMouseDown:(NSEvent *)theEvent
{
[self mouseEvent: theEvent];
}
-- (void) otherMouseUp:(NSEvent *)theEvent
+- (void)otherMouseUp:(NSEvent *)theEvent
{
[self mouseEvent: theEvent];
}
-- (void) scrollWheel:(NSEvent *)theEvent
+- (void)scrollWheel:(NSEvent *)theEvent
{
if ([theEvent deltaY] > 0)
- mplayer_put_key(l_vo->key_fifo, MOUSE_BTN3);
+ mplayer_put_key(_vo->key_fifo, MOUSE_BTN3);
else
- mplayer_put_key(l_vo->key_fifo, MOUSE_BTN4);
+ mplayer_put_key(_vo->key_fifo, MOUSE_BTN4);
}
-- (void) mouseEvent:(NSEvent *)theEvent
+- (void)mouseEvent:(NSEvent *)theEvent
{
if ([theEvent buttonNumber] >= 0 && [theEvent buttonNumber] <= 9) {
int buttonNumber = [theEvent buttonNumber];
@@ -653,43 +742,39 @@ void create_menu()
case NSLeftMouseDown:
case NSRightMouseDown:
case NSOtherMouseDown:
- mplayer_put_key(l_vo->key_fifo, (MOUSE_BTN0 + buttonNumber) | MP_KEY_DOWN);
+ mplayer_put_key(_vo->key_fifo,
+ (MOUSE_BTN0 + buttonNumber) | MP_KEY_DOWN);
// Looks like Cocoa doesn't create MouseUp events when we are
// doing the second click in a double click. Put in the key_fifo
// the key that would be put from the MouseUp handling code.
if([theEvent clickCount] == 2)
- mplayer_put_key(l_vo->key_fifo, MOUSE_BTN0 + buttonNumber);
+ mplayer_put_key(_vo->key_fifo, MOUSE_BTN0 + buttonNumber);
break;
case NSLeftMouseUp:
case NSRightMouseUp:
case NSOtherMouseUp:
- mplayer_put_key(l_vo->key_fifo, MOUSE_BTN0 + buttonNumber);
+ mplayer_put_key(_vo->key_fifo, MOUSE_BTN0 + buttonNumber);
break;
}
}
}
-- (void) applicationWillBecomeActive:(NSNotification *)aNotification
+- (void)applicationWillBecomeActive:(NSNotification *)aNotification
{
- if (vo_fs) {
- [s->window makeKeyAndOrderFront:s->window];
- [s->window setLevel:s->fullscreen_window_level];
- if (current_screen_has_dock_or_menubar())
- [NSApp setPresentationOptions:NSApplicationPresentationHideDock|
- NSApplicationPresentationHideMenuBar];
+ if (vo_fs && current_screen_has_dock_or_menubar(_vo)) {
+ [NSApp setPresentationOptions:NSApplicationPresentationHideDock|
+ NSApplicationPresentationHideMenuBar];
}
}
-- (void) applicationWillResignActive:(NSNotification *)aNotification
+- (void)applicationWillResignActive:(NSNotification *)aNotification
{
if (vo_fs) {
[NSApp setPresentationOptions:NSApplicationPresentationDefault];
- [s->window setLevel:s->windowed_window_level];
- [s->window orderBack:s->window];
}
}
-- (void) applicationDidFinishLaunching:(NSNotification*)notification
+- (void)applicationDidFinishLaunching:(NSNotification*)notification
{
// Install an event handler so the Quit menu entry works
// The proper way using NSApp setDelegate: and
@@ -702,19 +787,21 @@ void create_menu()
andEventID:kAEQuitApplication];
}
-- (void) normalSize
+- (void)normalSize
{
+ struct vo_cocoa_state *s = _vo->cocoa;
if (!vo_fs)
- [self setContentSize:s->current_video_size keepCentered:YES];
+ [self setContentSize:s->current_video_size keepCentered:YES];
}
-- (void) halfSize { [self mulSize:0.5f];}
+- (void)halfSize { [self mulSize:0.5f];}
-- (void) doubleSize { [self mulSize:2.0f];}
+- (void)doubleSize { [self mulSize:2.0f];}
-- (void) mulSize:(float)multiplier
+- (void)mulSize:(float)multiplier
{
if (!vo_fs) {
+ struct vo_cocoa_state *s = _vo->cocoa;
NSSize size = [[self contentView] frame].size;
size.width = s->current_video_size.width * (multiplier);
size.height = s->current_video_size.height * (multiplier);
@@ -722,33 +809,41 @@ void create_menu()
}
}
-- (void) setContentSize:(NSSize)ns keepCentered:(BOOL)keepCentered
+- (void)setCenteredContentSize:(NSSize)ns
{
- if (keepCentered) {
- NSRect nf = [self frame];
- NSRect vf = [[self screen] visibleFrame];
- int title_height = nf.size.height - [[self contentView] bounds].size.height;
- double ratio = (double)ns.width / (double)ns.height;
-
- // clip the new size to the visibleFrame's size if needed
- if (ns.width > vf.size.width || ns.height + title_height > vf.size.height) {
- ns = vf.size;
- ns.height -= title_height; // make space for the title bar
-
- if (ns.width > ns.height) {
- ns.height = ((double)ns.width * 1/ratio + 0.5);
- } else {
- ns.width = ((double)ns.height * ratio + 0.5);
- }
+ NSRect nf = [self frame];
+ NSRect vf = [[self screen] visibleFrame];
+ NSRect cb = [[self contentView] bounds];
+ int title_height = nf.size.height - cb.size.height;
+ double ratio = (double)ns.width / (double)ns.height;
+
+ // clip the new size to the visibleFrame's size if needed
+ if (ns.width > vf.size.width || ns.height + title_height > vf.size.height) {
+ ns = vf.size;
+ ns.height -= title_height; // make space for the title bar
+
+ if (ns.width > ns.height) {
+ ns.height = ((double)ns.width * 1/ratio + 0.5);
+ } else {
+ ns.width = ((double)ns.height * ratio + 0.5);
}
+ }
- int dw = nf.size.width - ns.width;
- int dh = nf.size.height - ns.height - title_height;
+ int dw = nf.size.width - ns.width;
+ int dh = nf.size.height - ns.height - title_height;
- nf.origin.x += dw / 2;
- nf.origin.y += dh / 2;
+ nf.origin.x += dw / 2;
+ nf.origin.y += dh / 2;
- [self setFrame: NSMakeRect(nf.origin.x, nf.origin.y, ns.width, ns.height + title_height) display:YES animate:NO];
+ NSRect new_frame =
+ NSMakeRect(nf.origin.x, nf.origin.y, ns.width, ns.height + title_height);
+ [self setFrame:new_frame display:YES animate:NO];
+}
+
+- (void)setContentSize:(NSSize)ns keepCentered:(BOOL)keepCentered
+{
+ if (keepCentered) {
+ [self setCenteredContentSize:ns];
} else {
[self setContentSize:ns];
}
@@ -756,7 +851,7 @@ void create_menu()
@end
@implementation GLMPlayerOpenGLView
-- (void) drawRect: (NSRect)rect
+- (void)drawRect: (NSRect)rect
{
[[NSColor clearColor] set];
NSRectFill([self bounds]);
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index 055b386639..90d6ffaa40 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -1996,9 +1996,9 @@ static bool create_window_cocoa(struct MPGLContext *ctx, uint32_t d_width,
getFunctions(ctx->gl, (void *)vo_cocoa_glgetaddr, NULL, gl3);
if (gl3) {
- ctx->depth_r = vo_cocoa_cgl_color_size();
- ctx->depth_g = vo_cocoa_cgl_color_size();
- ctx->depth_b = vo_cocoa_cgl_color_size();
+ ctx->depth_r = vo_cocoa_cgl_color_size(ctx->vo);
+ ctx->depth_g = vo_cocoa_cgl_color_size(ctx->vo);
+ ctx->depth_b = vo_cocoa_cgl_color_size(ctx->vo);
}
if (!ctx->gl->SwapInterval)
@@ -2025,22 +2025,7 @@ static void releaseGlContext_cocoa(MPGLContext *ctx)
static void swapGlBuffers_cocoa(MPGLContext *ctx)
{
- vo_cocoa_swap_buffers();
-}
-
-static int cocoa_check_events(struct vo *vo)
-{
- return vo_cocoa_check_events(vo);
-}
-
-static void cocoa_update_xinerama_info(struct vo *vo)
-{
- vo_cocoa_update_xinerama_info(vo);
-}
-
-static void cocoa_fullscreen(struct vo *vo)
-{
- vo_cocoa_fullscreen(vo);
+ vo_cocoa_swap_buffers(ctx->vo);
}
#endif
@@ -2532,11 +2517,13 @@ MPGLContext *mpgl_init(enum MPGLType type, struct vo *vo)
ctx->create_window_gl3 = create_window_cocoa_gl3;
ctx->releaseGlContext = releaseGlContext_cocoa;
ctx->swapGlBuffers = swapGlBuffers_cocoa;
- ctx->check_events = cocoa_check_events;
- ctx->update_xinerama_info = cocoa_update_xinerama_info;
- ctx->fullscreen = cocoa_fullscreen;
+ ctx->check_events = vo_cocoa_check_events;
+ ctx->update_xinerama_info = vo_cocoa_update_xinerama_info;
+ ctx->fullscreen = vo_cocoa_fullscreen;
ctx->ontop = vo_cocoa_ontop;
ctx->vo_init = vo_cocoa_init;
+ ctx->pause = vo_cocoa_pause;
+ ctx->resume = vo_cocoa_resume;
ctx->vo_uninit = vo_cocoa_uninit;
break;
#endif
diff --git a/libvo/gl_common.h b/libvo/gl_common.h
index d9f227c6aa..9816566097 100644
--- a/libvo/gl_common.h
+++ b/libvo/gl_common.h
@@ -217,6 +217,8 @@ typedef struct MPGLContext {
uint32_t d_height, uint32_t flags);
// optional
+ void (*pause)(struct vo *vo);
+ void (*resume)(struct vo *vo);
void (*ontop)(struct vo *vo);
void (*border)(struct vo *vo);
void (*update_xinerama_info)(struct vo *vo);
diff --git a/libvo/gl_header_fixes.h b/libvo/gl_header_fixes.h
index ebdbbb35b4..d149a9970a 100644
--- a/libvo/gl_header_fixes.h
+++ b/libvo/gl_header_fixes.h
@@ -243,3 +243,15 @@
#define GL_FRAMEBUFFER_SRGB 0x8DB9
#endif
#endif
+
+// FreeBSD 10.0-CURRENT lacks the GLX_ARB_create_context extension completely
+#ifndef GLX_CONTEXT_MAJOR_VERSION_ARB
+#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
+#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
+#define GLX_CONTEXT_FLAGS_ARB 0x2094
+#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
+#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001
+#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
+#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
+#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
+#endif
diff --git a/libvo/video_out.h b/libvo/video_out.h
index efe3624b52..5c8e10a008 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -250,6 +250,7 @@ struct vo {
struct MPOpts *opts;
struct vo_x11_state *x11;
struct vo_w32_state *w32;
+ struct vo_cocoa_state *cocoa;
struct mp_fifo *key_fifo;
struct encode_lavc_context *encode_lavc_ctx;
struct input_ctx *input_ctx;
diff --git a/libvo/vo_corevideo.m b/libvo/vo_corevideo.m
index fb9350cc47..c05863145c 100644
--- a/libvo/vo_corevideo.m
+++ b/libvo/vo_corevideo.m
@@ -226,8 +226,8 @@ static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)
CVReturn error;
if (!p->textureCache || !p->pixelBuffer) {
- error = CVOpenGLTextureCacheCreate(NULL, 0, vo_cocoa_cgl_context(),
- vo_cocoa_cgl_pixel_format(), 0, &p->textureCache);
+ error = CVOpenGLTextureCacheCreate(NULL, 0, vo_cocoa_cgl_context(vo),
+ vo_cocoa_cgl_pixel_format(vo), 0, &p->textureCache);
if(error != kCVReturnSuccess)
mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL"
" texture Cache(%d)\n", error);
@@ -395,6 +395,16 @@ static int control(struct vo *vo, uint32_t request, void *data)
case VOCTRL_ONTOP:
p->mpglctx->ontop(vo);
return VO_TRUE;
+ case VOCTRL_PAUSE:
+ if (!p->mpglctx->pause)
+ break;
+ p->mpglctx->pause(vo);
+ return VO_TRUE;
+ case VOCTRL_RESUME:
+ if (!p->mpglctx->resume)
+ break;
+ p->mpglctx->resume(vo);
+ return VO_TRUE;
case VOCTRL_FULLSCREEN:
p->mpglctx->fullscreen(vo);
resize(vo, vo->dwidth, vo->dheight);
diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c
index bbcce41ca1..2fa71d0d70 100644
--- a/libvo/vo_direct3d.c
+++ b/libvo/vo_direct3d.c
@@ -145,8 +145,6 @@ typedef struct d3d_priv {
fullscreen */
int src_width; /**< Source (movie) width */
int src_height; /**< Source (movie) heigth */
- int src_d_width; /**< Source (movie) aspect corrected width */
- int src_d_height; /**< Source (movie) aspect corrected heigth */
int border_x; /**< horizontal border value for OSD */
int border_y; /**< vertical border value for OSD */
int image_format; /**< mplayer image format */
@@ -1546,9 +1544,6 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
return VO_ERROR;
}
- priv->src_d_width = d_width;
- priv->src_d_height = d_height;
-
if ((priv->image_format != format)
|| (priv->src_width != width)
|| (priv->src_height != height))
@@ -1806,8 +1801,8 @@ static mp_image_t *get_screenshot(d3d_priv *priv)
return NULL;
}
- image->w = priv->src_d_width;
- image->h = priv->src_d_height;
+ image->w = priv->vo->aspdat.prew;
+ image->h = priv->vo->aspdat.preh;
return image;
}
diff --git a/libvo/vo_opengl.c b/libvo/vo_opengl.c
index 8b1b6aaa35..92a280f49b 100644
--- a/libvo/vo_opengl.c
+++ b/libvo/vo_opengl.c
@@ -1773,6 +1773,16 @@ static int control(struct vo *vo, uint32_t request, void *data)
break;
p->glctx->ontop(vo);
return VO_TRUE;
+ case VOCTRL_PAUSE:
+ if (!p->glctx->pause)
+ break;
+ p->glctx->pause(vo);
+ return VO_TRUE;
+ case VOCTRL_RESUME:
+ if (!p->glctx->resume)
+ break;
+ p->glctx->resume(vo);
+ return VO_TRUE;
case VOCTRL_FULLSCREEN:
p->glctx->fullscreen(vo);
resize(p);
@@ -2348,7 +2358,7 @@ static const char help_text[] =
" assumed to be in sRGB.\n"
" pbo\n"
" Enable use of PBOs. This is faster, but can sometimes lead to\n"
-" sparodic and temporary image corruption.\n"
+" sporadic and temporary image corruption.\n"
" dither-depth=<n>\n"
" Positive non-zero values select the target bit depth.\n"
" -1: Disable any dithering done by mpv.\n"
diff --git a/libvo/vo_opengl_old.c b/libvo/vo_opengl_old.c
index e83d45a692..f9262e417d 100644
--- a/libvo/vo_opengl_old.c
+++ b/libvo/vo_opengl_old.c
@@ -73,8 +73,6 @@ struct gl_priv {
uint32_t image_width;
uint32_t image_height;
uint32_t image_format;
- uint32_t image_d_width;
- uint32_t image_d_height;
int many_fmts;
int have_texture_rg;
int ati_hack;
@@ -497,8 +495,6 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
p->image_height = height;
p->image_width = width;
p->image_format = format;
- p->image_d_width = d_width;
- p->image_d_height = d_height;
p->is_yuv = mp_get_chroma_shift(p->image_format, &xs, &ys, NULL) > 0;
p->is_yuv |= (xs << 8) | (ys << 16);
glFindFormat(format, p->have_texture_rg, NULL, &p->texfmt, &p->gl_format,
@@ -829,8 +825,8 @@ static mp_image_t *get_screenshot(struct vo *vo)
image->width = p->image_width;
image->height = p->image_height;
- image->w = p->image_d_width;
- image->h = p->image_d_height;
+ image->w = vo->aspdat.prew;
+ image->h = vo->aspdat.preh;
return image;
}
@@ -1134,6 +1130,16 @@ static int control(struct vo *vo, uint32_t request, void *data)
case VOCTRL_REDRAW_FRAME:
do_render(vo);
return true;
+ case VOCTRL_PAUSE:
+ if (!p->glctx->pause)
+ break;
+ p->glctx->pause(vo);
+ return VO_TRUE;
+ case VOCTRL_RESUME:
+ if (!p->glctx->resume)
+ break;
+ p->glctx->resume(vo);
+ return VO_TRUE;
case VOCTRL_SCREENSHOT: {
struct voctrl_screenshot_args *args = data;
if (args->full_window)
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index 1d4bf8adf7..ba0e0993a2 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -106,8 +106,8 @@ struct vdpctx {
uint64_t last_vdp_time;
unsigned int last_sync_update;
- /* an extra last output surface is used for OSD and screenshots */
VdpOutputSurface output_surfaces[MAX_OUTPUT_SURFACES];
+ VdpOutputSurface screenshot_surface;
int num_output_surfaces;
struct buffered_video_surface {
VdpVideoSurface surface;
@@ -152,7 +152,6 @@ struct vdpctx {
bool dropped_frame;
uint64_t dropped_time;
uint32_t vid_width, vid_height;
- uint32_t vid_d_width, vid_d_height;
uint32_t image_format;
VdpChromaType vdp_chroma_type;
VdpYCbCrFormat vdp_pixel_format;
@@ -390,20 +389,17 @@ static void resize(struct vo *vo)
int flip_offset_ms = vo_fs ? vc->flip_offset_fs : vc->flip_offset_window;
vo->flip_queue_offset = flip_offset_ms / 1000.;
- int min_output_width = FFMAX(vo->dwidth, vc->vid_width);
- int min_output_height = FFMAX(vo->dheight, vc->vid_height);
-
- if (vc->output_surface_width < min_output_width
- || vc->output_surface_height < min_output_height) {
- if (vc->output_surface_width < min_output_width) {
+ if (vc->output_surface_width < vo->dwidth
+ || vc->output_surface_height < vo->dheight) {
+ if (vc->output_surface_width < vo->dwidth) {
vc->output_surface_width += vc->output_surface_width >> 1;
vc->output_surface_width = FFMAX(vc->output_surface_width,
- min_output_width);
+ vo->dwidth);
}
- if (vc->output_surface_height < min_output_height) {
+ if (vc->output_surface_height < vo->dheight) {
vc->output_surface_height += vc->output_surface_height >> 1;
vc->output_surface_height = FFMAX(vc->output_surface_height,
- min_output_height);
+ vo->dheight);
}
// Creation of output_surfaces
for (int i = 0; i < vc->num_output_surfaces; i++)
@@ -705,6 +701,12 @@ static void free_video_specific(struct vo *vo)
CHECK_ST_WARNING("Error when calling vdp_video_mixer_destroy");
}
vc->video_mixer = VDP_INVALID_HANDLE;
+
+ if (vc->screenshot_surface != VDP_INVALID_HANDLE) {
+ vdp_st = vdp->output_surface_destroy(vc->screenshot_surface);
+ CHECK_ST_WARNING("Error when calling vdp_output_surface_destroy");
+ }
+ vc->screenshot_surface = VDP_INVALID_HANDLE;
}
static int create_vdp_decoder(struct vo *vo, int max_refs)
@@ -800,6 +802,7 @@ static void mark_vdpau_objects_uninitialized(struct vo *vo)
vc->flip_target = VDP_INVALID_HANDLE;
for (int i = 0; i < MAX_OUTPUT_SURFACES; i++)
vc->output_surfaces[i] = VDP_INVALID_HANDLE;
+ vc->screenshot_surface = VDP_INVALID_HANDLE;
vc->vdp_device = VDP_INVALID_HANDLE;
for (int i = 0; i < MAX_OSD_PARTS; i++) {
struct osd_bitmap_surface *sfc = &vc->osd_surfaces[i];
@@ -869,8 +872,6 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
vc->image_format = format;
vc->vid_width = width;
vc->vid_height = height;
- vc->vid_d_width = d_width;
- vc->vid_d_height = d_height;
free_video_specific(vo);
if (IMGFMT_IS_VDPAU(vc->image_format) && !create_vdp_decoder(vo, 2))
@@ -1358,12 +1359,12 @@ static void draw_image(struct vo *vo, mp_image_t *mpi, double pts)
// warning: the size and pixel format of surface must match that of the
// surfaces in vc->output_surfaces
static struct mp_image *read_output_surface(struct vdpctx *vc,
- VdpOutputSurface surface)
+ VdpOutputSurface surface,
+ int width, int height)
{
VdpStatus vdp_st;
struct vdp_functions *vdp = vc->vdp;
- struct mp_image *image = alloc_mpi(vc->output_surface_width,
- vc->output_surface_height, IMGFMT_BGR32);
+ struct mp_image *image = alloc_mpi(width, height, IMGFMT_BGR32);
void *dst_planes[] = { image->planes[0] };
uint32_t dst_pitches[] = { image->stride[0] };
@@ -1377,19 +1378,27 @@ static struct mp_image *read_output_surface(struct vdpctx *vc,
static struct mp_image *get_screenshot(struct vo *vo)
{
struct vdpctx *vc = vo->priv;
+ VdpStatus vdp_st;
+ struct vdp_functions *vdp = vc->vdp;
- VdpOutputSurface screenshot_surface =
- vc->output_surfaces[vc->num_output_surfaces];
+ if (vc->screenshot_surface == VDP_INVALID_HANDLE) {
+ vdp_st = vdp->output_surface_create(vc->vdp_device,
+ OUTPUT_RGBA_FORMAT,
+ vc->vid_width, vc->vid_height,
+ &vc->screenshot_surface);
+ CHECK_ST_WARNING("Error when calling vdp_output_surface_create");
+ }
VdpRect rc = { .x1 = vc->vid_width, .y1 = vc->vid_height };
- render_video_to_output_surface(vo, screenshot_surface, &rc);
+ render_video_to_output_surface(vo, vc->screenshot_surface, &rc);
- struct mp_image *image = read_output_surface(vc, screenshot_surface);
+ struct mp_image *image = read_output_surface(vc, vc->screenshot_surface,
+ vc->vid_width, vc->vid_height);
image->width = vc->vid_width;
image->height = vc->vid_height;
- image->w = vc->vid_d_width;
- image->h = vc->vid_d_height;
+ image->w = vo->aspdat.prew;
+ image->h = vo->aspdat.preh;
return image;
}
@@ -1399,7 +1408,9 @@ static struct mp_image *get_window_screenshot(struct vo *vo)
struct vdpctx *vc = vo->priv;
int last_surface = WRAP_ADD(vc->surface_num, -1, vc->num_output_surfaces);
VdpOutputSurface screen = vc->output_surfaces[last_surface];
- struct mp_image *image = read_output_surface(vo->priv, screen);
+ struct mp_image *image = read_output_surface(vo->priv, screen,
+ vc->output_surface_width,
+ vc->output_surface_height);
image->width = image->w = vo->dwidth;
image->height = image->h = vo->dheight;
return image;
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 8095490f4a..390c1753b6 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -76,8 +76,6 @@ struct xvctx {
uint32_t image_width;
uint32_t image_height;
uint32_t image_format;
- uint32_t image_d_width;
- uint32_t image_d_height;
int is_paused;
struct vo_rect src_rect;
struct vo_rect dst_rect;
@@ -123,8 +121,6 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
ctx->image_height = height;
ctx->image_width = width;
ctx->image_format = format;
- ctx->image_d_width = d_width;
- ctx->image_d_height = d_height;
if ((ctx->max_width != 0 && ctx->max_height != 0)
&& (ctx->image_width > ctx->max_width
@@ -426,8 +422,8 @@ static mp_image_t *get_screenshot(struct vo *vo)
// try to get an image without OSD
int id = ctx->have_image_copy ? ctx->num_buffers : ctx->visible_buf;
struct mp_image img = get_xv_buffer(vo, id);
- img.w = ctx->image_d_width;
- img.h = ctx->image_d_height;
+ img.w = vo->aspdat.prew;
+ img.h = vo->aspdat.preh;
return talloc_memdup(NULL, &img, sizeof(img));
}
@@ -462,7 +458,7 @@ static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)
static int query_format(struct xvctx *ctx, uint32_t format)
{
uint32_t i;
- int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_OSD | VFCAP_OSD | VFCAP_ACCEPT_STRIDE; // FIXME! check for DOWN
+ int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_OSD | VFCAP_ACCEPT_STRIDE; // FIXME! check for DOWN
/* check image formats */
for (i = 0; i < ctx->formats; i++) {