SDL  2.0
SDL_cocoaevents.m
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../../SDL_internal.h"
22 
23 #if SDL_VIDEO_DRIVER_COCOA
24 
25 #include "SDL_timer.h"
26 
27 #include "SDL_cocoavideo.h"
28 #include "../../events/SDL_events_c.h"
29 #include "SDL_assert.h"
30 #include "SDL_hints.h"
31 
32 /* This define was added in the 10.9 SDK. */
33 #ifndef kIOPMAssertPreventUserIdleDisplaySleep
34 #define kIOPMAssertPreventUserIdleDisplaySleep kIOPMAssertionTypePreventUserIdleDisplaySleep
35 #endif
36 
37 @interface SDLApplication : NSApplication
38 
39 - (void)terminate:(id)sender;
40 - (void)sendEvent:(NSEvent *)theEvent;
41 
42 + (void)registerUserDefaults;
43 
44 @end
45 
46 @implementation SDLApplication
47 
48 // Override terminate to handle Quit and System Shutdown smoothly.
49 - (void)terminate:(id)sender
50 {
51  SDL_SendQuit();
52 }
53 
54 static SDL_bool s_bShouldHandleEventsInSDLApplication = SDL_FALSE;
55 
56 static void Cocoa_DispatchEvent(NSEvent *theEvent)
57 {
59 
60  switch ([theEvent type]) {
61  case NSEventTypeLeftMouseDown:
62  case NSEventTypeOtherMouseDown:
63  case NSEventTypeRightMouseDown:
64  case NSEventTypeLeftMouseUp:
65  case NSEventTypeOtherMouseUp:
66  case NSEventTypeRightMouseUp:
67  case NSEventTypeLeftMouseDragged:
68  case NSEventTypeRightMouseDragged:
69  case NSEventTypeOtherMouseDragged: /* usually middle mouse dragged */
70  case NSEventTypeMouseMoved:
71  case NSEventTypeScrollWheel:
72  Cocoa_HandleMouseEvent(_this, theEvent);
73  break;
74  case NSEventTypeKeyDown:
75  case NSEventTypeKeyUp:
76  case NSEventTypeFlagsChanged:
77  Cocoa_HandleKeyEvent(_this, theEvent);
78  break;
79  default:
80  break;
81  }
82 }
83 
84 // Dispatch events here so that we can handle events caught by
85 // nextEventMatchingMask in SDL, as well as events caught by other
86 // processes (such as CEF) that are passed down to NSApp.
87 - (void)sendEvent:(NSEvent *)theEvent
88 {
89  if (s_bShouldHandleEventsInSDLApplication) {
90  Cocoa_DispatchEvent(theEvent);
91  }
92 
93  [super sendEvent:theEvent];
94 }
95 
96 + (void)registerUserDefaults
97 {
98  NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
99  [NSNumber numberWithBool:NO], @"AppleMomentumScrollSupported",
100  [NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled",
101  [NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState",
102  nil];
103  [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
104  [appDefaults release];
105 }
106 
107 @end // SDLApplication
108 
109 /* setAppleMenu disappeared from the headers in 10.4 */
110 @interface NSApplication(NSAppleMenu)
111 - (void)setAppleMenu:(NSMenu *)menu;
112 @end
113 
114 @interface SDLAppDelegate : NSObject <NSApplicationDelegate> {
115 @public
116  BOOL seenFirstActivate;
117 }
118 
119 - (id)init;
120 @end
121 
122 @implementation SDLAppDelegate : NSObject
123 - (id)init
124 {
125  self = [super init];
126  if (self) {
127  NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
128 
129  seenFirstActivate = NO;
130 
131  [center addObserver:self
132  selector:@selector(windowWillClose:)
133  name:NSWindowWillCloseNotification
134  object:nil];
135 
136  [center addObserver:self
137  selector:@selector(focusSomeWindow:)
138  name:NSApplicationDidBecomeActiveNotification
139  object:nil];
140  }
141 
142  return self;
143 }
144 
145 - (void)dealloc
146 {
147  NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
148 
149  [center removeObserver:self name:NSWindowWillCloseNotification object:nil];
150  [center removeObserver:self name:NSApplicationDidBecomeActiveNotification object:nil];
151 
152  [super dealloc];
153 }
154 
155 - (void)windowWillClose:(NSNotification *)notification;
156 {
157  NSWindow *win = (NSWindow*)[notification object];
158 
159  if (![win isKeyWindow]) {
160  return;
161  }
162 
163  /* HACK: Make the next window in the z-order key when the key window is
164  * closed. The custom event loop and/or windowing code we have seems to
165  * prevent the normal behavior: https://bugzilla.libsdl.org/show_bug.cgi?id=1825
166  */
167 
168  /* +[NSApp orderedWindows] never includes the 'About' window, but we still
169  * want to try its list first since the behavior in other apps is to only
170  * make the 'About' window key if no other windows are on-screen.
171  */
172  for (NSWindow *window in [NSApp orderedWindows]) {
173  if (window != win && [window canBecomeKeyWindow]) {
174  if (![window isOnActiveSpace]) {
175  continue;
176  }
177  [window makeKeyAndOrderFront:self];
178  return;
179  }
180  }
181 
182  /* If a window wasn't found above, iterate through all visible windows in
183  * the active Space in z-order (including the 'About' window, if it's shown)
184  * and make the first one key.
185  */
186  for (NSNumber *num in [NSWindow windowNumbersWithOptions:0]) {
187  NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]];
188  if (window && window != win && [window canBecomeKeyWindow]) {
189  [window makeKeyAndOrderFront:self];
190  return;
191  }
192  }
193 }
194 
195 - (void)focusSomeWindow:(NSNotification *)aNotification
196 {
197  /* HACK: Ignore the first call. The application gets a
198  * applicationDidBecomeActive: a little bit after the first window is
199  * created, and if we don't ignore it, a window that has been created with
200  * SDL_WINDOW_MINIMIZED will ~immediately be restored.
201  */
202  if (!seenFirstActivate) {
203  seenFirstActivate = YES;
204  return;
205  }
206 
208  if (device && device->windows) {
209  SDL_Window *window = device->windows;
210  int i;
211  for (i = 0; i < device->num_displays; ++i) {
212  SDL_Window *fullscreen_window = device->displays[i].fullscreen_window;
213  if (fullscreen_window) {
214  if (fullscreen_window->flags & SDL_WINDOW_MINIMIZED) {
215  SDL_RestoreWindow(fullscreen_window);
216  }
217  return;
218  }
219  }
220 
221  if (window->flags & SDL_WINDOW_MINIMIZED) {
222  SDL_RestoreWindow(window);
223  } else {
224  SDL_RaiseWindow(window);
225  }
226  }
227 }
228 
229 - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
230 {
231  return (BOOL)SDL_SendDropFile(NULL, [filename UTF8String]) && SDL_SendDropComplete(NULL);
232 }
233 
234 - (void)applicationDidFinishLaunching:(NSNotification *)notification
235 {
236  /* The menu bar of SDL apps which don't have the typical .app bundle
237  * structure fails to work the first time a window is created (until it's
238  * de-focused and re-focused), if this call is in Cocoa_RegisterApp instead
239  * of here. https://bugzilla.libsdl.org/show_bug.cgi?id=3051
240  */
242  /* Get more aggressive for Catalina: activate the Dock first so we definitely reset all activation state. */
243  for (NSRunningApplication *i in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) {
244  [i activateWithOptions:NSApplicationActivateIgnoringOtherApps];
245  break;
246  }
247  SDL_Delay(300); /* !!! FIXME: this isn't right. */
248  [NSApp activateIgnoringOtherApps:YES];
249  }
250 
251  /* If we call this before NSApp activation, macOS might print a complaint
252  * about ApplePersistenceIgnoreState. */
253  [SDLApplication registerUserDefaults];
254 }
255 @end
256 
257 static SDLAppDelegate *appDelegate = nil;
258 
259 static NSString *
260 GetApplicationName(void)
261 {
262  NSString *appName;
263 
264  /* Determine the application name */
265  appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
266  if (!appName) {
267  appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
268  }
269 
270  if (![appName length]) {
271  appName = [[NSProcessInfo processInfo] processName];
272  }
273 
274  return appName;
275 }
276 
277 static bool
278 LoadMainMenuNibIfAvailable(void)
279 {
280  NSDictionary *infoDict;
281  NSString *mainNibFileName;
282  bool success = false;
283 
284  infoDict = [[NSBundle mainBundle] infoDictionary];
285  if (infoDict) {
286  mainNibFileName = [infoDict valueForKey:@"NSMainNibFile"];
287 
288  if (mainNibFileName) {
289  success = [[NSBundle mainBundle] loadNibNamed:mainNibFileName owner:[NSApplication sharedApplication] topLevelObjects:nil];
290  }
291  }
292 
293  return success;
294 }
295 
296 static void
297 CreateApplicationMenus(void)
298 {
299  NSString *appName;
300  NSString *title;
301  NSMenu *appleMenu;
302  NSMenu *serviceMenu;
303  NSMenu *windowMenu;
304  NSMenuItem *menuItem;
305  NSMenu *mainMenu;
306 
307  if (NSApp == nil) {
308  return;
309  }
310 
311  mainMenu = [[NSMenu alloc] init];
312 
313  /* Create the main menu bar */
314  [NSApp setMainMenu:mainMenu];
315 
316  [mainMenu release]; /* we're done with it, let NSApp own it. */
317  mainMenu = nil;
318 
319  /* Create the application menu */
320  appName = GetApplicationName();
321  appleMenu = [[NSMenu alloc] initWithTitle:@""];
322 
323  /* Add menu items */
324  title = [@"About " stringByAppendingString:appName];
325  [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
326 
327  [appleMenu addItem:[NSMenuItem separatorItem]];
328 
329  [appleMenu addItemWithTitle:@"Preferences…" action:nil keyEquivalent:@","];
330 
331  [appleMenu addItem:[NSMenuItem separatorItem]];
332 
333  serviceMenu = [[NSMenu alloc] initWithTitle:@""];
334  menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
335  [menuItem setSubmenu:serviceMenu];
336 
337  [NSApp setServicesMenu:serviceMenu];
338  [serviceMenu release];
339 
340  [appleMenu addItem:[NSMenuItem separatorItem]];
341 
342  title = [@"Hide " stringByAppendingString:appName];
343  [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
344 
345  menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
346  [menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEventModifierFlagCommand)];
347 
348  [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
349 
350  [appleMenu addItem:[NSMenuItem separatorItem]];
351 
352  title = [@"Quit " stringByAppendingString:appName];
353  [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
354 
355  /* Put menu into the menubar */
356  menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
357  [menuItem setSubmenu:appleMenu];
358  [[NSApp mainMenu] addItem:menuItem];
359  [menuItem release];
360 
361  /* Tell the application object that this is now the application menu */
362  [NSApp setAppleMenu:appleMenu];
363  [appleMenu release];
364 
365 
366  /* Create the window menu */
367  windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
368 
369  /* Add menu items */
370  [windowMenu addItemWithTitle:@"Close" action:@selector(performClose:) keyEquivalent:@"w"];
371 
372  [windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
373 
374  [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
375 
376  /* Add the fullscreen toggle menu option, if supported */
377  if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
378  /* Cocoa should update the title to Enter or Exit Full Screen automatically.
379  * But if not, then just fallback to Toggle Full Screen.
380  */
381  menuItem = [[NSMenuItem alloc] initWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
382  [menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
383  [windowMenu addItem:menuItem];
384  [menuItem release];
385  }
386 
387  /* Put menu into the menubar */
388  menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
389  [menuItem setSubmenu:windowMenu];
390  [[NSApp mainMenu] addItem:menuItem];
391  [menuItem release];
392 
393  /* Tell the application object that this is now the window menu */
394  [NSApp setWindowsMenu:windowMenu];
395  [windowMenu release];
396 }
397 
398 void
399 Cocoa_RegisterApp(void)
400 { @autoreleasepool
401 {
402  /* This can get called more than once! Be careful what you initialize! */
403 
404  if (NSApp == nil) {
405  [SDLApplication sharedApplication];
406  SDL_assert(NSApp != nil);
407 
408  s_bShouldHandleEventsInSDLApplication = SDL_TRUE;
409 
411  [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
412  }
413 
414  /* If there aren't already menus in place, look to see if there's
415  * a nib we should use. If not, then manually create the basic
416  * menus we meed.
417  */
418  if ([NSApp mainMenu] == nil) {
419  bool nibLoaded;
420 
421  nibLoaded = LoadMainMenuNibIfAvailable();
422  if (!nibLoaded) {
423  CreateApplicationMenus();
424  }
425  }
426  [NSApp finishLaunching];
427  if ([NSApp delegate]) {
428  /* The SDL app delegate calls this in didFinishLaunching if it's
429  * attached to the NSApp, otherwise we need to call it manually.
430  */
431  [SDLApplication registerUserDefaults];
432  }
433  }
434  if (NSApp && !appDelegate) {
435  appDelegate = [[SDLAppDelegate alloc] init];
436 
437  /* If someone else has an app delegate, it means we can't turn a
438  * termination into SDL_Quit, and we can't handle application:openFile:
439  */
440  if (![NSApp delegate]) {
441  [(NSApplication *)NSApp setDelegate:appDelegate];
442  } else {
443  appDelegate->seenFirstActivate = YES;
444  }
445  }
446 }}
447 
448 void
450 { @autoreleasepool
451 {
452 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
453  /* Update activity every 30 seconds to prevent screensaver */
455  if (_this->suspend_screensaver && !data->screensaver_use_iopm) {
456  Uint32 now = SDL_GetTicks();
457  if (!data->screensaver_activity ||
458  SDL_TICKS_PASSED(now, data->screensaver_activity + 30000)) {
459  UpdateSystemActivity(UsrActivity);
460  data->screensaver_activity = now;
461  }
462  }
463 #endif
464 
465  for ( ; ; ) {
466  NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
467  if ( event == nil ) {
468  break;
469  }
470 
471  if (!s_bShouldHandleEventsInSDLApplication) {
472  Cocoa_DispatchEvent(event);
473  }
474 
475  // Pass events down to SDLApplication to be handled in sendEvent:
476  [NSApp sendEvent:event];
477  }
478 }}
479 
480 void
482 { @autoreleasepool
483 {
485 
486  if (!data->screensaver_use_iopm) {
487  return;
488  }
489 
490  if (data->screensaver_assertion) {
491  IOPMAssertionRelease(data->screensaver_assertion);
492  data->screensaver_assertion = 0;
493  }
494 
495  if (_this->suspend_screensaver) {
496  /* FIXME: this should ideally describe the real reason why the game
497  * called SDL_DisableScreenSaver. Note that the name is only meant to be
498  * seen by OS X power users. there's an additional optional human-readable
499  * (localized) reason parameter which we don't set.
500  */
501  NSString *name = [GetApplicationName() stringByAppendingString:@" using SDL_DisableScreenSaver"];
502  IOPMAssertionCreateWithDescription(kIOPMAssertPreventUserIdleDisplaySleep,
503  (CFStringRef) name,
504  NULL, NULL, NULL, 0, NULL,
505  &data->screensaver_assertion);
506  }
507 }}
508 
509 #endif /* SDL_VIDEO_DRIVER_COCOA */
510 
511 /* vi: set ts=4 sw=4 expandtab: */
terminate
void terminate(int sig)
Definition: testlock.c:45
sort_controllers.filename
string filename
Definition: sort_controllers.py:8
Cocoa_SuspendScreenSaver
void Cocoa_SuspendScreenSaver(_THIS)
SDL_VideoDevice::driverdata
void * driverdata
Definition: SDL_sysvideo.h:389
SDL_WINDOW_MINIMIZED
@ SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:105
in
GLuint in
Definition: SDL_opengl_glext.h:7943
if
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
Definition: pixman-arm-neon-asm.h:469
NULL
#define NULL
Definition: begin_code.h:167
SDL_timer.h
Cocoa_HandleKeyEvent
void Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
num
GLuint num
Definition: SDL_opengl_glext.h:4959
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:203
SDL_cocoavideo.h
length
GLuint GLsizei GLsizei * length
Definition: SDL_opengl_glext.h:672
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:75
SDL_HINT_MAC_BACKGROUND_APP
#define SDL_HINT_MAC_BACKGROUND_APP
When set don't force the SDL app to become a foreground process.
Definition: SDL_hints.h:905
SDL_GetHintBoolean
#define SDL_GetHintBoolean
Definition: SDL_dynapi_overrides.h:608
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2652
_this
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
name
GLuint const GLchar * name
Definition: SDL_opengl_glext.h:663
SDL_SendDropFile
int SDL_SendDropFile(SDL_Window *window, const char *file)
Definition: SDL_dropevents.c:80
SDL_assert.h
SDL_GetTicks
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
SDL_Delay
#define SDL_Delay
Definition: SDL_dynapi_overrides.h:486
SDL_SendDropComplete
int SDL_SendDropComplete(SDL_Window *window)
Definition: SDL_dropevents.c:92
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
Cocoa_HandleMouseEvent
void Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
SDL_VideoDevice
Definition: SDL_sysvideo.h:150
id
GLuint id
Definition: SDL_opengl_glext.h:531
action
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF PF lsl PF PF PF else PF lsl PF lsl PF lsl PF endif SIZE macro preload_middle scratch_holds_offset if bpp if else PF PF endif endif endif endm macro preload_trailing base if bpp if bpp *pix_per_block PF PF lsl PF PF PF PF PF else PF lsl PF lsl PF PF PF PF PF base if bpp if narrow_case &&bpp<=dst_w_bpp) PF bic, WK0, base, #31 PF pld,[WK0] PF add, WK1, base, X, LSL #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 90f PF pld,[WK1]90:.else PF bic, WK0, base, #31 PF pld,[WK0] PF add, WK1, base, X, lsl #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 92f91:PF add, WK0, WK0, #32 PF cmp, WK0, WK1 PF pld,[WK0] PF bne, 91b92:.endif .endif.endm.macro conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx process_head cond, numbytes, firstreg, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond X, X, #8 *numbytes/dst_w_bpp .endif process_tail cond, numbytes, firstreg .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst cond, numbytes, firstreg, DST .endif.endm.macro conditional_process1 cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_BRANCH_OVER .ifc cond, mi bpl 100f .endif .ifc cond, cs bcc 100f .endif .ifc cond, ne beq 100f .endif conditional_process1_helper, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx100:.else conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .endif.endm.macro conditional_process2 test, cond1, cond2, process_head, process_tail, numbytes1, numbytes2, firstreg1, firstreg2, unaligned_src, unaligned_mask, decrementx .if(flags) &(FLAG_DST_READWRITE|FLAG_BRANCH_OVER|FLAG_PROCESS_CORRUPTS_PSR|FLAG_PROCESS_DOES_STORE) test conditional_process1 cond1, process_head, process_tail, numbytes1, firstreg1, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_PROCESS_CORRUPTS_PSR test .endif conditional_process1 cond2, process_head, process_tail, numbytes2, firstreg2, unaligned_src, unaligned_mask, decrementx .else test process_head cond1, numbytes1, firstreg1, unaligned_src, unaligned_mask, 0 process_head cond2, numbytes2, firstreg2, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond1 X, X, #8 *numbytes1/dst_w_bpp sub &cond2 X, X, #8 *numbytes2/dst_w_bpp .endif process_tail cond1, numbytes1, firstreg1 process_tail cond2, numbytes2, firstreg2 pixst cond1, numbytes1, firstreg1, DST pixst cond2, numbytes2, firstreg2, DST .endif.endm.macro test_bits_1_0_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-1 .else movs SCRATCH, WK0, lsl #32-1 .endif.endm.macro test_bits_3_2_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-3 .else movs SCRATCH, WK0, lsl #32-3 .endif.endm.macro leading_15bytes process_head, process_tail .set DECREMENT_X, 1 .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 .set DECREMENT_X, 0 sub X, X, WK0, lsr #dst_bpp_shift str X,[sp, #LINE_SAVED_REG_COUNT *4] mov X, WK0 .endif .if dst_w_bpp==8 conditional_process2 test_bits_1_0_ptr, mi, cs, process_head, process_tail, 1, 2, 1, 2, 1, 1, DECREMENT_X .elseif dst_w_bpp==16 test_bits_1_0_ptr conditional_process1 cs, process_head, process_tail, 2, 2, 1, 1, DECREMENT_X .endif conditional_process2 test_bits_3_2_ptr, mi, cs, process_head, process_tail, 4, 8, 1, 2, 1, 1, DECREMENT_X .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 ldr X,[sp, #LINE_SAVED_REG_COUNT *4] .endif.endm.macro test_bits_3_2_pix movs SCRATCH, X, lsl #dst_bpp_shift+32-3.endm.macro test_bits_1_0_pix .if dst_w_bpp==8 movs SCRATCH, X, lsl #dst_bpp_shift+32-1 .else movs SCRATCH, X, lsr #1 .endif.endm.macro trailing_15bytes process_head, process_tail, unaligned_src, unaligned_mask conditional_process2 test_bits_3_2_pix, cs, mi, process_head, process_tail, 8, 4, 0, 2, unaligned_src, unaligned_mask, 0 .if dst_w_bpp==16 test_bits_1_0_pix conditional_process1 cs, process_head, process_tail, 2, 0, unaligned_src, unaligned_mask, 0 .elseif dst_w_bpp==8 conditional_process2 test_bits_1_0_pix, cs, mi, process_head, process_tail, 2, 1, 0, 1, unaligned_src, unaligned_mask, 0 .endif.endm.macro wide_case_inner_loop process_head, process_tail, unaligned_src, unaligned_mask, dst_alignment110:.set SUBBLOCK, 0 .rept pix_per_block *dst_w_bpp/128 process_head, 16, 0, unaligned_src, unaligned_mask, 1 .if(src_bpp > 0) &&(mask_bpp==0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle src_bpp, SRC, 1 .elseif(src_bpp==0) &&(mask_bpp > 0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle mask_bpp, MASK, 1 .else preload_middle src_bpp, SRC, 0 preload_middle mask_bpp, MASK, 0 .endif .if(dst_r_bpp > 0) &&((SUBBLOCK % 2)==0) &&(((flags) &FLAG_NO_PRELOAD_DST)==0) PF pld,[DST, #32 *prefetch_distance - dst_alignment] .endif process_tail, 16, 0 .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst, 16, 0, DST .endif .set SUBBLOCK, SUBBLOCK+1 .endr subs X, X, #pix_per_block bhs 110b.endm.macro wide_case_inner_loop_and_trailing_pixels process_head, process_tail, process_inner_loop, exit_label, unaligned_src, unaligned_mask .if dst_r_bpp > tst bne process_inner_loop DST_PRELOAD_BIAS endif preload_trailing SRC preload_trailing MASK DST endif add medium_case_inner_loop_and_trailing_pixels unaligned_mask endm macro medium_case_inner_loop_and_trailing_pixels DST endif subs bhs tst beq exit_label trailing_15bytes unaligned_mask endm macro narrow_case_inner_loop_and_trailing_pixels unaligned_mask tst conditional_process1 trailing_15bytes unaligned_mask endm macro switch_on_alignment action
Definition: pixman-arm-simd-asm.h:510
Cocoa_RegisterApp
void Cocoa_RegisterApp(void)
SDL_hints.h
Cocoa_PumpEvents
void Cocoa_PumpEvents(_THIS)
SDL_TICKS_PASSED
#define SDL_TICKS_PASSED(A, B)
Compare SDL ticks values, and return true if A has passed B.
Definition: SDL_timer.h:56
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:162
SDL_GetVideoDevice
SDL_VideoDevice * SDL_GetVideoDevice(void)
Definition: SDL_video.c:586
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
void
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
Definition: SDL_dynapi_procs.h:89
device
static SDL_AudioDeviceID device
Definition: loopwave.c:37
floor
double floor(double x)
Definition: s_floor.c:33
SDL_Window::flags
Uint32 flags
Definition: SDL_sysvideo.h:84
type
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
SDL_SendQuit
int SDL_SendQuit(void)
Definition: SDL_quit.c:201
SDL_VideoDevice::suspend_screensaver
SDL_bool suspend_screensaver
Definition: SDL_sysvideo.h:322
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
init
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld init[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head if pixblock_size cache_preload_simple endif process_pixblock_tail pixinterleave dst_w_basereg irp if pixblock_size chunk_size tst beq if DST_W else pixst DST_W else mov ORIG_W endif add lsl if lsl endif if lsl endif lsl endif lsl endif lsl endif subs mov DST_W if regs_shortage str endif bge start_of_loop_label endm macro generate_composite_function
Definition: pixman-arm-neon-asm.h:624
SDL_VideoData
Definition: SDL_androidvideo.h:37