From 107e6aafaa16ed6e1582774ed59814343adeaa3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Mon, 28 Dec 2015 22:22:29 +0100 Subject: [PATCH] Improve perfs of autoRedraw --- ios/GLCanvas.m | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ios/GLCanvas.m b/ios/GLCanvas.m index 764b2f4..24141ae 100644 --- a/ios/GLCanvas.m +++ b/ios/GLCanvas.m @@ -111,11 +111,13 @@ RCT_NOT_IMPLEMENTED(-init) - (void)setAutoRedraw:(BOOL)autoRedraw { + _autoRedraw = autoRedraw; if (autoRedraw) { if (!animationTimer) + animationTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self - selector:@selector(setNeedsDisplay) + selector:@selector(autoRedrawUpdate) userInfo:nil repeats:YES]; } @@ -332,10 +334,21 @@ RCT_NOT_IMPLEMENTED(-init) //// Draw +- (void) autoRedrawUpdate +{ + if ([self haveRemainingToPreload]) { + return; + } + if ([_nbContentTextures intValue] > 0) { + [self syncContentData]; + } + [self setNeedsDisplay]; +} + - (void)drawRect:(CGRect)rect { self.layer.opaque = _opaque; - + if (_neverRendered) { _neverRendered = false; glClearColor(0.0, 0.0, 0.0, 0.0); @@ -352,7 +365,7 @@ RCT_NOT_IMPLEMENTED(-init) bool willRender = !_deferredRendering; - if ([_nbContentTextures intValue] > 0) { + if ([_nbContentTextures intValue] > 0 && !_autoRedraw) { _deferredRendering = true; [self performSelectorOnMainThread:@selector(syncContentData) withObject:nil waitUntilDone:NO]; } -- 2.26.2