mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
Use the standard MPlayer aspect handling instead of reimplementing our own in vo_quartz.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29572 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
6901602578
commit
1ba0432474
@ -87,8 +87,7 @@ static int EnterMoviesDone = 0;
|
|||||||
static int get_image_done = 0;
|
static int get_image_done = 0;
|
||||||
|
|
||||||
static int vo_quartz_fs; // we are in fullscreen
|
static int vo_quartz_fs; // we are in fullscreen
|
||||||
extern float monitor_aspect;
|
static int our_aspect_change;
|
||||||
extern float movie_aspect;
|
|
||||||
static float old_movie_aspect;
|
static float old_movie_aspect;
|
||||||
|
|
||||||
static int winLevel = 1;
|
static int winLevel = 1;
|
||||||
@ -121,7 +120,6 @@ static Rect imgRect; // size of the original image (unscaled)
|
|||||||
static Rect dstRect; // size of the displayed image (after scaling)
|
static Rect dstRect; // size of the displayed image (after scaling)
|
||||||
static Rect winRect; // size of the window containg the displayed image (include padding)
|
static Rect winRect; // size of the window containg the displayed image (include padding)
|
||||||
static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode
|
static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode
|
||||||
static CGRect displayRect; // size of the display device
|
|
||||||
static Rect oldWinBounds;
|
static Rect oldWinBounds;
|
||||||
|
|
||||||
static MenuRef windMenu;
|
static MenuRef windMenu;
|
||||||
@ -391,6 +389,7 @@ static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef even
|
|||||||
//default window event handler
|
//default window event handler
|
||||||
static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
|
static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
|
||||||
{
|
{
|
||||||
|
char cmd_str[64];
|
||||||
OSStatus result = noErr;
|
OSStatus result = noErr;
|
||||||
uint32_t d_width;
|
uint32_t d_width;
|
||||||
uint32_t d_height;
|
uint32_t d_height;
|
||||||
@ -420,7 +419,7 @@ static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef eve
|
|||||||
window_fullscreen();
|
window_fullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
SizeWindow(theWindow, (d_width / 2), ((d_width / movie_aspect) / 2), 1);
|
SizeWindow(theWindow, d_width / 2, d_height / 2, 1);
|
||||||
window_resized();
|
window_resized();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -431,7 +430,7 @@ static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef eve
|
|||||||
window_fullscreen();
|
window_fullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
SizeWindow(theWindow, d_width, (d_width / movie_aspect), 1);
|
SizeWindow(theWindow, d_width, d_height, 1);
|
||||||
window_resized();
|
window_resized();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -442,7 +441,7 @@ static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef eve
|
|||||||
window_fullscreen();
|
window_fullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
SizeWindow(theWindow, (d_width * 2), ((d_width / movie_aspect) * 2), 1);
|
SizeWindow(theWindow, d_width * 2, d_height * 2, 1);
|
||||||
window_resized();
|
window_resized();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -458,30 +457,19 @@ static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef eve
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kAspectOrgCmd:
|
case kAspectOrgCmd:
|
||||||
movie_aspect = old_movie_aspect;
|
our_aspect_change = 1;
|
||||||
if (!vo_quartz_fs)
|
sprintf(cmd_str, "switch_ratio %f", old_movie_aspect);
|
||||||
{
|
mp_input_queue_cmd(mp_input_parse_cmd(cmd_str));
|
||||||
SizeWindow(theWindow, dstRect.right, (dstRect.right / movie_aspect), 1);
|
|
||||||
}
|
|
||||||
window_resized();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kAspectFullCmd:
|
case kAspectFullCmd:
|
||||||
movie_aspect = 4.0f / 3.0f;
|
our_aspect_change = 1;
|
||||||
if (!vo_quartz_fs)
|
mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 1.6667"));
|
||||||
{
|
|
||||||
SizeWindow(theWindow, dstRect.right, (dstRect.right / movie_aspect), 1);
|
|
||||||
}
|
|
||||||
window_resized();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kAspectWideCmd:
|
case kAspectWideCmd:
|
||||||
movie_aspect = 16.0f / 9.0f;
|
our_aspect_change = 1;
|
||||||
if (!vo_quartz_fs)
|
mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 1.7778"));
|
||||||
{
|
|
||||||
SizeWindow(theWindow, dstRect.right, (dstRect.right / movie_aspect), 1);
|
|
||||||
}
|
|
||||||
window_resized();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kPanScanCmd:
|
case kPanScanCmd:
|
||||||
@ -631,16 +619,11 @@ static void quartz_CreateWindow(uint32_t d_width, uint32_t d_height, WindowAttri
|
|||||||
InstallWindowEventHandler(theWindow, NewEventHandlerUPP(WindowEventHandler), GetEventTypeCount(win_events), win_events, theWindow, NULL);
|
InstallWindowEventHandler(theWindow, NewEventHandlerUPP(WindowEventHandler), GetEventTypeCount(win_events), win_events, theWindow, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
|
static void update_screen_info(void)
|
||||||
{
|
{
|
||||||
WindowAttributes windowAttrs;
|
CGRect displayRect;
|
||||||
OSErr qterr;
|
|
||||||
CGRect tmpBounds;
|
|
||||||
CGDisplayCount displayCount;
|
CGDisplayCount displayCount;
|
||||||
CGDirectDisplayID *displays;
|
CGDirectDisplayID *displays;
|
||||||
|
|
||||||
// Get Main device info///////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Display IDs might not be consecutive, get the list of all devices up to # device_id
|
// Display IDs might not be consecutive, get the list of all devices up to # device_id
|
||||||
displayCount = device_id + 1;
|
displayCount = device_id + 1;
|
||||||
displays = malloc(sizeof(CGDirectDisplayID) * displayCount);
|
displays = malloc(sizeof(CGDirectDisplayID) * displayCount);
|
||||||
@ -656,8 +639,22 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
|
|||||||
free(displays);
|
free(displays);
|
||||||
|
|
||||||
displayRect = CGDisplayBounds(displayId);
|
displayRect = CGDisplayBounds(displayId);
|
||||||
|
xinerama_x = displayRect.origin.x;
|
||||||
|
xinerama_y = displayRect.origin.y;
|
||||||
|
vo_screenwidth = displayRect.size.width;
|
||||||
|
vo_screenheight = displayRect.size.height;
|
||||||
|
aspect_save_screenres(vo_screenwidth, vo_screenheight);
|
||||||
|
}
|
||||||
|
|
||||||
monitor_aspect = (float)displayRect.size.width / (float)displayRect.size.height;
|
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
|
||||||
|
{
|
||||||
|
WindowAttributes windowAttrs;
|
||||||
|
OSErr qterr;
|
||||||
|
CGRect tmpBounds;
|
||||||
|
|
||||||
|
if (!our_aspect_change)
|
||||||
|
old_movie_aspect = (float)d_width / d_height;
|
||||||
|
our_aspect_change = 0;
|
||||||
|
|
||||||
// misc mplayer setup/////////////////////////////////////////////////////
|
// misc mplayer setup/////////////////////////////////////////////////////
|
||||||
SetRect(&imgRect, 0, 0, width, height);
|
SetRect(&imgRect, 0, 0, width, height);
|
||||||
@ -676,19 +673,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
|
|||||||
}
|
}
|
||||||
image_size = ((imgRect.right * imgRect.bottom * image_depth) + 7) / 8;
|
image_size = ((imgRect.right * imgRect.bottom * image_depth) + 7) / 8;
|
||||||
|
|
||||||
vo_fs = flags & VOFLAG_FULLSCREEN;
|
|
||||||
|
|
||||||
// get movie aspect
|
|
||||||
panscan_init();
|
|
||||||
aspect_save_orig(width, height);
|
|
||||||
aspect_save_prescale(d_width, d_height);
|
|
||||||
aspect_save_screenres(displayRect.size.width, displayRect.size.height);
|
|
||||||
|
|
||||||
aspect(&d_width, &d_height, A_NOZOOM);
|
|
||||||
|
|
||||||
movie_aspect = (float)d_width / (float)d_height;
|
|
||||||
old_movie_aspect = movie_aspect;
|
|
||||||
|
|
||||||
if (image_data)
|
if (image_data)
|
||||||
free(image_data);
|
free(image_data);
|
||||||
|
|
||||||
@ -1294,17 +1278,15 @@ static int control(uint32_t request, void *data, ...)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case VOCTRL_UPDATE_SCREENINFO:
|
||||||
|
update_screen_info();
|
||||||
|
return VO_TRUE;
|
||||||
}
|
}
|
||||||
return VO_NOTIMPL;
|
return VO_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_resized(void)
|
void window_resized(void)
|
||||||
{
|
{
|
||||||
float aspectX;
|
|
||||||
float aspectY;
|
|
||||||
|
|
||||||
int padding = 0;
|
|
||||||
|
|
||||||
uint32_t d_width;
|
uint32_t d_width;
|
||||||
uint32_t d_height;
|
uint32_t d_height;
|
||||||
|
|
||||||
@ -1313,30 +1295,12 @@ void window_resized(void)
|
|||||||
CGContextRef context;
|
CGContextRef context;
|
||||||
|
|
||||||
GetWindowPortBounds(theWindow, &winRect);
|
GetWindowPortBounds(theWindow, &winRect);
|
||||||
|
d_width = vo_dwidth = winRect.right;
|
||||||
|
d_height = vo_dheight = winRect.bottom;
|
||||||
|
|
||||||
if (vo_keepaspect)
|
if (vo_keepaspect)
|
||||||
{
|
aspect(&d_width, &d_height, A_WINZOOM);
|
||||||
aspect(&d_width, &d_height, A_NOZOOM);
|
SetRect(&dstRect, (vo_dwidth - d_width) / 2, (vo_dheight - d_height) / 2, d_width, d_height);
|
||||||
d_height = ((float)d_width / movie_aspect);
|
|
||||||
|
|
||||||
aspectX = (float)((float)winRect.right / (float)d_width);
|
|
||||||
aspectY = (float)((float)(winRect.bottom) / (float)d_height);
|
|
||||||
|
|
||||||
if ((d_height * aspectX) > (winRect.bottom))
|
|
||||||
{
|
|
||||||
padding = (winRect.right - d_width * aspectY) / 2;
|
|
||||||
SetRect(&dstRect, padding, 0, d_width * aspectY + padding, d_height * aspectY);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
padding = ((winRect.bottom) - d_height * aspectX) / 2;
|
|
||||||
SetRect(&dstRect, 0, padding, (d_width * aspectX), d_height * aspectX + padding);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetRect(&dstRect, 0, 0, winRect.right, winRect.bottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (image_format)
|
switch (image_format)
|
||||||
{
|
{
|
||||||
@ -1359,7 +1323,7 @@ void window_resized(void)
|
|||||||
{
|
{
|
||||||
ScaleMatrix(&matrix, scale_X, scale_Y, 0, 0);
|
ScaleMatrix(&matrix, scale_X, scale_Y, 0, 0);
|
||||||
|
|
||||||
if (padding > 0)
|
if (vo_dwidth > d_width || vo_dheight > d_height)
|
||||||
{
|
{
|
||||||
TranslateMatrix(&matrix, Long2Fix(dstRect.left), Long2Fix(dstRect.top));
|
TranslateMatrix(&matrix, Long2Fix(dstRect.left), Long2Fix(dstRect.top));
|
||||||
}
|
}
|
||||||
@ -1432,7 +1396,7 @@ void window_fullscreen(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get Main device info///////////////////////////////////////////////////
|
// Get Main device info///////////////////////////////////////////////////
|
||||||
displayRect = CGDisplayBounds(displayId);
|
update_screen_info();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// save old window size
|
// save old window size
|
||||||
@ -1442,12 +1406,10 @@ void window_fullscreen(void)
|
|||||||
GetWindowBounds(theWindow, kWindowContentRgn, &oldWinBounds);
|
GetWindowBounds(theWindow, kWindowContentRgn, &oldWinBounds);
|
||||||
}
|
}
|
||||||
// go fullscreen
|
// go fullscreen
|
||||||
panscan_calc();
|
|
||||||
ChangeWindowAttributes(theWindow, kWindowNoShadowAttribute, 0);
|
ChangeWindowAttributes(theWindow, kWindowNoShadowAttribute, 0);
|
||||||
MoveWindow(theWindow, displayRect.origin.x - (vo_panscan_x >> 1), displayRect.origin.y - (vo_panscan_y >> 1), 1);
|
|
||||||
SizeWindow(theWindow, displayRect.size.width + vo_panscan_x, displayRect.size.height + vo_panscan_y, 1);
|
|
||||||
|
|
||||||
vo_quartz_fs = 1;
|
vo_quartz_fs = 1;
|
||||||
|
window_panscan();
|
||||||
}
|
}
|
||||||
else //go back to windowed mode
|
else //go back to windowed mode
|
||||||
{
|
{
|
||||||
@ -1458,7 +1420,7 @@ void window_fullscreen(void)
|
|||||||
CGDisplayRelease(displayId);
|
CGDisplayRelease(displayId);
|
||||||
|
|
||||||
// Get Main device info///////////////////////////////////////////////////
|
// Get Main device info///////////////////////////////////////////////////
|
||||||
displayRect = CGDisplayBounds(displayId);
|
update_screen_info();
|
||||||
|
|
||||||
originalMode = NULL;
|
originalMode = NULL;
|
||||||
}
|
}
|
||||||
@ -1487,7 +1449,7 @@ void window_panscan(void)
|
|||||||
|
|
||||||
if (vo_quartz_fs)
|
if (vo_quartz_fs)
|
||||||
{
|
{
|
||||||
MoveWindow(theWindow, displayRect.origin.x - (vo_panscan_x >> 1), displayRect.origin.y - (vo_panscan_y >> 1), 1);
|
MoveWindow(theWindow, xinerama_x - (vo_panscan_x >> 1), xinerama_y - (vo_panscan_y >> 1), 1);
|
||||||
SizeWindow(theWindow, displayRect.size.width + vo_panscan_x, displayRect.size.height + vo_panscan_y, 1);
|
SizeWindow(theWindow, vo_screenwidth + vo_panscan_x, vo_screenheight + vo_panscan_y, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user