21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_UIKIT 30 #include "../SDL_sysvideo.h" 31 #include "../SDL_pixels_c.h" 32 #include "../../events/SDL_events_c.h" 43 #include <Foundation/Foundation.h> 53 if ((
self = [super
init])) {
54 views = [NSMutableArray new];
62 @interface SDL_uikitwindow : UIWindow
64 - (
void)layoutSubviews;
68 @implementation SDL_uikitwindow
70 - (
void)layoutSubviews
73 self.frame =
self.screen.bounds;
74 [
super layoutSubviews];
86 CGRect
frame = UIKit_ComputeViewFrame(window, displaydata.
uiscreen);
95 window->
driverdata = (
void *) CFBridgingRetain(data);
102 if (displaydata.
uiscreen != [UIScreen mainScreen]) {
109 if (displaydata.
uiscreen == [UIScreen mainScreen]) {
111 BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0;
112 BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown)) != 0;
115 if ((width >
height && !supportsLandscape) || (
height > width && !supportsPortrait)) {
138 [view setSDLWindow:window];
141 if (displaydata.
uiscreen == [UIScreen mainScreen]) {
161 return SDL_SetError(
"Only one window allowed per display.");
168 const CGSize origsize = data.
uiscreen.currentMode.size;
169 if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) {
178 if ((mode->
w >= window->
w) && (mode->
h >= window->
h)) {
194 if (data.
uiscreen == [UIScreen mainScreen]) {
196 [UIApplication sharedApplication].statusBarHidden = YES;
198 [UIApplication sharedApplication].statusBarHidden = NO;
205 UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds];
208 if (data.
uiscreen != [UIScreen mainScreen]) {
209 [uiwindow setScreen:data.uiscreen];
212 if (SetupWindowData(
_this, window, uiwindow,
SDL_TRUE) < 0) {
264 if (data.
uiwindow.screen == [UIScreen mainScreen]) {
266 [UIApplication sharedApplication].statusBarHidden = YES;
268 [UIApplication sharedApplication].statusBarHidden = NO;
272 if ([
viewcontroller respondsToSelector:
@selector(setNeedsStatusBarAppearanceUpdate)]) {
273 [viewcontroller setNeedsStatusBarAppearanceUpdate];
281 #ifdef SDL_IPHONE_KEYBOARD 283 [viewcontroller updateKeyboard];
286 [viewcontroller.view setNeedsLayout];
287 [viewcontroller.view layoutIfNeeded];
294 UIKit_UpdateWindowBorder(
_this, window);
302 UIKit_UpdateWindowBorder(
_this, window);
312 NSArray *
views = nil;
314 [data.viewcontroller stopAnimation];
319 views = [data.views copy];
321 [view setSDLWindow:NULL];
328 data.
uiwindow.rootViewController = nil;
350 SDL_uikitopenglview *glview = (SDL_uikitopenglview *)data.
viewcontroller.view;
355 info->
info.uikit.framebuffer = 0;
356 info->
info.uikit.colorbuffer = 0;
357 info->
info.uikit.resolveFramebuffer = 0;
363 SDL_SetError(
"Application not compiled with SDL %d.%d\n",
375 NSUInteger validOrientations = UIInterfaceOrientationMaskAll;
376 NSUInteger orientationMask = 0;
380 UIApplication *app = [UIApplication sharedApplication];
384 if ([app.delegate respondsToSelector:
@selector(application:supportedInterfaceOrientationsForWindow:)]) {
385 validOrientations = [app.delegate application:app supportedInterfaceOrientationsForWindow:data.uiwindow];
386 }
else if ([app respondsToSelector:
@selector(supportedInterfaceOrientationsForWindow:)]) {
387 validOrientations = [app supportedInterfaceOrientationsForWindow:data.uiwindow];
391 NSArray *orientations = [@(hint) componentsSeparatedByString:@" "];
393 if ([orientations containsObject:
@"LandscapeLeft"]) {
394 orientationMask |= UIInterfaceOrientationMaskLandscapeLeft;
396 if ([orientations containsObject:
@"LandscapeRight"]) {
397 orientationMask |= UIInterfaceOrientationMaskLandscapeRight;
399 if ([orientations containsObject:
@"Portrait"]) {
400 orientationMask |= UIInterfaceOrientationMaskPortrait;
402 if ([orientations containsObject:
@"PortraitUpsideDown"]) {
403 orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown;
409 orientationMask = UIInterfaceOrientationMaskAll;
412 if (orientationMask == 0) {
413 if (window->
w >= window->
h) {
414 orientationMask |= UIInterfaceOrientationMaskLandscape;
416 if (window->
h >= window->
w) {
417 orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
422 if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
423 orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown;
429 if ((validOrientations & orientationMask) == 0) {
430 orientationMask = validOrientations;
434 return orientationMask;
449 callbackParam:callbackParam];
#define SDL_MINOR_VERSION
SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
void SDL_SetKeyboardFocus(SDL_Window *window)
int UIKit_CreateWindow(_THIS, SDL_Window *window)
GLint GLint GLsizei width
GLuint drawableRenderbuffer
void UIKit_DestroyWindow(_THIS, SDL_Window *window)
#define SDL_MAJOR_VERSION
SDL_uikitviewcontroller * viewcontroller
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
The structure that defines a display mode.
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 local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
void UIKit_SetWindowTitle(_THIS, SDL_Window *window)
void UIKit_RaiseWindow(_THIS, SDL_Window *window)
void UIKit_HideWindow(_THIS, SDL_Window *window)
void SDL_SetMouseFocus(SDL_Window *window)
GLuint drawableFramebuffer
GLuint msaaResolveFramebuffer
GLint GLint GLsizei GLsizei height
void UIKit_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
NSUInteger UIKit_GetSupportedOrientations(SDL_Window *window)
static SDL_VideoDevice * _this
SDL_GLContext current_glctx
void UIKit_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
#define SDL_VERSIONNUM(X, Y, Z)
SDL_DisplayMode * display_modes
SDL_DisplayMode current_mode
static Uint32 callback(Uint32 interval, void *param)
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)
#define SDL_assert(condition)
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
#define SDL_HINT_ORIENTATIONS
A variable controlling which orientations are allowed on iOS.
#define SDL_OutOfMemory()
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
UIScreenMode * uiscreenmode
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
The type used to identify a 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 local 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
union SDL_SysWMinfo::@18 info
void UIKit_ShowWindow(_THIS, SDL_Window *window)
SDL_Window * current_glwin
#define SDL_iPhoneSetAnimationCallback