From 24f13a0d6e1c4e626daa327b119793dcb8a876e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Sun, 7 Feb 2016 23:23:07 +0100 Subject: [PATCH] poc getPixelBuffer --- ios/GLCanvas.m | 60 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/ios/GLCanvas.m b/ios/GLCanvas.m index f2a5dd9..d6e202f 100644 --- a/ios/GLCanvas.m +++ b/ios/GLCanvas.m @@ -321,9 +321,12 @@ RCT_NOT_IMPLEMENTED(-init) } } -- (void)syncContentData +- (void)rasterizeContent { - RCT_PROFILE_BEGIN_EVENT(0, @"GLCanvas syncContentData", nil); + // TODO: we need to refactor how this stuff work... + // we should no longer do any rasterize work if all the work is to be done in syncContentTextures + + RCT_PROFILE_BEGIN_EVENT(0, @"GLCanvas rasterizeContent", nil); NSMutableArray *contentData = [[NSMutableArray alloc] init]; int nb = [_nbContentTextures intValue]; for (int i = 0; i < nb; i++) { @@ -333,9 +336,14 @@ RCT_NOT_IMPLEMENTED(-init) UIView *v = [view.subviews count] == 1 ? view.subviews[0] : view; - imgData = [GLImageData genPixelsWithView:v withPixelRatio:self.contentScaleFactor]; - } else { - imgData = nil; + + SEL selector = NSSelectorFromString(@"getPixelBuffer"); + if ([v respondsToSelector:selector]) { + // will do in syncContentTextures at draw() time + } + else { + imgData = [GLImageData genPixelsWithView:v withPixelRatio:self.contentScaleFactor]; + } } if (imgData) contentData[i] = imgData; } @@ -344,13 +352,41 @@ RCT_NOT_IMPLEMENTED(-init) RCT_PROFILE_END_EVENT(0, @"gl", nil); } - - (void)syncContentTextures { - unsigned long max = MIN([_contentData count], [_contentTextures count]); - for (int i=0; i 0) { - [self syncContentData]; + [self rasterizeContent]; } [self setNeedsDisplay]; } @@ -407,7 +443,7 @@ RCT_NOT_IMPLEMENTED(-init) BOOL needsDeferredRendering = [_nbContentTextures intValue] > 0 && !_autoRedraw; if (needsDeferredRendering && !_deferredRendering) { _deferredRendering = true; - [self performSelectorOnMainThread:@selector(syncContentData) withObject:nil waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(rasterizeContent) withObject:nil waitUntilDone:NO]; } else { _deferredRendering = false; @@ -534,7 +570,7 @@ RCT_NOT_IMPLEMENTED(-init) }; // DRAWING THE SCENE - + [self syncContentTextures]; glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); -- 2.26.2