Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: talk/app/webrtc/objc/RTCEAGLVideoView.m

Issue 1347013002: RTCEAGLVideoView: Fix GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/objc/RTCEAGLVideoView.m
diff --git a/talk/app/webrtc/objc/RTCEAGLVideoView.m b/talk/app/webrtc/objc/RTCEAGLVideoView.m
index 61040ba1025c2f23eed07f916df93d36b2955d76..bd3ada5c8f3a4d4fafc6a164b1fdbff586020d18 100644
--- a/talk/app/webrtc/objc/RTCEAGLVideoView.m
+++ b/talk/app/webrtc/objc/RTCEAGLVideoView.m
@@ -121,24 +121,6 @@
}
- (void)configure {
- EAGLContext* glContext =
- [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
- if (!glContext) {
- glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
- }
- _glRenderer = [[RTCOpenGLVideoRenderer alloc] initWithContext:glContext];
magjed_webrtc 2015/09/17 08:59:46 Why can't _glRenderer alloc stay in this function?
-
- // GLKView manages a framebuffer for us.
- _glkView = [[GLKView alloc] initWithFrame:CGRectZero
- context:glContext];
- _glkView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
- _glkView.drawableDepthFormat = GLKViewDrawableDepthFormatNone;
- _glkView.drawableStencilFormat = GLKViewDrawableStencilFormatNone;
- _glkView.drawableMultisample = GLKViewDrawableMultisampleNone;
- _glkView.delegate = self;
- _glkView.layer.masksToBounds = YES;
- [self addSubview:_glkView];
-
// Listen to application state in order to clean up OpenGL before app goes
// away.
NSNotificationCenter* notificationCenter =
@@ -166,6 +148,39 @@
// GLKViewDelegate method implemented below.
[strongSelf.glkView setNeedsDisplay];
}];
+}
+
+- (BOOL)isGLConfigured {
+ return (_glkView != nil) && (_glRenderer != nil);
+}
+
+- (void)configureGLIfApplicable {
+ NSAssert([NSThread isMainThread], @"should only configure on main thread");
+ if ((![self isGLConfigured]) && (!CGRectIsEmpty(self.bounds))) {
+ [self configureGL];
+ NSAssert([self isGLConfigured], @"GL components should have been configured");
+ }
+}
+
+- (void)configureGL {
+ NSAssert((self.bounds.size.width > 0) && (self.bounds.size.height > 0),
+ @"Don't attempt to configure GLKView and renderer until a size is specified");
+ EAGLContext *glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
+ if (!glContext) {
+ glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
+ }
+ _glRenderer = [[RTCOpenGLVideoRenderer alloc] initWithContext:glContext];
+
+ // GLKView manages a framebuffer for us.
+ _glkView = [[GLKView alloc] initWithFrame:self.bounds context:glContext];
+ _glkView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
+ _glkView.drawableDepthFormat = GLKViewDrawableDepthFormatNone;
+ _glkView.drawableStencilFormat = GLKViewDrawableStencilFormatNone;
+ _glkView.drawableMultisample = GLKViewDrawableMultisampleNone;
+ _glkView.delegate = self;
+ _glkView.layer.masksToBounds = YES;
+ [self addSubview:_glkView];
+
[self setupGL];
}
@@ -181,6 +196,16 @@
#pragma mark - UIView
+- (void)setFrame:(CGRect)frame {
+ [super setFrame:frame];
+ [self configureGLIfApplicable];
+}
+
+- (void)setBounds:(CGRect)bounds {
+ [super setBounds:bounds];
+ [self configureGLIfApplicable];
+}
+
- (void)layoutSubviews {
[super layoutSubviews];
_glkView.frame = self.bounds;
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698