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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m

Issue 2259513002: Nil out EAGLContext explicitly on RTCEAGLVideoView dealloc. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 @interface RTCEAGLVideoView () <GLKViewDelegate> 86 @interface RTCEAGLVideoView () <GLKViewDelegate>
87 // |videoFrame| is set when we receive a frame from a worker thread and is read 87 // |videoFrame| is set when we receive a frame from a worker thread and is read
88 // from the display link callback so atomicity is required. 88 // from the display link callback so atomicity is required.
89 @property(atomic, strong) RTCVideoFrame *videoFrame; 89 @property(atomic, strong) RTCVideoFrame *videoFrame;
90 @property(nonatomic, readonly) GLKView *glkView; 90 @property(nonatomic, readonly) GLKView *glkView;
91 @property(nonatomic, readonly) RTCOpenGLVideoRenderer *glRenderer; 91 @property(nonatomic, readonly) RTCOpenGLVideoRenderer *glRenderer;
92 @end 92 @end
93 93
94 @implementation RTCEAGLVideoView { 94 @implementation RTCEAGLVideoView {
95 RTCDisplayLinkTimer *_timer; 95 RTCDisplayLinkTimer *_timer;
96 EAGLContext *_glContext;
96 // This flag should only be set and read on the main thread (e.g. by 97 // This flag should only be set and read on the main thread (e.g. by
97 // setNeedsDisplay) 98 // setNeedsDisplay)
98 BOOL _isDirty; 99 BOOL _isDirty;
99 } 100 }
100 101
101 @synthesize delegate = _delegate; 102 @synthesize delegate = _delegate;
102 @synthesize videoFrame = _videoFrame; 103 @synthesize videoFrame = _videoFrame;
103 @synthesize glkView = _glkView; 104 @synthesize glkView = _glkView;
104 @synthesize glRenderer = _glRenderer; 105 @synthesize glRenderer = _glRenderer;
105 106
(...skipping 10 matching lines...) Expand all
116 } 117 }
117 return self; 118 return self;
118 } 119 }
119 120
120 - (void)configure { 121 - (void)configure {
121 EAGLContext *glContext = 122 EAGLContext *glContext =
122 [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; 123 [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
123 if (!glContext) { 124 if (!glContext) {
124 glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; 125 glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
125 } 126 }
126 _glRenderer = [[RTCOpenGLVideoRenderer alloc] initWithContext:glContext]; 127 _glContext = glContext;
128 _glRenderer = [[RTCOpenGLVideoRenderer alloc] initWithContext:_glContext];
127 129
128 // GLKView manages a framebuffer for us. 130 // GLKView manages a framebuffer for us.
129 _glkView = [[GLKView alloc] initWithFrame:CGRectZero 131 _glkView = [[GLKView alloc] initWithFrame:CGRectZero
130 context:glContext]; 132 context:_glContext];
131 _glkView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888; 133 _glkView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
132 _glkView.drawableDepthFormat = GLKViewDrawableDepthFormatNone; 134 _glkView.drawableDepthFormat = GLKViewDrawableDepthFormatNone;
133 _glkView.drawableStencilFormat = GLKViewDrawableStencilFormatNone; 135 _glkView.drawableStencilFormat = GLKViewDrawableStencilFormatNone;
134 _glkView.drawableMultisample = GLKViewDrawableMultisampleNone; 136 _glkView.drawableMultisample = GLKViewDrawableMultisampleNone;
135 _glkView.delegate = self; 137 _glkView.delegate = self;
136 _glkView.layer.masksToBounds = YES; 138 _glkView.layer.masksToBounds = YES;
137 _glkView.enableSetNeedsDisplay = NO; 139 _glkView.enableSetNeedsDisplay = NO;
138 [self addSubview:_glkView]; 140 [self addSubview:_glkView];
139 141
140 // Listen to application state in order to clean up OpenGL before app goes 142 // Listen to application state in order to clean up OpenGL before app goes
(...skipping 21 matching lines...) Expand all
162 } 164 }
163 165
164 - (void)dealloc { 166 - (void)dealloc {
165 [[NSNotificationCenter defaultCenter] removeObserver:self]; 167 [[NSNotificationCenter defaultCenter] removeObserver:self];
166 UIApplicationState appState = 168 UIApplicationState appState =
167 [UIApplication sharedApplication].applicationState; 169 [UIApplication sharedApplication].applicationState;
168 if (appState == UIApplicationStateActive) { 170 if (appState == UIApplicationStateActive) {
169 [self teardownGL]; 171 [self teardownGL];
170 } 172 }
171 [_timer invalidate]; 173 [_timer invalidate];
174 if (_glContext && [EAGLContext currentContext] == _glContext) {
175 [EAGLContext setCurrentContext:nil];
176 }
172 } 177 }
173 178
174 #pragma mark - UIView 179 #pragma mark - UIView
175 180
176 - (void)setNeedsDisplay { 181 - (void)setNeedsDisplay {
177 [super setNeedsDisplay]; 182 [super setNeedsDisplay];
178 _isDirty = YES; 183 _isDirty = YES;
179 } 184 }
180 185
181 - (void)setNeedsDisplayInRect:(CGRect)rect { 186 - (void)setNeedsDisplayInRect:(CGRect)rect {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 261
257 - (void)didBecomeActive { 262 - (void)didBecomeActive {
258 [self setupGL]; 263 [self setupGL];
259 } 264 }
260 265
261 - (void)willResignActive { 266 - (void)willResignActive {
262 [self teardownGL]; 267 [self teardownGL];
263 } 268 }
264 269
265 @end 270 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698