Mercurial > mplayer.hg
annotate libvo/vo_quartz.c @ 12582:162c80b2d432
major reindentation of x11 code try #2
note that this is plain ident output, i didnt tweak it by
hand like the last attempt.
if anyone is interested in the indent profile i used, just drop me a mail.
please contact me on irc on how to send me my share of cola,
but be aware that i will only accept swiss or german cola, as the japanese is
way to sweet :)
author | attila |
---|---|
date | Mon, 14 Jun 2004 04:53:03 +0000 |
parents | 12a87d539f6d |
children | e64e106c8798 |
rev | line source |
---|---|
12296 | 1 /* |
2 vo_quartz.c | |
3 | |
4 by Nicolas Plourde <nicolasplourde@hotmail.com> | |
5 | |
6 Copyright (c) Nicolas Plourde - April 2004 | |
12414 | 7 |
8 YUV support Copyright (C) 2004 Romain Dolbeau <romain@dolbeau.org> | |
12296 | 9 |
10 MPlayer Mac OSX Quartz video out module. | |
11 | |
12432 | 12 todo: -'plist' resource |
13 -Choose fullscreen display device (-xineramascreen / -multiscreen). | |
12296 | 14 -resize black bar without CGContext |
15 -rootwin | |
12460 | 16 -screen overlay output |
12296 | 17 -non-blocking event |
18 -(add sugestion here) | |
12120 | 19 */ |
20 | |
21 //SYS | |
22 #include <stdio.h> | |
23 | |
24 //OSX | |
25 #include <Carbon/Carbon.h> | |
12414 | 26 #include <QuickTime/QuickTime.h> |
12120 | 27 |
28 //MPLAYER | |
29 #include "config.h" | |
12414 | 30 #include "fastmemcpy.h" |
12120 | 31 #include "video_out.h" |
32 #include "video_out_internal.h" | |
33 #include "aspect.h" | |
12414 | 34 #include "mp_msg.h" |
35 #include "m_option.h" | |
12120 | 36 |
37 #include "../input/input.h" | |
38 #include "../input/mouse.h" | |
39 | |
40 #include "vo_quartz.h" | |
41 | |
12296 | 42 static vo_info_t info = |
43 { | |
44 "Mac OSX (Quartz)", | |
45 "quartz", | |
12414 | 46 "Nicolas Plourde <nicolasplourde@hotmail.com>, Romain Dolbeau <romain@dolbeau.org>", |
12296 | 47 "" |
12120 | 48 }; |
49 | |
12296 | 50 LIBVO_EXTERN(quartz) |
12120 | 51 |
12414 | 52 static uint32_t image_depth; |
53 static uint32_t image_format; | |
54 static uint32_t image_size; | |
55 static uint32_t image_buffer_size; | |
12432 | 56 static char *image_data; |
12414 | 57 |
12432 | 58 static ImageSequence seqId; |
12414 | 59 static CodecType image_qtcodec; |
12487 | 60 static PlanarPixmapInfoYUV420 *P = NULL; |
12424 | 61 static struct |
62 { | |
63 ImageDescriptionHandle desc; | |
64 Handle extension_colr; | |
65 Handle extension_fiel; | |
66 Handle extension_clap; | |
67 Handle extension_pasp; | |
12414 | 68 } yuv_qt_stuff; |
12432 | 69 static MatrixRecord matrix; |
12414 | 70 static int EnterMoviesDone = 0; |
12487 | 71 static int get_image_done = 0; |
12120 | 72 |
12296 | 73 extern int vo_ontop; |
12487 | 74 extern int vo_fs; // user want fullscreen |
75 static int vo_quartz_fs; // we are in fullscreen | |
12120 | 76 |
12487 | 77 static int int_pause = 0; |
78 static float winAlpha = 1; | |
12296 | 79 |
12487 | 80 static int device_width; |
81 static int device_height; | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
82 static int device_id; |
12120 | 83 |
12487 | 84 static WindowRef theWindow = NULL; |
12296 | 85 |
12487 | 86 static Rect imgRect; // size of the original image (unscaled) |
87 static Rect dstRect; // size of the displayed image (after scaling) | |
88 static Rect winRect; // size of the window containg the displayed image (include padding) | |
89 static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
90 static Rect deviceRect; // size of the display device |
12296 | 91 |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
92 CGrafPtr gDisplayPortPtr; |
12120 | 93 |
94 #include "../osdep/keycodes.h" | |
12296 | 95 extern void mplayer_put_key(int code); |
96 | |
97 extern void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); | |
12120 | 98 |
99 //PROTOTYPE///////////////////////////////////////////////////////////////// | |
12296 | 100 void window_resized(); |
101 void window_ontop(); | |
102 void window_fullscreen(); | |
12120 | 103 |
12460 | 104 static OSStatus MainEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); |
12296 | 105 |
106 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) | |
107 { | |
12424 | 108 switch (image_format) |
109 { | |
110 case IMGFMT_RGB32: | |
111 vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*imgRect.right+x0),4*imgRect.right); | |
112 break; | |
113 case IMGFMT_YV12: | |
114 case IMGFMT_IYUV: | |
115 case IMGFMT_I420: | |
12487 | 116 vo_draw_alpha_yv12(w,h,src,srca,stride, ((char*)P) + P->componentInfoY.offset + x0 + y0 * imgRect.right, imgRect.right); |
12424 | 117 break; |
118 case IMGFMT_UYVY: | |
12517 | 119 vo_draw_alpha_uyvy(w,h,src,srca,stride,((char*)P) + (x0 + y0 * imgRect.right) * 2,imgRect.right*2); |
12424 | 120 break; |
121 case IMGFMT_YUY2: | |
12487 | 122 vo_draw_alpha_yuy2(w,h,src,srca,stride,((char*)P) + (x0 + y0 * imgRect.right) * 2,imgRect.right*2); |
12424 | 123 break; |
12487 | 124 } |
12296 | 125 } |
12120 | 126 |
127 //default window event handler | |
12460 | 128 static OSStatus MainEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) |
12120 | 129 { |
12296 | 130 OSStatus err = noErr; |
12460 | 131 OSStatus result = eventNotHandledErr; |
132 UInt32 class = GetEventClass (event); | |
133 UInt32 kind = GetEventKind (event); | |
134 | |
135 if(class == kEventClassWindow) | |
136 { | |
137 WindowRef window; | |
138 Rect rectPort = {0,0,0,0}; | |
139 | |
140 GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window); | |
141 | |
142 if(window) | |
143 { | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
144 GetPortBounds(GetWindowPort(window), &rectPort); |
12460 | 145 } |
12296 | 146 |
12460 | 147 switch (kind) |
148 { | |
149 //close window | |
150 case kEventWindowClosed: | |
151 mplayer_put_key(KEY_ESC); | |
152 break; | |
153 | |
154 //resize window | |
155 case kEventWindowBoundsChanged: | |
156 window_resized(); | |
157 flip_page(); | |
158 break; | |
159 | |
160 default: | |
161 err = eventNotHandledErr; | |
162 break; | |
163 } | |
164 } | |
165 else if(class == kEventClassKeyboard) | |
166 { | |
167 char macCharCodes; | |
168 UInt32 macKeyCode; | |
169 UInt32 macKeyModifiers; | |
170 | |
171 GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(macCharCodes), NULL, &macCharCodes); | |
172 GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(macKeyCode), NULL, &macKeyCode); | |
173 GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(macKeyModifiers), NULL, &macKeyModifiers); | |
12296 | 174 |
12460 | 175 switch (kind) |
12296 | 176 { |
12460 | 177 case kEventRawKeyDown: |
178 { | |
179 switch(macKeyCode) | |
180 { | |
181 case QZ_RETURN: mplayer_put_key(KEY_ENTER);break; | |
182 case QZ_ESCAPE: mplayer_put_key(KEY_ESC);break; | |
183 case QZ_F1: mplayer_put_key(KEY_F+1);break; | |
184 case QZ_F2: mplayer_put_key(KEY_F+2);break; | |
185 case QZ_F3: mplayer_put_key(KEY_F+3);break; | |
186 case QZ_F4: mplayer_put_key(KEY_F+4);break; | |
187 case QZ_F5: mplayer_put_key(KEY_F+5);break; | |
188 case QZ_F6: mplayer_put_key(KEY_F+6);break; | |
189 case QZ_F7: mplayer_put_key(KEY_F+7);break; | |
190 case QZ_F8: mplayer_put_key(KEY_F+8);break; | |
191 case QZ_F9: mplayer_put_key(KEY_F+9);break; | |
192 case QZ_F10: mplayer_put_key(KEY_F+10);break; | |
193 case QZ_F11: mplayer_put_key(KEY_F+11);break; | |
194 case QZ_F12: mplayer_put_key(KEY_F+12);break; | |
195 //case QZ_7: mplayer_put_key(shift_key?'/':'7'); | |
196 //case QZ_PLUS: mplayer_put_key(shift_key?'*':'+'); | |
197 case QZ_KP_PLUS: mplayer_put_key('+');break; | |
198 case QZ_MINUS: | |
199 case QZ_KP_MINUS: mplayer_put_key('-');break; | |
200 case QZ_TAB: mplayer_put_key('\t');break; | |
201 case QZ_PAGEUP: mplayer_put_key(KEY_PAGE_UP);break; | |
202 case QZ_PAGEDOWN: mplayer_put_key(KEY_PAGE_DOWN);break; | |
203 case QZ_UP: mplayer_put_key(KEY_UP);break; | |
204 case QZ_DOWN: mplayer_put_key(KEY_DOWN);break; | |
205 case QZ_LEFT: mplayer_put_key(KEY_LEFT);break; | |
206 case QZ_RIGHT: mplayer_put_key(KEY_RIGHT);break; | |
207 case QZ_KP_MULTIPLY: mplayer_put_key('*'); break; | |
208 case QZ_SLASH: | |
209 case QZ_KP_DIVIDE: mplayer_put_key('/'); break; | |
210 case QZ_KP0: mplayer_put_key(KEY_KP0); break; | |
211 case QZ_KP1: mplayer_put_key(KEY_KP1); break; | |
212 case QZ_KP2: mplayer_put_key(KEY_KP2); break; | |
213 case QZ_KP3: mplayer_put_key(KEY_KP3); break; | |
214 case QZ_KP4: mplayer_put_key(KEY_KP4); break; | |
215 case QZ_KP5: mplayer_put_key(KEY_KP5); break; | |
216 case QZ_KP6: mplayer_put_key(KEY_KP6); break; | |
217 case QZ_KP7: mplayer_put_key(KEY_KP7); break; | |
218 case QZ_KP8: mplayer_put_key(KEY_KP8); break; | |
219 case QZ_KP9: mplayer_put_key(KEY_KP9); break; | |
220 case QZ_KP_PERIOD: mplayer_put_key(KEY_KPDEC); break; | |
221 case QZ_KP_ENTER: mplayer_put_key(KEY_KPENTER); break; | |
222 case QZ_LEFTBRACKET: SetWindowAlpha(theWindow, winAlpha-=0.05);break; | |
223 case QZ_RIGHTBRACKET: SetWindowAlpha(theWindow, winAlpha+=0.05);break; | |
224 | |
225 default:mplayer_put_key(macCharCodes);break; | |
226 } | |
227 } | |
228 | |
229 default: | |
230 err = eventNotHandledErr; | |
231 break; | |
232 } | |
233 } | |
234 else if(class == kEventClassMouse) | |
235 { | |
236 WindowPtr tmpWin; | |
237 Point mousePos; | |
238 | |
239 GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &mousePos); | |
240 | |
241 switch (kind) | |
242 { | |
243 case kEventMouseDown: | |
12296 | 244 { |
12460 | 245 EventMouseButton button; |
246 GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(EventMouseButton), 0, &button); | |
247 | |
12296 | 248 short part = FindWindow(mousePos,&tmpWin); |
249 | |
250 if(part == inMenuBar) | |
251 { | |
252 MenuSelect(mousePos); | |
12460 | 253 HiliteMenu(0); |
12296 | 254 } |
12460 | 255 else if(part == inContent) |
256 { | |
257 switch(button) | |
258 { | |
259 case 1: mplayer_put_key(MOUSE_BTN0);break; | |
260 case 2: mplayer_put_key(MOUSE_BTN2);break; | |
261 case 3: mplayer_put_key(MOUSE_BTN1);break; | |
262 | |
263 default:break; | |
264 } | |
265 } | |
266 } | |
267 break; | |
268 | |
269 case kEventMouseWheelMoved: | |
270 { | |
271 int wheel; | |
272 GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0, sizeof(int), 0, &wheel); | |
273 | |
274 short part = FindWindow(mousePos,&tmpWin); | |
275 | |
276 if(part == inContent) | |
277 { | |
278 if(wheel > 0) | |
279 mplayer_put_key(MOUSE_BTN3); | |
280 else | |
281 mplayer_put_key(MOUSE_BTN4); | |
282 } | |
283 } | |
284 break; | |
285 | |
286 default: | |
287 err = eventNotHandledErr; | |
288 break; | |
289 } | |
290 } | |
291 | |
12296 | 292 return err; |
293 } | |
12120 | 294 |
12487 | 295 static void quartz_CreateWindow(uint32_t d_width, uint32_t d_height, WindowAttributes windowAttrs) |
296 { | |
297 CFStringRef titleKey; | |
298 CFStringRef windowTitle; | |
299 OSStatus result; | |
300 | |
301 SetRect(&winRect, 0, 0, d_width, d_height); | |
302 SetRect(&oldWinRect, 0, 0, d_width, d_height); | |
303 SetRect(&dstRect, 0, 0, d_width, d_height); | |
304 | |
305 CreateNewWindow(kDocumentWindowClass, windowAttrs, &winRect, &theWindow); | |
306 | |
307 //Set window title | |
308 titleKey = CFSTR("MPlayer"); | |
309 windowTitle = CFCopyLocalizedString(titleKey, NULL); | |
310 result = SetWindowTitleWithCFString(theWindow, windowTitle); | |
311 CFRelease(titleKey); | |
312 CFRelease(windowTitle); | |
313 | |
314 //Install event handler | |
315 const EventTypeSpec winEvents[] = { { kEventClassKeyboard, kEventRawKeyDown }, | |
316 { kEventClassMouse, kEventMouseDown }, | |
317 { kEventClassMouse, kEventMouseWheelMoved }, | |
318 { kEventClassWindow, kEventWindowClosed }, | |
319 { kEventClassWindow, kEventWindowBoundsChanged } }; | |
320 | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
321 InstallApplicationEventHandler (NewEventHandlerUPP (MainEventHandler), GetEventTypeCount(winEvents), winEvents, NULL, NULL); |
12487 | 322 } |
323 | |
12296 | 324 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
325 { | |
326 WindowAttributes windowAttrs; | |
327 GDHandle deviceHdl; | |
12414 | 328 OSErr qterr; |
12296 | 329 |
330 //Get Main device info/////////////////////////////////////////////////// | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
331 int i; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
332 |
12296 | 333 deviceHdl = GetMainDevice(); |
334 | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
335 for(i=0; i<device_id; i++) |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
336 { |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
337 deviceHdl = GetNextDevice(deviceHdl); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
338 |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
339 if(deviceHdl == NULL) |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
340 { |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
341 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Device ID %d do not exist, falling back to main device.\n", device_id); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
342 deviceHdl = GetMainDevice(); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
343 break; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
344 } |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
345 } |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
346 |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
347 deviceRect = (*deviceHdl)->gdRect; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
348 device_width = deviceRect.right-deviceRect.left; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
349 device_height = deviceRect.bottom-deviceRect.top; |
12296 | 350 |
351 //misc mplayer setup///////////////////////////////////////////////////// | |
12487 | 352 SetRect(&imgRect, 0, 0, width, height); |
12414 | 353 switch (image_format) |
354 { | |
355 case IMGFMT_RGB32: | |
12432 | 356 image_depth = 32; |
12414 | 357 break; |
358 case IMGFMT_YV12: | |
359 case IMGFMT_IYUV: | |
360 case IMGFMT_I420: | |
361 case IMGFMT_UYVY: | |
362 case IMGFMT_YUY2: | |
363 image_depth = 16; | |
364 break; | |
365 } | |
12487 | 366 image_size = ((imgRect.right*imgRect.bottom*image_depth)+7)/8; |
12296 | 367 |
368 vo_fs = flags & VOFLAG_FULLSCREEN; | |
369 | |
370 //get movie aspect | |
371 aspect_save_orig(width,height); | |
372 aspect_save_prescale(d_width,d_height); | |
373 aspect_save_screenres(device_width, device_height); | |
374 | |
375 aspect(&d_width,&d_height,A_NOZOOM); | |
376 | |
377 //Create player window////////////////////////////////////////////////// | |
378 windowAttrs = kWindowStandardDocumentAttributes | |
379 | kWindowStandardHandlerAttribute | |
380 | kWindowLiveResizeAttribute; | |
12425 | 381 |
12432 | 382 windowAttrs &= (~kWindowResizableAttribute); |
12296 | 383 |
12487 | 384 if (theWindow == NULL) |
385 { | |
386 quartz_CreateWindow(d_width, d_height, windowAttrs); | |
387 | |
388 if (theWindow == NULL) | |
389 { | |
390 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Couldn't create window !!!!!\n"); | |
391 return -1; | |
392 } | |
393 } | |
394 else | |
395 { | |
396 HideWindow(theWindow); | |
397 ChangeWindowAttributes(theWindow, ~windowAttrs, windowAttrs); | |
398 SetRect(&winRect, 0, 0, d_width, d_height); | |
399 SetRect(&oldWinRect, 0, 0, d_width, d_height); | |
400 SizeWindow (theWindow, d_width, d_height, 1); | |
401 } | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
402 |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
403 gDisplayPortPtr = GetWindowPort(theWindow); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
404 |
12487 | 405 get_image_done = 0; |
12296 | 406 |
12432 | 407 if (!EnterMoviesDone) |
408 { | |
409 qterr = EnterMovies(); | |
410 EnterMoviesDone = 1; | |
411 } | |
412 else | |
413 qterr = 0; | |
414 | |
415 if (qterr) | |
12424 | 416 { |
12432 | 417 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: EnterMovies (%d)\n", qterr); |
12487 | 418 return -1; |
12432 | 419 } |
420 | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
421 SetPort(gDisplayPortPtr); |
12432 | 422 SetIdentityMatrix(&matrix); |
423 | |
424 if ((d_width != width) || (d_height != height)) | |
425 { | |
426 ScaleMatrix(&matrix, FixDiv(Long2Fix(d_width),Long2Fix(width)), FixDiv(Long2Fix(d_height),Long2Fix(height)), 0, 0); | |
427 } | |
12433 | 428 |
12432 | 429 switch (image_format) |
430 { | |
431 case IMGFMT_RGB32: | |
12424 | 432 { |
12432 | 433 ImageDescriptionHandle desc; |
12487 | 434 GWorldPtr imgGWorld; |
12432 | 435 image_data = calloc(sizeof(image_size),1); |
12487 | 436 NewGWorldFromPtr (&imgGWorld, k32ARGBPixelFormat, &imgRect, 0, 0, 0, image_data, imgRect.right * 4); |
12432 | 437 MakeImageDescriptionForPixMap(GetGWorldPixMap(imgGWorld), &desc); |
438 DisposeGWorld(imgGWorld); | |
12424 | 439 |
12432 | 440 qterr = DecompressSequenceBeginS ( &seqId, |
441 desc, | |
442 image_data, | |
443 image_size, | |
444 GetWindowPort(theWindow), | |
445 NULL, | |
446 NULL, | |
447 ((d_width != width) || (d_height != height)) ? &matrix : NULL, | |
448 srcCopy, | |
449 NULL, | |
450 0, | |
451 codecLosslessQuality, | |
452 bestSpeedCodec); | |
12487 | 453 free(image_data); |
454 image_data = NULL; | |
12424 | 455 if (qterr) |
456 { | |
12432 | 457 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: DecompressSequenceBeginS (%d)\n", qterr); |
12487 | 458 return -1; |
12424 | 459 } |
460 } | |
12432 | 461 break; |
12424 | 462 |
12432 | 463 case IMGFMT_YV12: |
464 case IMGFMT_IYUV: | |
465 case IMGFMT_I420: | |
466 case IMGFMT_UYVY: | |
467 case IMGFMT_YUY2: | |
12424 | 468 { |
12432 | 469 yuv_qt_stuff.desc = (ImageDescriptionHandle)NewHandleClear( sizeof(ImageDescription) ); |
12424 | 470 |
12432 | 471 yuv_qt_stuff.extension_colr = NewHandleClear(sizeof(NCLCColorInfoImageDescriptionExtension)); |
472 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->colorParamType = kVideoColorInfoImageDescriptionExtensionType; | |
473 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->primaries = 2; | |
474 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->transferFunction = 2; | |
475 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->matrix = 2; | |
476 | |
477 yuv_qt_stuff.extension_fiel = NewHandleClear(sizeof(FieldInfoImageDescriptionExtension)); | |
478 ((FieldInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_fiel))->fieldCount = 1; | |
479 ((FieldInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_fiel))->fieldOrderings = 0; | |
12424 | 480 |
12432 | 481 yuv_qt_stuff.extension_clap = NewHandleClear(sizeof(CleanApertureImageDescriptionExtension)); |
12487 | 482 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureWidthN = imgRect.right; |
12432 | 483 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureWidthD = 1; |
12487 | 484 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureHeightN = imgRect.bottom; |
12432 | 485 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureHeightD = 1; |
486 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->horizOffN = 0; | |
487 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->horizOffD = 1; | |
488 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->vertOffN = 0; | |
489 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->vertOffD = 1; | |
490 | |
491 yuv_qt_stuff.extension_pasp = NewHandleClear(sizeof(PixelAspectRatioImageDescriptionExtension)); | |
492 ((PixelAspectRatioImageDescriptionExtension*)(*yuv_qt_stuff.extension_pasp))->hSpacing = 1; | |
493 ((PixelAspectRatioImageDescriptionExtension*)(*yuv_qt_stuff.extension_pasp))->vSpacing = 1; | |
494 | |
495 (*yuv_qt_stuff.desc)->idSize = sizeof(ImageDescription); | |
496 (*yuv_qt_stuff.desc)->cType = image_qtcodec; | |
497 (*yuv_qt_stuff.desc)->version = 2; | |
498 (*yuv_qt_stuff.desc)->revisionLevel = 0; | |
499 (*yuv_qt_stuff.desc)->vendor = 'mpla'; | |
12487 | 500 (*yuv_qt_stuff.desc)->width = imgRect.right; |
501 (*yuv_qt_stuff.desc)->height = imgRect.bottom; | |
12432 | 502 (*yuv_qt_stuff.desc)->hRes = Long2Fix(72); |
503 (*yuv_qt_stuff.desc)->vRes = Long2Fix(72); | |
504 (*yuv_qt_stuff.desc)->temporalQuality = 0; | |
505 (*yuv_qt_stuff.desc)->spatialQuality = codecLosslessQuality; | |
506 (*yuv_qt_stuff.desc)->frameCount = 1; | |
507 (*yuv_qt_stuff.desc)->dataSize = 0; | |
508 (*yuv_qt_stuff.desc)->depth = 24; | |
509 (*yuv_qt_stuff.desc)->clutID = -1; | |
12424 | 510 |
12432 | 511 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_colr, kColorInfoImageDescriptionExtension); |
512 if (qterr) | |
513 { | |
12487 | 514 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [colr] (%d)\n", qterr); |
12432 | 515 } |
516 | |
517 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_fiel, kFieldInfoImageDescriptionExtension); | |
518 if (qterr) | |
519 { | |
12487 | 520 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [fiel] (%d)\n", qterr); |
12432 | 521 } |
522 | |
523 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_clap, kCleanApertureImageDescriptionExtension); | |
524 if (qterr) | |
525 { | |
12487 | 526 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [clap] (%d)\n", qterr); |
12432 | 527 } |
528 | |
529 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_pasp, kCleanApertureImageDescriptionExtension); | |
530 if (qterr) | |
531 { | |
12487 | 532 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [pasp] (%d)\n", qterr); |
12432 | 533 } |
12487 | 534 if (P != NULL) { // second or subsequent movie |
535 free(P); | |
536 } | |
12432 | 537 P = calloc(sizeof(PlanarPixmapInfoYUV420) + image_size, 1); |
538 switch (image_format) | |
539 { | |
540 case IMGFMT_YV12: | |
541 case IMGFMT_IYUV: | |
542 case IMGFMT_I420: | |
543 P->componentInfoY.offset = sizeof(PlanarPixmapInfoYUV420); | |
544 P->componentInfoCb.offset = P->componentInfoY.offset + image_size / 2; | |
545 P->componentInfoCr.offset = P->componentInfoCb.offset + image_size / 4; | |
12487 | 546 P->componentInfoY.rowBytes = imgRect.right; |
547 P->componentInfoCb.rowBytes = imgRect.right / 2; | |
548 P->componentInfoCr.rowBytes = imgRect.right / 2; | |
12432 | 549 image_buffer_size = image_size + sizeof(PlanarPixmapInfoYUV420); |
550 break; | |
551 case IMGFMT_UYVY: | |
552 case IMGFMT_YUY2: | |
553 image_buffer_size = image_size; | |
554 break; | |
555 } | |
12414 | 556 |
12432 | 557 qterr = DecompressSequenceBeginS(&seqId, |
12414 | 558 yuv_qt_stuff.desc, |
12432 | 559 (char *)P, |
12414 | 560 image_buffer_size, |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
561 gDisplayPortPtr,//GetWindowPort(theWindow), |
12432 | 562 NULL, |
563 NULL, | |
12414 | 564 ((d_width != width) || (d_height != height)) ? |
12432 | 565 &matrix : NULL, |
12414 | 566 srcCopy, |
12432 | 567 NULL, |
568 0, | |
12414 | 569 codecLosslessQuality, |
570 bestSpeedCodec); | |
12432 | 571 |
572 if (qterr) | |
573 { | |
574 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: DecompressSequenceBeginS (%d)\n", qterr); | |
12487 | 575 return -1; |
12432 | 576 } |
12424 | 577 } |
12432 | 578 break; |
12414 | 579 } |
580 | |
12424 | 581 //Show window |
582 RepositionWindow(theWindow, NULL, kWindowCascadeOnMainScreen); | |
12296 | 583 ShowWindow (theWindow); |
584 | |
585 if(vo_fs) | |
586 window_fullscreen(); | |
587 | |
588 if(vo_ontop) | |
589 window_ontop(); | |
590 | |
591 return 0; | |
12120 | 592 } |
593 | |
12296 | 594 static void check_events(void) |
12120 | 595 { |
12296 | 596 EventRef theEvent; |
597 EventTargetRef theTarget; | |
598 OSStatus theErr; | |
599 | |
600 //Get event | |
601 theTarget = GetEventDispatcherTarget(); | |
602 theErr = ReceiveNextEvent(0, 0, kEventDurationNoWait,true, &theEvent); | |
603 if(theErr == noErr && theEvent != NULL) | |
604 { | |
605 SendEventToEventTarget (theEvent, theTarget); | |
606 ReleaseEvent(theEvent); | |
607 } | |
12120 | 608 |
12296 | 609 //update activity every 30 seconds to prevent |
610 //screensaver from starting up. | |
611 DateTimeRec d; | |
612 unsigned long curTime; | |
613 static unsigned long lastTime = 0; | |
614 | |
615 GetTime(&d); | |
616 DateToSeconds( &d, &curTime); | |
617 | |
618 if( ( (curTime - lastTime) >= 30) || (lastTime == 0)) | |
619 { | |
620 UpdateSystemActivity(UsrActivity); | |
621 lastTime = curTime; | |
622 } | |
623 } | |
12120 | 624 |
12296 | 625 static void draw_osd(void) |
626 { | |
12487 | 627 vo_draw_text(imgRect.right,imgRect.bottom,draw_alpha); |
12296 | 628 } |
12120 | 629 |
12296 | 630 static void flip_page(void) |
631 { | |
12432 | 632 switch (image_format) |
633 { | |
634 case IMGFMT_RGB32: | |
635 { | |
12487 | 636 if (EnterMoviesDone && (image_data != NULL)) |
12432 | 637 { |
638 OSErr qterr; | |
639 CodecFlags flags = 0; | |
640 | |
641 qterr = DecompressSequenceFrameWhen(seqId, | |
642 image_data, | |
643 image_size, | |
644 0, | |
645 &flags, | |
646 NULL, | |
647 NULL); | |
12487 | 648 image_data = NULL; |
12432 | 649 if (qterr) |
650 { | |
12487 | 651 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: DecompressSequenceFrameWhen in flip_page (%d) flags:0x%08x\n", qterr, flags); |
12432 | 652 } |
653 } | |
654 } | |
655 break; | |
12414 | 656 |
12433 | 657 case IMGFMT_YV12: |
658 case IMGFMT_IYUV: | |
659 case IMGFMT_I420: | |
660 case IMGFMT_UYVY: | |
661 case IMGFMT_YUY2: | |
662 if (EnterMoviesDone) | |
663 { | |
664 OSErr qterr; | |
665 CodecFlags flags = 0; | |
666 qterr = DecompressSequenceFrameWhen(seqId, | |
667 (char *)P, | |
668 image_buffer_size, | |
669 0, //codecFlagUseImageBuffer, | |
670 &flags, | |
671 NULL, | |
672 NULL); | |
673 if (qterr) | |
674 { | |
12487 | 675 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: DecompressSequenceFrameWhen in flip_page (%d) flags:0x%08x\n", qterr, flags); |
12433 | 676 } |
677 } | |
678 break; | |
679 } | |
12296 | 680 } |
681 | |
682 static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) | |
683 { | |
12433 | 684 switch (image_format) |
685 { | |
12487 | 686 case IMGFMT_YV12: |
687 case IMGFMT_I420: | |
688 memcpy_pic(((char*)P) + P->componentInfoY.offset + x + imgRect.right * y, src[0], w, h, imgRect.right, stride[0]); | |
689 x=x/2;y=y/2;w=w/2;h=h/2; | |
690 | |
691 memcpy_pic(((char*)P) + P->componentInfoCb.offset + x + imgRect.right / 2 * y, src[1], w, h, imgRect.right / 2, stride[1]); | |
692 memcpy_pic(((char*)P) + P->componentInfoCr.offset + x + imgRect.right / 2 * y, src[2], w, h, imgRect.right / 2, stride[2]); | |
693 return 0; | |
694 | |
695 case IMGFMT_IYUV: | |
696 memcpy_pic(((char*)P) + P->componentInfoY.offset + x + imgRect.right * y, src[0], w, h, imgRect.right, stride[0]); | |
697 x=x/2;y=y/2;w=w/2;h=h/2; | |
698 | |
699 memcpy_pic(((char*)P) + P->componentInfoCr.offset + x + imgRect.right / 2 * y, src[1], w, h, imgRect.right / 2, stride[1]); | |
700 memcpy_pic(((char*)P) + P->componentInfoCb.offset + x + imgRect.right / 2 * y, src[2], w, h, imgRect.right / 2, stride[2]); | |
701 return 0; | |
12433 | 702 } |
12296 | 703 return -1; |
704 } | |
705 | |
706 static uint32_t draw_frame(uint8_t *src[]) | |
707 { | |
12433 | 708 switch (image_format) |
709 { | |
710 case IMGFMT_RGB32: | |
711 image_data = src[0]; | |
712 return 0; | |
12432 | 713 |
12433 | 714 case IMGFMT_UYVY: |
715 case IMGFMT_YUY2: | |
12487 | 716 memcpy_pic(((char*)P), src[0], imgRect.right * 2, imgRect.bottom, imgRect.right * 2, imgRect.right * 2); |
12433 | 717 return 0; |
718 } | |
719 return -1; | |
12296 | 720 } |
12120 | 721 |
12296 | 722 static uint32_t query_format(uint32_t format) |
723 { | |
724 image_format = format; | |
12432 | 725 image_qtcodec = 0; |
726 | |
727 if (format == IMGFMT_RGB32) | |
728 { | |
12487 | 729 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; |
12432 | 730 } |
12414 | 731 |
12424 | 732 if ((format == IMGFMT_YV12) || (format == IMGFMT_IYUV) || (format == IMGFMT_I420)) |
733 { | |
734 image_qtcodec = kMpegYUV420CodecType; //kYUV420CodecType ?; | |
12487 | 735 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE; |
12414 | 736 } |
737 | |
12424 | 738 if (format == IMGFMT_YUY2) |
739 { | |
740 image_qtcodec = kComponentVideoUnsigned; | |
12487 | 741 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; |
12414 | 742 } |
743 | |
12424 | 744 if (format == IMGFMT_UYVY) |
745 { | |
746 image_qtcodec = k422YpCbCr8CodecType; | |
12487 | 747 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; |
12424 | 748 } |
12414 | 749 |
12296 | 750 return 0; |
751 } | |
12120 | 752 |
12296 | 753 static void uninit(void) |
754 { | |
12432 | 755 OSErr qterr; |
12424 | 756 |
12432 | 757 if (EnterMoviesDone) |
758 { | |
759 qterr = CDSequenceEnd(seqId); | |
760 if (qterr) | |
761 { | |
12487 | 762 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: CDSequenceEnd (%d)\n", qterr); |
12424 | 763 } |
12414 | 764 } |
12432 | 765 |
12296 | 766 ShowMenuBar(); |
767 } | |
12120 | 768 |
12296 | 769 static uint32_t preinit(const char *arg) |
770 { | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
771 int parse_err = 0; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
772 |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
773 if(arg) |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
774 { |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
775 char *parse_pos = &arg[0]; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
776 while (parse_pos[0] && !parse_err) |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
777 { |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
778 if (strncmp (parse_pos, "device_id=", 10) == 0) |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
779 { |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
780 parse_pos = &parse_pos[10]; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
781 device_id = strtol(parse_pos, &parse_pos, 0); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
782 } |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
783 if (parse_pos[0] == ':') parse_pos = &parse_pos[1]; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
784 else if (parse_pos[0]) parse_err = 1; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
785 } |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
786 } |
12296 | 787 return 0; |
12120 | 788 } |
789 | |
12424 | 790 static uint32_t draw_yuv_image(mp_image_t *mpi) |
791 { | |
792 // ATM we're only called for planar IMGFMT | |
793 // drawing is done directly in P | |
794 // and displaying is in flip_page. | |
12487 | 795 return get_image_done ? VO_TRUE : VO_FALSE; |
12414 | 796 } |
797 | |
12424 | 798 static uint32_t get_yuv_image(mp_image_t *mpi) |
799 { | |
800 if(mpi->type!=MP_IMGTYPE_EXPORT) return VO_FALSE; | |
12414 | 801 |
12424 | 802 if(mpi->imgfmt!=image_format) return VO_FALSE; |
12414 | 803 |
12424 | 804 if(mpi->flags&MP_IMGFLAG_PLANAR) |
805 { | |
806 if (mpi->num_planes != 3) | |
807 { | |
808 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: only 3 planes allowed in get_yuv_image for planar (%d) \n", mpi->num_planes); | |
809 return VO_FALSE; | |
810 } | |
12414 | 811 |
12424 | 812 mpi->planes[0]=((char*)P) + P->componentInfoY.offset; |
12487 | 813 mpi->stride[0]=imgRect.right; |
814 mpi->width=imgRect.right; | |
12414 | 815 |
12424 | 816 if(mpi->flags&MP_IMGFLAG_SWAPPED) |
817 { | |
818 // I420 | |
819 mpi->planes[1]=((char*)P) + P->componentInfoCb.offset; | |
820 mpi->planes[2]=((char*)P) + P->componentInfoCr.offset; | |
12487 | 821 mpi->stride[1]=imgRect.right/2; |
822 mpi->stride[2]=imgRect.right/2; | |
12424 | 823 } |
824 else | |
825 { | |
826 // YV12 | |
827 mpi->planes[1]=((char*)P) + P->componentInfoCr.offset; | |
828 mpi->planes[2]=((char*)P) + P->componentInfoCb.offset; | |
12487 | 829 mpi->stride[1]=imgRect.right/2; |
830 mpi->stride[2]=imgRect.right/2; | |
12424 | 831 } |
832 | |
833 mpi->flags|=MP_IMGFLAG_DIRECT; | |
12487 | 834 get_image_done = 1; |
12424 | 835 return VO_TRUE; |
836 } | |
837 else | |
12433 | 838 { |
839 // doesn't work yet | |
12424 | 840 if (mpi->num_planes != 1) |
841 { | |
842 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: only 1 plane allowed in get_yuv_image for packed (%d) \n", mpi->num_planes); | |
843 return VO_FALSE; | |
844 } | |
12414 | 845 |
12424 | 846 mpi->planes[0] = (char*)P; |
12487 | 847 mpi->stride[0] = imgRect.right * 2; |
848 mpi->width=imgRect.right; | |
12424 | 849 mpi->flags|=MP_IMGFLAG_DIRECT; |
12487 | 850 get_image_done = 1; |
12424 | 851 return VO_TRUE; |
852 } | |
853 return VO_FALSE; | |
12414 | 854 } |
855 | |
12296 | 856 static uint32_t control(uint32_t request, void *data, ...) |
12120 | 857 { |
12424 | 858 switch (request) |
859 { | |
860 case VOCTRL_PAUSE: return (int_pause=1); | |
861 case VOCTRL_RESUME: return (int_pause=0); | |
12460 | 862 case VOCTRL_FULLSCREEN: vo_fs = (!(vo_fs)); window_fullscreen(); return VO_TRUE; |
863 case VOCTRL_ONTOP: vo_ontop = (!(vo_ontop)); window_ontop(); return VO_TRUE; | |
12424 | 864 case VOCTRL_QUERY_FORMAT: return query_format(*((uint32_t*)data)); |
865 case VOCTRL_GET_IMAGE: | |
866 switch (image_format) | |
867 { | |
868 case IMGFMT_YV12: | |
869 case IMGFMT_IYUV: | |
870 case IMGFMT_I420: | |
12487 | 871 case IMGFMT_UYVY: |
872 case IMGFMT_YUY2: | |
12424 | 873 return get_yuv_image(data); |
874 break; | |
12487 | 875 default: |
876 break; | |
12424 | 877 } |
878 case VOCTRL_DRAW_IMAGE: | |
879 switch (image_format) | |
880 { | |
881 case IMGFMT_YV12: | |
882 case IMGFMT_IYUV: | |
883 case IMGFMT_I420: | |
12487 | 884 case IMGFMT_UYVY: |
885 case IMGFMT_YUY2: | |
12424 | 886 return draw_yuv_image(data); |
887 break; | |
12487 | 888 default: |
889 break; | |
12424 | 890 } |
891 } | |
892 return VO_NOTIMPL; | |
12120 | 893 } |
894 | |
12296 | 895 void window_resized() |
12120 | 896 { |
12296 | 897 float aspectX; |
898 float aspectY; | |
899 | |
900 int padding; | |
901 | |
902 uint32_t d_width; | |
903 uint32_t d_height; | |
904 | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
905 //GetWindowPortBounds(theWindow, &winRect); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
906 GetPortBounds( gDisplayPortPtr, &winRect ); |
12120 | 907 |
12296 | 908 aspect( &d_width, &d_height, A_NOZOOM); |
909 | |
910 aspectX = (float)((float)winRect.right/(float)d_width); | |
911 aspectY = (float)((float)winRect.bottom/(float)d_height); | |
912 | |
913 if((d_height*aspectX)>winRect.bottom) | |
914 { | |
915 padding = (winRect.right - d_width*aspectY)/2; | |
916 SetRect(&dstRect, padding, 0, d_width*aspectY+padding, d_height*aspectY); | |
917 } | |
918 else | |
919 { | |
920 padding = (winRect.bottom - d_height*aspectX)/2; | |
921 SetRect(&dstRect, 0, padding, (d_width*aspectX), d_height*aspectX+padding); | |
922 } | |
12120 | 923 |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
924 //Clear Background |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
925 SetGWorld( gDisplayPortPtr, NULL ); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
926 RGBColor blackC = { 0x0000, 0x0000, 0x0000 }; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
927 RGBForeColor( &blackC ); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
928 PaintRect( &winRect ); |
12414 | 929 |
12487 | 930 long scale_X = FixDiv(Long2Fix(dstRect.right - dstRect.left),Long2Fix(imgRect.right)); |
931 long scale_Y = FixDiv(Long2Fix(dstRect.bottom - dstRect.top),Long2Fix(imgRect.bottom)); | |
12414 | 932 |
12432 | 933 SetIdentityMatrix(&matrix); |
12487 | 934 if (((dstRect.right - dstRect.left) != imgRect.right) || ((dstRect.bottom - dstRect.right) != imgRect.bottom)) |
12432 | 935 { |
936 ScaleMatrix(&matrix, scale_X, scale_Y, 0, 0); | |
12414 | 937 |
12432 | 938 if (padding > 0) |
939 { | |
940 TranslateMatrix(&matrix, Long2Fix(dstRect.left), Long2Fix(dstRect.top)); | |
941 } | |
942 } | |
12424 | 943 |
12432 | 944 SetDSequenceMatrix(seqId, &matrix); |
12120 | 945 } |
946 | |
12296 | 947 void window_ontop() |
12460 | 948 { |
12432 | 949 if(vo_ontop) |
12296 | 950 SetWindowClass( theWindow, kUtilityWindowClass); |
951 else | |
952 SetWindowClass( theWindow, kDocumentWindowClass); | |
12120 | 953 } |
954 | |
12296 | 955 void window_fullscreen() |
12120 | 956 { |
12296 | 957 GDHandle deviceHdl; |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
958 //Rect deviceRect; |
12120 | 959 |
12296 | 960 //go fullscreen |
12432 | 961 if(vo_fs) |
12296 | 962 { |
963 HideMenuBar(); | |
12120 | 964 |
12296 | 965 //save old window size |
12487 | 966 if (!vo_quartz_fs) |
967 GetWindowPortBounds(theWindow, &oldWinRect); | |
12296 | 968 |
969 //hide mouse cursor | |
970 HideCursor(); | |
971 | |
972 //go fullscreen | |
12432 | 973 //ChangeWindowAttributes(theWindow, 0, kWindowResizableAttribute); |
12425 | 974 |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
975 MoveWindow (theWindow, deviceRect.left, deviceRect.top, 1); |
12296 | 976 SizeWindow(theWindow, device_width, device_height,1); |
12487 | 977 |
978 vo_quartz_fs = 1; | |
12296 | 979 } |
980 else //go back to windowed mode | |
981 { | |
982 ShowMenuBar(); | |
12120 | 983 |
12296 | 984 //show mouse cursor |
985 ShowCursor(); | |
986 | |
987 //revert window to previous setting | |
12432 | 988 //ChangeWindowAttributes(theWindow, kWindowResizableAttribute, 0); |
12425 | 989 |
12487 | 990 SizeWindow(theWindow, oldWinRect.right, oldWinRect.bottom,1); |
12296 | 991 RepositionWindow(theWindow, NULL, kWindowCascadeOnMainScreen); |
12487 | 992 |
993 vo_quartz_fs = 0; | |
12296 | 994 } |
995 | |
996 window_resized(); | |
12120 | 997 } |