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

Unified Diff: webrtc/api/objc/RTCOpenGLVideoRenderer.mm

Issue 1542473003: Move Objective-C video renderers to webrtc/api/objc. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@updateI420Frame
Patch Set: Update style and fix build Created 5 years 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
Index: webrtc/api/objc/RTCOpenGLVideoRenderer.mm
diff --git a/talk/app/webrtc/objc/RTCOpenGLVideoRenderer.mm b/webrtc/api/objc/RTCOpenGLVideoRenderer.mm
similarity index 85%
copy from talk/app/webrtc/objc/RTCOpenGLVideoRenderer.mm
copy to webrtc/api/objc/RTCOpenGLVideoRenderer.mm
index cfead91bcafd0eee7261af8750473649ef46e16d..daf83eedfd44a3965b8116840e57f6ac3e6c7a8e 100644
--- a/talk/app/webrtc/objc/RTCOpenGLVideoRenderer.mm
+++ b/webrtc/api/objc/RTCOpenGLVideoRenderer.mm
@@ -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 "RTCOpenGLVideoRenderer.h"
#include <string.h>
@@ -102,7 +81,7 @@ static const char kFragmentShaderSource[] =
// Compiles a shader of the given |type| with GLSL source |source| and returns
// the shader handle or 0 on error.
-GLuint CreateShader(GLenum type, const GLchar* source) {
+GLuint CreateShader(GLenum type, const GLchar *source) {
GLuint shader = glCreateShader(type);
if (!shader) {
return 0;
@@ -164,9 +143,9 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
@implementation RTCOpenGLVideoRenderer {
#if TARGET_OS_IPHONE
- EAGLContext* _context;
+ EAGLContext *_context;
#else
- NSOpenGLContext* _context;
+ NSOpenGLContext *_context;
#endif
BOOL _isInitialized;
NSUInteger _currentTextureSet;
@@ -187,15 +166,17 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
rtc::scoped_ptr<uint8_t[]> _planeBuffer;
}
+@synthesize lastDrawnFrame = _lastDrawnFrame;
+
+ (void)initialize {
// Disable dithering for performance.
glDisable(GL_DITHER);
}
#if TARGET_OS_IPHONE
-- (instancetype)initWithContext:(EAGLContext*)context {
+- (instancetype)initWithContext:(EAGLContext *)context {
#else
-- (instancetype)initWithContext:(NSOpenGLContext*)context {
+- (instancetype)initWithContext:(NSOpenGLContext *)context {
#endif
NSAssert(context != nil, @"context cannot be nil");
if (self = [super init]) {
@@ -204,7 +185,7 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
return self;
}
-- (BOOL)drawFrame:(RTCI420Frame*)frame {
+- (BOOL)drawFrame:(RTCI420Frame *)frame {
if (!_isInitialized) {
return NO;
}
@@ -325,7 +306,7 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
return YES;
}
-- (BOOL)updateTextureSizesForFrame:(RTCI420Frame*)frame {
+- (BOOL)updateTextureSizesForFrame:(RTCI420Frame *)frame {
if (frame.height == _lastDrawnFrame.height &&
frame.width == _lastDrawnFrame.width &&
frame.chromaWidth == _lastDrawnFrame.chromaWidth &&
@@ -368,8 +349,9 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
GL_UNSIGNED_BYTE,
0);
}
- if (frame.yPitch != frame.width || frame.uPitch != frame.chromaWidth ||
- frame.vPitch != frame.chromaWidth) {
+ if ((NSUInteger)frame.yPitch != frame.width ||
+ (NSUInteger)frame.uPitch != frame.chromaWidth ||
+ (NSUInteger)frame.vPitch != frame.chromaWidth) {
hjon 2015/12/21 20:01:44 Due to compiler warnings, I cast these to NSUInteg
tkchin_webrtc 2016/01/05 17:19:08 Should be fine.
hjon 2016/01/06 00:07:17 Due to the changes to RTCVideoFrame, I've now upda
_planeBuffer.reset(new uint8_t[frame.width * frame.height]);
} else {
_planeBuffer.reset();
@@ -377,7 +359,7 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
return YES;
}
-- (void)uploadPlane:(const uint8_t*)plane
+- (void)uploadPlane:(const uint8_t *)plane
sampler:(GLint)sampler
offset:(NSUInteger)offset
width:(NSUInteger)width
@@ -392,8 +374,8 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
#else
BOOL hasUnpackRowLength = YES;
#endif
- const uint8_t* uploadPlane = plane;
- if (stride != width) {
+ const uint8_t *uploadPlane = plane;
+ if ((NSUInteger)stride != width) {
hjon 2015/12/21 20:01:44 Due to compiler warnings, I cast this to NSUIntege
if (hasUnpackRowLength) {
// GLES3 allows us to specify stride.
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride);
@@ -411,7 +393,7 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
} else {
// Make an unpadded copy and upload that instead. Quick profiling showed
// that this is faster than uploading row by row using glTexSubImage2D.
- uint8_t* unpaddedPlane = _planeBuffer.get();
+ uint8_t *unpaddedPlane = _planeBuffer.get();
for (NSUInteger y = 0; y < height; ++y) {
memcpy(unpaddedPlane + y * width, plane + y * stride, width);
}
@@ -429,7 +411,7 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
uploadPlane);
}
-- (BOOL)updateTextureDataForFrame:(RTCI420Frame*)frame {
+- (BOOL)updateTextureDataForFrame:(RTCI420Frame *)frame {
NSUInteger textureOffset = _currentTextureSet * 3;
NSAssert(textureOffset + 3 <= kNumTextures, @"invalid offset");
@@ -483,7 +465,7 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
// beginning at the start of the array. The last argument indicates offset
// of data within |gVertices| as supplied to the vertex buffer.
glVertexAttribPointer(
- _position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (void*)0);
+ _position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (void *)0);
glEnableVertexAttribArray(_position);
// Read texcoord attribute from |gVertices| with size of 2 and stride of 4
@@ -494,7 +476,7 @@ static const GLsizei kNumTextures = 3 * kNumTextureSets;
GL_FLOAT,
GL_FALSE,
4 * sizeof(GLfloat),
- (void*)(2 * sizeof(GLfloat)));
+ (void *)(2 * sizeof(GLfloat)));
glEnableVertexAttribArray(_texcoord);
return YES;

Powered by Google App Engine
This is Rietveld 408576698