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]) {
119 BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0;
120 BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown)) != 0;
123 if ((width >
height && !supportsLandscape) || (
height > width && !supportsPortrait)) {
146 [view setSDLWindow:window];
149 if (displaydata.
uiscreen == [UIScreen mainScreen]) {
169 return SDL_SetError(
"Only one window allowed per display.");
176 const CGSize origsize = data.
uiscreen.currentMode.size;
177 if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) {
186 if ((mode->
w >= window->
w) && (mode->
h >= window->
h)) {
202 if (data.
uiscreen == [UIScreen mainScreen]) {
204 [UIApplication sharedApplication].statusBarHidden = YES;
206 [UIApplication sharedApplication].statusBarHidden = NO;
213 UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds];
216 if (data.
uiscreen != [UIScreen mainScreen]) {
217 [uiwindow setScreen:data.uiscreen];
220 if (SetupWindowData(
_this, window, uiwindow,
SDL_TRUE) < 0) {
272 if (data.
uiwindow.screen == [UIScreen mainScreen]) {
274 [UIApplication sharedApplication].statusBarHidden = YES;
276 [UIApplication sharedApplication].statusBarHidden = NO;
280 if ([
viewcontroller respondsToSelector:
@selector(setNeedsStatusBarAppearanceUpdate)]) {
281 [viewcontroller setNeedsStatusBarAppearanceUpdate];
289 #ifdef SDL_IPHONE_KEYBOARD 291 [viewcontroller updateKeyboard];
294 [viewcontroller.view setNeedsLayout];
295 [viewcontroller.view layoutIfNeeded];
302 UIKit_UpdateWindowBorder(
_this, window);
310 UIKit_UpdateWindowBorder(
_this, window);
320 NSArray *
views = nil;
322 [data.viewcontroller stopAnimation];
327 views = [data.views copy];
329 [view setSDLWindow:NULL];
336 data.
uiwindow.rootViewController = nil;
358 SDL_uikitopenglview *glview = (SDL_uikitopenglview *)data.
viewcontroller.view;
363 info->
info.uikit.framebuffer = 0;
364 info->
info.uikit.colorbuffer = 0;
365 info->
info.uikit.resolveFramebuffer = 0;
383 NSUInteger validOrientations = UIInterfaceOrientationMaskAll;
384 NSUInteger orientationMask = 0;
388 UIApplication *app = [UIApplication sharedApplication];
392 if ([app.delegate respondsToSelector:
@selector(application:supportedInterfaceOrientationsForWindow:)]) {
393 validOrientations = [app.delegate application:app supportedInterfaceOrientationsForWindow:data.uiwindow];
394 }
else if ([app respondsToSelector:
@selector(supportedInterfaceOrientationsForWindow:)]) {
395 validOrientations = [app supportedInterfaceOrientationsForWindow:data.uiwindow];
399 NSArray *orientations = [@(hint) componentsSeparatedByString:@" "];
401 if ([orientations containsObject:
@"LandscapeLeft"]) {
402 orientationMask |= UIInterfaceOrientationMaskLandscapeLeft;
404 if ([orientations containsObject:
@"LandscapeRight"]) {
405 orientationMask |= UIInterfaceOrientationMaskLandscapeRight;
407 if ([orientations containsObject:
@"Portrait"]) {
408 orientationMask |= UIInterfaceOrientationMaskPortrait;
410 if ([orientations containsObject:
@"PortraitUpsideDown"]) {
411 orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown;
417 orientationMask = UIInterfaceOrientationMaskAll;
420 if (orientationMask == 0) {
421 if (window->
w >= window->
h) {
422 orientationMask |= UIInterfaceOrientationMaskLandscape;
424 if (window->
h >= window->
w) {
425 orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
430 if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
431 orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown;
437 if ((validOrientations & orientationMask) == 0) {
438 orientationMask = validOrientations;
442 return orientationMask;
457 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)
GLuint drawableRenderbuffer
void UIKit_DestroyWindow(_THIS, SDL_Window *window)
#define SDL_MAJOR_VERSION
SDL_uikitviewcontroller * viewcontroller
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)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void UIKit_HideWindow(_THIS, SDL_Window *window)
void SDL_SetMouseFocus(SDL_Window *window)
GLuint drawableFramebuffer
GLuint msaaResolveFramebuffer
void UIKit_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
NSUInteger UIKit_GetSupportedOrientations(SDL_Window *window)
GLint GLint GLsizei width
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/Android.
#define SDL_OutOfMemory()
GLint GLint GLsizei GLsizei height
UIScreenMode * uiscreenmode
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
EGLSurface EGLNativeWindowType * window
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
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