提交 8071298e 编写于 作者: X Xinzheng Zhang

ios/IJKSDLGLView: lock opengl during moved to window

上级 48fab142
......@@ -33,6 +33,7 @@
- (UIImage*) snapshot;
- (void)setHudValue:(NSString *)value forKey:(NSString *)key;
- (void)setShouldLockWhileBeingMovedToWindow:(BOOL)shouldLockWhiteBeingMovedToWindow __attribute__((deprecated("unused")));
@property(nonatomic,strong) NSLock *appActivityLock;
@property(nonatomic) CGFloat fps;
......
......@@ -52,6 +52,8 @@
int _tryLockErrorCount;
BOOL _didSetupGL;
BOOL _didStopGL;
BOOL _didLockedDueToMovedToWindow;
BOOL _shouldLockWhileBeingMovedToWindow;
NSMutableArray *_registeredNotifications;
IJKSDLHudViewController *_hudViewController;
......@@ -67,7 +69,7 @@
self = [super initWithFrame:frame];
if (self) {
_tryLockErrorCount = 0;
_shouldLockWhileBeingMovedToWindow = YES;
self.glActiveLock = [[NSRecursiveLock alloc] init];
_registeredNotifications = [[NSMutableArray alloc] init];
[self registerApplicationObservers];
......@@ -82,6 +84,28 @@
return self;
}
- (void)willMoveToWindow:(UIWindow *)newWindow
{
if (!_shouldLockWhileBeingMovedToWindow) {
[super willMoveToWindow:newWindow];
return;
}
if (newWindow && !_didLockedDueToMovedToWindow) {
[self lockGLActive];
_didLockedDueToMovedToWindow = YES;
}
[super willMoveToWindow:newWindow];
}
- (void)didMoveToWindow
{
[super didMoveToWindow];
if (self.window && _didLockedDueToMovedToWindow) {
[self unlockGLActive];
_didLockedDueToMovedToWindow = NO;
}
}
- (BOOL)setupEAGLContext:(EAGLContext *)context
{
glGenFramebuffers(1, &_framebuffer);
......@@ -601,6 +625,11 @@
}
}
- (void)setShouldLockWhileBeingMovedToWindow:(BOOL)shouldLockWhileBeingMovedToWindow
{
_shouldLockWhileBeingMovedToWindow = shouldLockWhileBeingMovedToWindow;
}
- (void)setShouldShowHudView:(BOOL)shouldShowHudView
{
_hudViewController.tableView.hidden = !shouldShowHudView;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册