21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_UIKIT
28 #include "../../events/SDL_events_c.h"
30 #import <sys/utsname.h>
34 - (instancetype)initWithScreen:(UIScreen*)screen
36 if (
self = [super
init]) {
141 struct utsname systemInfo;
143 NSString* deviceName =
144 [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
145 id foundDPI =
devices[deviceName];
147 self.screenDPI = (float)[foundDPI integerValue];
153 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000
159 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
161 }
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
166 self.screenDPI =
scale * defaultDPI;
172 @synthesize uiscreen;
173 @synthesize screenDPI;
183 @interface SDL_DisplayWatch : NSObject
186 @implementation SDL_DisplayWatch
190 NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
192 [center addObserver:self selector:@selector(screenConnected:)
193 name:UIScreenDidConnectNotification object:nil];
194 [center addObserver:self selector:@selector(screenDisconnected:)
195 name:UIScreenDidDisconnectNotification object:nil];
200 NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
202 [center removeObserver:self
203 name:UIScreenDidConnectNotification object:nil];
204 [center removeObserver:self
205 name:UIScreenDidDisconnectNotification object:nil];
208 + (
void)screenConnected:(NSNotification*)notification
210 UIScreen *uiscreen = [notification object];
214 + (
void)screenDisconnected:(NSNotification*)notification
216 UIScreen *uiscreen = [notification object];
224 UIScreenMode * uiscreenmode)
228 if (uiscreenmode != nil) {
235 data.uiscreenmode = uiscreenmode;
238 mode->driverdata = (
void *) CFBridgingRetain(
data);
247 CFRelease(
mode->driverdata);
253 UIKit_GetDisplayModeRefreshRate(UIScreen *uiscreen)
256 if ([uiscreen respondsToSelector:
@selector(maximumFramesPerSecond)]) {
257 return uiscreen.maximumFramesPerSecond;
265 UIScreen * uiscreen, UIScreenMode * uiscreenmode)
270 if (UIKit_AllocateDisplayModeData(&
mode, uiscreenmode) < 0) {
275 mode.refresh_rate = (
int) UIKit_GetDisplayModeRefreshRate(uiscreen);
282 UIKit_FreeDisplayModeData(&
mode);
289 UIScreenMode * uiscreenmode,
SDL_bool addRotation)
291 if (UIKit_AddSingleDisplayMode(display,
w,
h, uiscreen, uiscreenmode) < 0) {
297 if (UIKit_AddSingleDisplayMode(display,
h,
w, uiscreen, uiscreenmode) < 0) {
308 UIScreenMode *uiscreenmode = uiscreen.currentMode;
309 CGSize
size = uiscreen.bounds.size;
322 mode.refresh_rate = (
int) UIKit_GetDisplayModeRefreshRate(uiscreen);
326 if (UIKit_AllocateDisplayModeData(&
mode, uiscreenmode) < 0) {
355 if (
data &&
data.uiscreen == uiscreen) {
367 if (uiscreen == [UIScreen mainScreen]) {
368 return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
372 CGSize
size = uiscreen.bounds.size;
381 for (UIScreen *uiscreen
in [UIScreen screens]) {
390 [SDL_DisplayWatch start];
403 SDL_bool addRotation = (
data.uiscreen == [UIScreen mainScreen]);
405 NSArray *availableModes = nil;
409 availableModes = @[data.uiscreen.currentMode];
411 availableModes =
data.uiscreen.availableModes;
414 for (UIScreenMode *uimode
in availableModes) {
426 int w = (
int)(uimode.size.width /
scale);
427 int h = (
int)(uimode.size.height /
scale);
430 if (isLandscape != (
w >
h)) {
436 UIKit_AddDisplayMode(display,
w,
h,
data.uiscreen, uimode, addRotation);
446 float dpi =
data.screenDPI;
470 [data.uiscreen setCurrentMode:modedata.uiscreenmode];
473 if (
data.uiscreen == [UIScreen mainScreen]) {
479 return SDL_SetError(
"Screen orientation does not match display mode size");
483 return SDL_SetError(
"Screen orientation does not match display mode size");
506 #if !TARGET_OS_TV && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
508 frame = [data.uiscreen applicationFrame];
524 [SDL_DisplayWatch stop];
535 UIKit_FreeDisplayModeData(
mode);
549 BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
561 if (isLandscape != (desktopmode->
w > desktopmode->
h)) {
563 desktopmode->
w = desktopmode->
h;
568 if (isLandscape != (currentmode->
w > currentmode->
h)) {
570 currentmode->
w = currentmode->
h;
574 switch ([UIApplication sharedApplication].statusBarOrientation) {
575 case UIInterfaceOrientationPortrait:
578 case UIInterfaceOrientationPortraitUpsideDown:
581 case UIInterfaceOrientationLandscapeLeft:
585 case UIInterfaceOrientationLandscapeRight:
int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1)
#define SDL_OnApplicationDidChangeStatusBarOrientation
#define SDL_GetNumVideoDisplays
#define SDL_GetDisplayBounds
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()
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei height
GLenum GLenum GLenum GLenum GLenum scale
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
@ SDL_PIXELFORMAT_ABGR8888
void * SDL_GetDisplayDriverData(int displayIndex)
void SDL_DelVideoDisplay(int index)
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event)
SDL_VideoDisplay * SDL_GetDisplay(int displayIndex)
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
void UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
void UIKit_QuitModes(_THIS)
int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event)
int UIKit_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
void UIKit_DelDisplay(UIScreen *uiscreen)
int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen)
int UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
int UIKit_InitModes(_THIS)
SDL_bool UIKit_IsSystemVersionAtLeast(double version)
static SDL_VideoDevice * _this
@ SDL_DISPLAYEVENT_ORIENTATION
@ SDL_ORIENTATION_LANDSCAPE
@ SDL_ORIENTATION_PORTRAIT
@ SDL_ORIENTATION_PORTRAIT_FLIPPED
@ SDL_ORIENTATION_LANDSCAPE_FLIPPED
@ SDL_ORIENTATION_UNKNOWN
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)
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 int in j)
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.
A rectangle, with the origin at the upper left (integer).
SDL_VideoDisplay * displays
SDL_DisplayMode desktop_mode
SDL_DisplayMode * display_modes
SDL_DisplayMode current_mode
typedef int(__stdcall *FARPROC)()