Chromium Code Reviews| Index: webrtc/api/objc/RTCEAGLVideoView.m |
| diff --git a/talk/app/webrtc/objc/RTCEAGLVideoView.m b/webrtc/api/objc/RTCEAGLVideoView.m |
| similarity index 72% |
| copy from talk/app/webrtc/objc/RTCEAGLVideoView.m |
| copy to webrtc/api/objc/RTCEAGLVideoView.m |
| index d19462c9d97576b841df86cd6f1872fc738de2ba..5d0ab2d226e65d9e75c4af7f0e573d26866899ce 100644 |
| --- a/talk/app/webrtc/objc/RTCEAGLVideoView.m |
| +++ b/webrtc/api/objc/RTCEAGLVideoView.m |
| @@ -1,34 +1,13 @@ |
| /* |
| - * libjingle |
| - * Copyright 2014 Google Inc. |
| + * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| * |
| - * Redistribution and use in source and binary forms, with or without |
| - * modification, are permitted provided that the following conditions are met: |
| - * |
| - * 1. Redistributions of source code must retain the above copyright notice, |
| - * this list of conditions and the following disclaimer. |
| - * 2. Redistributions in binary form must reproduce the above copyright notice, |
| - * this list of conditions and the following disclaimer in the documentation |
| - * and/or other materials provided with the distribution. |
| - * 3. The name of the author may not be used to endorse or promote products |
| - * derived from this software without specific prior written permission. |
| - * |
| - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| */ |
| -#if !defined(__has_feature) || !__has_feature(objc_arc) |
| -#error "This file requires ARC support." |
| -#endif |
| - |
| #import "RTCEAGLVideoView.h" |
| #import <GLKit/GLKit.h> |
| @@ -50,7 +29,7 @@ |
| @end |
| @implementation RTCDisplayLinkTimer { |
| - CADisplayLink* _displayLink; |
| + CADisplayLink *_displayLink; |
| void (^_timerHandler)(void); |
| } |
| @@ -86,7 +65,7 @@ |
| [_displayLink invalidate]; |
| } |
| -- (void)displayLinkDidFire:(CADisplayLink*)displayLink { |
| +- (void)displayLinkDidFire:(CADisplayLink *)displayLink { |
| _timerHandler(); |
| } |
| @@ -107,20 +86,23 @@ |
| @interface RTCEAGLVideoView () <GLKViewDelegate> |
| // |i420Frame| is set when we receive a frame from a worker thread and is read |
| // from the display link callback so atomicity is required. |
| -@property(atomic, strong) RTCI420Frame* i420Frame; |
| -@property(nonatomic, readonly) GLKView* glkView; |
| -@property(nonatomic, readonly) RTCOpenGLVideoRenderer* glRenderer; |
| +@property(atomic, strong) RTCI420Frame *i420Frame; |
| +@property(nonatomic, readonly) GLKView *glkView; |
| +@property(nonatomic, readonly) RTCOpenGLVideoRenderer *glRenderer; |
| @end |
| @implementation RTCEAGLVideoView { |
| - RTCDisplayLinkTimer* _timer; |
| - GLKView* _glkView; |
| - RTCOpenGLVideoRenderer* _glRenderer; |
| + RTCDisplayLinkTimer *_timer; |
| // This flag should only be set and read on the main thread (e.g. by |
| // setNeedsDisplay) |
| BOOL _isDirty; |
| } |
| +@synthesize delegate = _delegate; |
| +@synthesize i420Frame = _i420Frame; |
| +@synthesize glkView = _glkView; |
| +@synthesize glRenderer = _glRenderer; |
| + |
| - (instancetype)initWithFrame:(CGRect)frame { |
| if (self = [super initWithFrame:frame]) { |
| [self configure]; |
| @@ -136,7 +118,7 @@ |
| } |
| - (void)configure { |
| - EAGLContext* glContext = |
| + EAGLContext *glContext = |
| [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; |
| if (!glContext) { |
| glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; |
| @@ -157,7 +139,7 @@ |
| // Listen to application state in order to clean up OpenGL before app goes |
| // away. |
| - NSNotificationCenter* notificationCenter = |
| + NSNotificationCenter *notificationCenter = |
| [NSNotificationCenter defaultCenter]; |
| [notificationCenter addObserver:self |
| selector:@selector(willResignActive) |
| @@ -171,9 +153,9 @@ |
| // Frames are received on a separate thread, so we poll for current frame |
| // using a refresh rate proportional to screen refresh frequency. This |
| // occurs on the main thread. |
| - __weak RTCEAGLVideoView* weakSelf = self; |
| + __weak RTCEAGLVideoView *weakSelf = self; |
| _timer = [[RTCDisplayLinkTimer alloc] initWithTimerHandler:^{ |
| - RTCEAGLVideoView* strongSelf = weakSelf; |
| + RTCEAGLVideoView *strongSelf = weakSelf; |
| [strongSelf displayLinkTimerDidFire]; |
| }]; |
| [self setupGL]; |
| @@ -210,25 +192,25 @@ |
| // This method is called when the GLKView's content is dirty and needs to be |
| // redrawn. This occurs on main thread. |
| -- (void)glkView:(GLKView*)view drawInRect:(CGRect)rect { |
| +- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { |
| // The renderer will draw the frame to the framebuffer corresponding to the |
| // one used by |view|. |
| - [_glRenderer drawFrame:self.i420Frame]; |
| + [_glRenderer drawFrame:_i420Frame]; |
|
tkchin_webrtc
2016/01/05 17:19:08
ditto self.i420Frame
hjon
2016/01/06 00:07:17
Done.
|
| } |
| #pragma mark - RTCVideoRenderer |
| // These methods may be called on non-main thread. |
| - (void)setSize:(CGSize)size { |
| - __weak RTCEAGLVideoView* weakSelf = self; |
| + __weak RTCEAGLVideoView *weakSelf = self; |
| dispatch_async(dispatch_get_main_queue(), ^{ |
| - RTCEAGLVideoView* strongSelf = weakSelf; |
| + RTCEAGLVideoView *strongSelf = weakSelf; |
| [strongSelf.delegate videoView:strongSelf didChangeVideoSize:size]; |
| }); |
| } |
| -- (void)renderFrame:(RTCI420Frame*)frame { |
| - self.i420Frame = frame; |
| +- (void)renderFrame:(RTCI420Frame *)frame { |
| + _i420Frame = frame; |
|
tkchin_webrtc
2016/01/05 17:19:08
revert this please. self. is needed here for atomi
hjon
2016/01/06 00:07:17
Done.
|
| } |
| #pragma mark - Private |
| @@ -236,7 +218,7 @@ |
| - (void)displayLinkTimerDidFire { |
| // Don't render unless video frame have changed or the view content |
| // has explicitly been marked dirty. |
| - if (!_isDirty && _glRenderer.lastDrawnFrame == self.i420Frame) { |
| + if (!_isDirty && _glRenderer.lastDrawnFrame == _i420Frame) { |
| return; |
| } |
| @@ -254,13 +236,13 @@ |
| } |
| - (void)setupGL { |
| - self.i420Frame = nil; |
| + _i420Frame = nil; |
| [_glRenderer setupGL]; |
| _timer.isPaused = NO; |
| } |
| - (void)teardownGL { |
| - self.i420Frame = nil; |
| + _i420Frame = nil; |
| _timer.isPaused = YES; |
| [_glkView deleteDrawable]; |
| [_glRenderer teardownGL]; |