Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2] [iOS] Port 4.0 changes #42582

Merged
merged 2 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions modules/arkit/arkit_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
// forward declaration for some needed objects
class ARKitShader;

#ifdef __OBJC__
typedef NSObject GodotARAnchor;
#else
typedef void GodotARAnchor;
#endif

class ARKitInterface : public ARVRInterface {
GDCLASS(ARKitInterface, ARVRInterface);

Expand Down Expand Up @@ -115,8 +121,8 @@ class ARKitInterface : public ARVRInterface {
virtual void process();

// called by delegate (void * because C++ and Obj-C don't always mix, should really change all platform/iphone/*.cpp files to .mm)
void _add_or_update_anchor(void *p_anchor);
void _remove_anchor(void *p_anchor);
void _add_or_update_anchor(GodotARAnchor *p_anchor);
void _remove_anchor(GodotARAnchor *p_anchor);

ARKitInterface();
~ARKitInterface();
Expand Down
10 changes: 3 additions & 7 deletions modules/arkit/arkit_interface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,8 @@
remove_all_anchors();

if (@available(iOS 11.0, *)) {
[ar_session release];
ar_session = NULL;
ar_session = nil;
}
[ar_delegate release];

ar_delegate = NULL;
initialized = false;
Expand Down Expand Up @@ -469,10 +467,8 @@

if (@available(iOS 13, *)) {
orientation = [UIApplication sharedApplication].delegate.window.windowScene.interfaceOrientation;
#if !defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR
} else {
orientation = [[UIApplication sharedApplication] statusBarOrientation];
#endif
}

// Grab our camera image for our backbuffer
Expand Down Expand Up @@ -686,7 +682,7 @@
}
}

void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
void ARKitInterface::_add_or_update_anchor(GodotARAnchor *p_anchor) {
_THREAD_SAFE_METHOD_

if (@available(iOS 11.0, *)) {
Expand Down Expand Up @@ -748,7 +744,7 @@
}
}

void ARKitInterface::_remove_anchor(void *p_anchor) {
void ARKitInterface::_remove_anchor(GodotARAnchor *p_anchor) {
_THREAD_SAFE_METHOD_

if (@available(iOS 11.0, *)) {
Expand Down
39 changes: 17 additions & 22 deletions modules/camera/camera_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,12 @@ - (void)cleanup {
if (output) {
[self removeOutput:output];
[output setSampleBufferDelegate:nil queue:NULL];
[output release];
output = nil;
}

[self commitConfiguration];
}

- (void)dealloc {
// bye bye
[super dealloc];
}

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
// This gets called every time our camera has a new image for us to process.
// May need to investigate in a way to throttle this if we get more images then we're rendering frames..
Expand All @@ -158,7 +152,14 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
} else if (dataCbCr == NULL) {
print_line("Couldn't access CbCr pixel buffer data");
} else {
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
UIInterfaceOrientation orientation = UIInterfaceOrientationUnknown;

if (@available(iOS 13, *)) {
orientation = [UIApplication sharedApplication].delegate.window.windowScene.interfaceOrientation;
} else {
orientation = [[UIApplication sharedApplication] statusBarOrientation];
}

Ref<Image> img[2];

{
Expand Down Expand Up @@ -263,7 +264,6 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM

void CameraFeedIOS::set_device(AVCaptureDevice *p_device) {
device = p_device;
[device retain];

// get some info
NSString *device_name = p_device.localizedName;
Expand All @@ -277,15 +277,13 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
};

CameraFeedIOS::~CameraFeedIOS() {
if (capture_session != NULL) {
[capture_session release];
capture_session = NULL;
};
if (capture_session) {
capture_session = nil;
}

if (device != NULL) {
[device release];
device = NULL;
};
if (device) {
device = nil;
}
};

bool CameraFeedIOS::activate_feed() {
Expand All @@ -303,9 +301,8 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
// end camera capture if we have one
if (capture_session) {
[capture_session cleanup];
[capture_session release];
capture_session = NULL;
};
capture_session = nil;
}
};

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -338,8 +335,6 @@ - (void)dealloc {
// remove notifications
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVCaptureDeviceWasConnectedNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVCaptureDeviceWasDisconnectedNotification object:nil];

[super dealloc];
}

@end
Expand Down Expand Up @@ -442,5 +437,5 @@ - (void)dealloc {
};

CameraIOS::~CameraIOS() {
[device_notifications release];
device_notifications = nil;
};
3 changes: 1 addition & 2 deletions modules/mono/mono_gd/support/ios_support.mm
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ GD_PINVOKE_EXPORT void xamarin_log(const uint16_t *p_unicode_message) {
NSTimeZone *tz = nil;
if (p_name) {
NSString *n = [[NSString alloc] initWithUTF8String:p_name];
tz = [[[NSTimeZone alloc] initWithName:n] autorelease];
[n release];
tz = [[NSTimeZone alloc] initWithName:n];
} else {
tz = [NSTimeZone localTimeZone];
}
Expand Down
11 changes: 8 additions & 3 deletions platform/iphone/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
Import("env")

iphone_lib = [
"godot_iphone.cpp",
"os_iphone.mm",
"semaphore_iphone.cpp",
"godot_view.mm",
"godot_iphone.mm",
"os_iphone.mm",
"main.m",
"app_delegate.mm",
"view_controller.mm",
"game_center.mm",
"in_app_store.mm",
"icloud.mm",
"ios.mm",
"joypad_iphone.mm",
"godot_view.mm",
"display_layer.mm",
"godot_view_renderer.mm",
"godot_view_gesture_recognizer.mm",
"device_metrics.m",
"native_video_view.m",
]

env_ios = env.Clone()
Expand Down
12 changes: 3 additions & 9 deletions platform/iphone/app_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

#import "godot_view.h"
#import "view_controller.h"
#import <UIKit/UIKit.h>

#import <CoreMotion/CoreMotion.h>
@class ViewController;

@interface AppDelegate : NSObject <UIApplicationDelegate, GodotViewDelegate> {
//@property (strong, nonatomic) UIWindow *window;
ViewController *view_controller;
bool is_focus_out;
};
@interface AppDelegate : NSObject <UIApplicationDelegate>

@property(strong, class, readonly, nonatomic) ViewController *viewController;
@property(strong, nonatomic) UIWindow *window;
@property(strong, class, readonly, nonatomic) ViewController *viewController;

@end
Loading