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
|
- (void)async_swap
|
||||||
{
|
{
|
||||||
[self.context presentRenderbuffer:GL_RENDERBUFFER];
|
[self.context presentRenderbuffer:GL_FRAMEBUFFER];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)share_file:(NSString *)file_path
|
- (void)share_file:(NSString *)file_path
|
||||||
@@ -468,16 +468,16 @@ std::set<UITouch*> ignored_touch;
|
|||||||
|
|
||||||
App::I.tick(dt.count());
|
App::I.tick(dt.count());
|
||||||
|
|
||||||
|
[self async_lock];
|
||||||
if (!(App::I.redraw || App::I.animate || !working_list.empty()))
|
if (!(App::I.redraw || App::I.animate || !working_list.empty()))
|
||||||
{
|
{
|
||||||
//[self.context presentRenderbuffer:GL_FRAMEBUFFER];
|
[self.context presentRenderbuffer:GL_FRAMEBUFFER];
|
||||||
//[self async_unlock];
|
[self async_unlock];
|
||||||
std::unique_lock<std::mutex> lock(render_mutex);
|
std::unique_lock<std::mutex> lock(render_mutex);
|
||||||
render_cv.wait(lock);
|
render_cv.wait(lock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self async_lock];
|
|
||||||
while (!working_list.empty())
|
while (!working_list.empty())
|
||||||
{
|
{
|
||||||
working_list.front()();
|
working_list.front()();
|
||||||
|
|||||||
@@ -41,8 +41,10 @@ void App::showKeyboard()
|
|||||||
LOG("show keyboard");
|
LOG("show keyboard");
|
||||||
redraw = true;
|
redraw = true;
|
||||||
#ifdef __IOS__
|
#ifdef __IOS__
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[ios_view registerForKeyboardNotifications];
|
[ios_view registerForKeyboardNotifications];
|
||||||
[ios_view becomeFirstResponder];
|
[ios_view becomeFirstResponder];
|
||||||
|
});
|
||||||
#elif __ANDROID__
|
#elif __ANDROID__
|
||||||
displayKeyboard(and_app, true);
|
displayKeyboard(and_app, true);
|
||||||
#endif
|
#endif
|
||||||
@@ -53,8 +55,10 @@ void App::hideKeyboard()
|
|||||||
LOG("hide keyboard");
|
LOG("hide keyboard");
|
||||||
redraw = true;
|
redraw = true;
|
||||||
#ifdef __IOS__
|
#ifdef __IOS__
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[ios_view resignFirstResponder];
|
[ios_view resignFirstResponder];
|
||||||
// [ios_view unregisterForKeyboardNotifications];
|
// [ios_view unregisterForKeyboardNotifications];
|
||||||
|
});
|
||||||
#elif __ANDROID__
|
#elif __ANDROID__
|
||||||
displayKeyboard(and_app, false);
|
displayKeyboard(and_app, false);
|
||||||
#endif
|
#endif
|
||||||
@@ -64,7 +68,9 @@ void App::pick_image(std::function<void(std::string path)> callback)
|
|||||||
{
|
{
|
||||||
redraw = true;
|
redraw = true;
|
||||||
#ifdef __IOS__
|
#ifdef __IOS__
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[ios_view pick_photo:callback];
|
[ios_view pick_photo:callback];
|
||||||
|
});
|
||||||
#elif __OSX__
|
#elif __OSX__
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
NSArray* fileTypes = [NSArray arrayWithObjects:@"png", @"PNG", @"jpg", @"JPG", @"jpeg", nil];
|
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__
|
#ifdef __IOS__
|
||||||
// not implemented on ios
|
// not implemented on ios
|
||||||
// fallback to pick_image
|
// fallback to pick_image
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[ios_view pick_photo:callback];
|
[ios_view pick_photo:callback];
|
||||||
|
});
|
||||||
#elif __OSX__
|
#elif __OSX__
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
//NSArray* fileTypes = [NSArray arrayWithObjects:@"ppi", @"PPI", nil];
|
//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)
|
void App::display_file(std::string path)
|
||||||
{
|
{
|
||||||
#ifdef __IOS__
|
#ifdef __IOS__
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[ios_view display_file:path];
|
[ios_view display_file:path];
|
||||||
|
});
|
||||||
#elif __OSX__
|
#elif __OSX__
|
||||||
[[NSWorkspace sharedWorkspace] openFile:[NSString stringWithUTF8String:path.c_str()]];
|
[[NSWorkspace sharedWorkspace] openFile:[NSString stringWithUTF8String:path.c_str()]];
|
||||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
|||||||
Reference in New Issue
Block a user