iOS: implement SDL_GetWindowSizeInPixels.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m
index 2b014bc..4e8a577 100644
--- a/src/video/uikit/SDL_uikitvideo.m
+++ b/src/video/uikit/SDL_uikitvideo.m
@@ -98,6 +98,7 @@ UIKit_CreateDevice(void)
device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
device->GetDisplayUsableBounds = UIKit_GetDisplayUsableBounds;
device->GetDisplayDPI = UIKit_GetDisplayDPI;
+ device->GetWindowSizeInPixels = UIKit_GetWindowSizeInPixels;
#if SDL_IPHONE_KEYBOARD
device->HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
diff --git a/src/video/uikit/SDL_uikitwindow.h b/src/video/uikit/SDL_uikitwindow.h
index 65dbc87..7ca9b47 100644
--- a/src/video/uikit/SDL_uikitwindow.h
+++ b/src/video/uikit/SDL_uikitwindow.h
@@ -36,6 +36,7 @@ extern void UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDispl
extern void UIKit_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
extern void UIKit_UpdatePointerLock(_THIS, SDL_Window * window);
extern void UIKit_DestroyWindow(_THIS, SDL_Window * window);
+extern void UIKit_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h);
extern SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo * info);
diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m
index 8a923fb..433c80e 100644
--- a/src/video/uikit/SDL_uikitwindow.m
+++ b/src/video/uikit/SDL_uikitwindow.m
@@ -369,6 +369,25 @@ UIKit_DestroyWindow(_THIS, SDL_Window * window)
window->driverdata = NULL;
}
+void
+UIKit_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h)
+{ @autoreleasepool
+{
+ SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata;
+ UIView *view = windata.viewcontroller.view;
+ CGSize size = view.bounds.size;
+ CGFloat scale = 1.0;
+
+ if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
+ scale = windata.uiwindow.screen.nativeScale;
+ }
+
+ /* Integer truncation of fractional values matches SDL_uikitmetalview and
+ * SDL_uikitopenglview. */
+ *w = size.width * scale;
+ *h = size.height * scale;
+}}
+
SDL_bool
UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
{