21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_UIKIT
29 #include "../SDL_sysvideo.h"
30 #include "../SDL_pixels_c.h"
31 #include "../../events/SDL_events_c.h"
42 #include <Foundation/Foundation.h>
52 if ((
self = [super
init])) {
53 views = [NSMutableArray new];
61 @interface SDL_uikitwindow : UIWindow
63 - (
void)layoutSubviews;
67 @implementation SDL_uikitwindow
69 - (
void)layoutSubviews
78 self.frame =
self.screen.bounds;
80 [
super layoutSubviews];
102 window->driverdata = (
void *) CFBridgingRetain(
data);
104 data.uiwindow = uiwindow;
109 if (displaydata.
uiscreen != [UIScreen mainScreen]) {
116 if (displaydata.
uiscreen == [UIScreen mainScreen]) {
126 BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0;
127 BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown)) != 0;
153 [view setSDLWindow:window];
169 return SDL_SetError(
"Only one window allowed per display.");
177 const CGSize origsize =
data.uiscreen.currentMode.size;
178 if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) {
203 if (
data.uiscreen == [UIScreen mainScreen]) {
205 [UIApplication sharedApplication].statusBarHidden = YES;
207 [UIApplication sharedApplication].statusBarHidden = NO;
214 UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds];
217 if (
data.uiscreen != [UIScreen mainScreen]) {
218 [uiwindow setScreen:data.uiscreen];
243 [
data.uiwindow makeKeyAndVisible];
248 if (displaydata.
uiscreen == [UIScreen mainScreen]) {
281 if (
data.uiwindow.screen == [UIScreen mainScreen]) {
283 [UIApplication sharedApplication].statusBarHidden = YES;
285 [UIApplication sharedApplication].statusBarHidden = NO;
289 if ([viewcontroller respondsToSelector:
@selector(setNeedsStatusBarAppearanceUpdate)]) {
290 [viewcontroller setNeedsStatusBarAppearanceUpdate];
295 viewcontroller.view.frame = UIKit_ComputeViewFrame(
window,
data.uiwindow.screen);
298 #ifdef SDL_IPHONE_KEYBOARD
300 [viewcontroller updateKeyboard];
303 [viewcontroller.view setNeedsLayout];
304 [viewcontroller.view layoutIfNeeded];
329 NSArray *views = nil;
331 [data.viewcontroller stopAnimation];
336 views = [data.views copy];
338 [view setSDLWindow:NULL];
346 data.uiwindow.hidden = YES;
366 #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
367 if ([
data.viewcontroller.view isKindOfClass:[SDL_uikitopenglview
class]]) {
368 SDL_uikitopenglview *glview = (SDL_uikitopenglview *)
data.viewcontroller.view;
369 info->
info.uikit.framebuffer = glview.drawableFramebuffer;
370 info->
info.uikit.colorbuffer = glview.drawableRenderbuffer;
371 info->
info.uikit.resolveFramebuffer = glview.msaaResolveFramebuffer;
376 info->
info.uikit.framebuffer = 0;
377 info->
info.uikit.colorbuffer = 0;
378 info->
info.uikit.resolveFramebuffer = 0;
396 NSUInteger validOrientations = UIInterfaceOrientationMaskAll;
397 NSUInteger orientationMask = 0;
401 UIApplication *app = [UIApplication sharedApplication];
405 if ([app.delegate respondsToSelector:
@selector(application:supportedInterfaceOrientationsForWindow:)]) {
406 validOrientations = [app.delegate application:app supportedInterfaceOrientationsForWindow:data.uiwindow];
407 }
else if ([app respondsToSelector:
@selector(supportedInterfaceOrientationsForWindow:)]) {
408 validOrientations = [app supportedInterfaceOrientationsForWindow:data.uiwindow];
412 NSArray *orientations = [@(hint) componentsSeparatedByString:@" "];
414 if ([orientations containsObject:
@"LandscapeLeft"]) {
415 orientationMask |= UIInterfaceOrientationMaskLandscapeLeft;
417 if ([orientations containsObject:
@"LandscapeRight"]) {
418 orientationMask |= UIInterfaceOrientationMaskLandscapeRight;
420 if ([orientations containsObject:
@"Portrait"]) {
421 orientationMask |= UIInterfaceOrientationMaskPortrait;
423 if ([orientations containsObject:
@"PortraitUpsideDown"]) {
424 orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown;
430 orientationMask = UIInterfaceOrientationMaskAll;
433 if (orientationMask == 0) {
435 orientationMask |= UIInterfaceOrientationMaskLandscape;
438 orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
443 if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
444 orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown;
450 if ((validOrientations & orientationMask) == 0) {
451 orientationMask = validOrientations;
455 return orientationMask;
468 [
data.viewcontroller setAnimationCallback:interval
470 callbackParam:callbackParam];
#define SDL_iPhoneSetAnimationCallback
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
#define SDL_OutOfMemory()
#define SDL_HINT_ORIENTATIONS
A variable controlling which orientations are allowed on iOS/Android.
void SDL_SetKeyboardFocus(SDL_Window *window)
void SDL_SetMouseFocus(SDL_Window *window)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei width
GLint GLint GLsizei GLsizei height
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
SDL_bool UIKit_IsSystemVersionAtLeast(double version)
void UIKit_ShowWindow(_THIS, SDL_Window *window)
void UIKit_RaiseWindow(_THIS, SDL_Window *window)
SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
void UIKit_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
void UIKit_SetWindowTitle(_THIS, SDL_Window *window)
void UIKit_DestroyWindow(_THIS, SDL_Window *window)
void UIKit_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
NSUInteger UIKit_GetSupportedOrientations(SDL_Window *window)
int UIKit_CreateWindow(_THIS, SDL_Window *window)
void UIKit_HideWindow(_THIS, SDL_Window *window)
#define SDL_MINOR_VERSION
#define SDL_MAJOR_VERSION
#define SDL_VERSIONNUM(X, Y, Z)
static SDL_VideoDevice * _this
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)
EGLSurface EGLNativeWindowType * window
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 ®2 endm macro vzip8 reg2 vzip d d ®2 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
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 ®2 endm macro vzip8 reg2 vzip d d ®2 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
UIScreenMode * uiscreenmode
The structure that defines a display mode.
union SDL_SysWMinfo::@10 info
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
SDL_GLContext current_glctx
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
SDL_Window * current_glwin
SDL_DisplayMode * display_modes
SDL_DisplayMode current_mode
SDL_uikitviewcontroller * viewcontroller
The type used to identify a window.
static Uint32 callback(Uint32 interval, void *param)
typedef int(__stdcall *FARPROC)()