iOS: fix screen black flickers and queue UI api calls to the main thread
This commit is contained in:
@@ -69,7 +69,7 @@ std::recursive_mutex lock_mutex;
|
||||
}
|
||||
- (void)async_swap
|
||||
{
|
||||
[self.context presentRenderbuffer:GL_RENDERBUFFER];
|
||||
[self.context presentRenderbuffer:GL_FRAMEBUFFER];
|
||||
}
|
||||
|
||||
- (void)share_file:(NSString *)file_path
|
||||
@@ -468,16 +468,16 @@ std::set<UITouch*> ignored_touch;
|
||||
|
||||
App::I.tick(dt.count());
|
||||
|
||||
[self async_lock];
|
||||
if (!(App::I.redraw || App::I.animate || !working_list.empty()))
|
||||
{
|
||||
//[self.context presentRenderbuffer:GL_FRAMEBUFFER];
|
||||
//[self async_unlock];
|
||||
[self.context presentRenderbuffer:GL_FRAMEBUFFER];
|
||||
[self async_unlock];
|
||||
std::unique_lock<std::mutex> lock(render_mutex);
|
||||
render_cv.wait(lock);
|
||||
continue;
|
||||
}
|
||||
|
||||
[self async_lock];
|
||||
while (!working_list.empty())
|
||||
{
|
||||
working_list.front()();
|
||||
|
||||
@@ -41,8 +41,10 @@ void App::showKeyboard()
|
||||
LOG("show keyboard");
|
||||
redraw = true;
|
||||
#ifdef __IOS__
|
||||
[ios_view registerForKeyboardNotifications];
|
||||
[ios_view becomeFirstResponder];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view registerForKeyboardNotifications];
|
||||
[ios_view becomeFirstResponder];
|
||||
});
|
||||
#elif __ANDROID__
|
||||
displayKeyboard(and_app, true);
|
||||
#endif
|
||||
@@ -53,8 +55,10 @@ void App::hideKeyboard()
|
||||
LOG("hide keyboard");
|
||||
redraw = true;
|
||||
#ifdef __IOS__
|
||||
[ios_view resignFirstResponder];
|
||||
// [ios_view unregisterForKeyboardNotifications];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view resignFirstResponder];
|
||||
// [ios_view unregisterForKeyboardNotifications];
|
||||
});
|
||||
#elif __ANDROID__
|
||||
displayKeyboard(and_app, false);
|
||||
#endif
|
||||
@@ -64,7 +68,9 @@ void App::pick_image(std::function<void(std::string path)> callback)
|
||||
{
|
||||
redraw = true;
|
||||
#ifdef __IOS__
|
||||
[ios_view pick_photo:callback];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view pick_photo:callback];
|
||||
});
|
||||
#elif __OSX__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSArray* fileTypes = [NSArray arrayWithObjects:@"png", @"PNG", @"jpg", @"JPG", @"jpeg", nil];
|
||||
@@ -87,7 +93,9 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
|
||||
#ifdef __IOS__
|
||||
// not implemented on ios
|
||||
// fallback to pick_image
|
||||
[ios_view pick_photo:callback];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view pick_photo:callback];
|
||||
});
|
||||
#elif __OSX__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//NSArray* fileTypes = [NSArray arrayWithObjects:@"ppi", @"PPI", nil];
|
||||
@@ -147,7 +155,9 @@ void App::pick_dir(std::function<void(std::string path)> callback)
|
||||
void App::display_file(std::string path)
|
||||
{
|
||||
#ifdef __IOS__
|
||||
[ios_view display_file:path];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view display_file:path];
|
||||
});
|
||||
#elif __OSX__
|
||||
[[NSWorkspace sharedWorkspace] openFile:[NSString stringWithUTF8String:path.c_str()]];
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
Reference in New Issue
Block a user