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

Side by Side Diff: webrtc/api/objc/RTCOpenGLVideoRenderer.mm

Issue 1824573002: Fix some warnings in ObjC code. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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 | « webrtc/api/objc/RTCIceCandidate.mm ('k') | 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 static const GLsizei kNumTextureSets = 2; 141 static const GLsizei kNumTextureSets = 2;
142 static const GLsizei kNumTextures = 3 * kNumTextureSets; 142 static const GLsizei kNumTextures = 3 * kNumTextureSets;
143 143
144 @implementation RTCOpenGLVideoRenderer { 144 @implementation RTCOpenGLVideoRenderer {
145 #if TARGET_OS_IPHONE 145 #if TARGET_OS_IPHONE
146 EAGLContext *_context; 146 EAGLContext *_context;
147 #else 147 #else
148 NSOpenGLContext *_context; 148 NSOpenGLContext *_context;
149 #endif 149 #endif
150 BOOL _isInitialized; 150 BOOL _isInitialized;
151 NSUInteger _currentTextureSet; 151 GLint _currentTextureSet;
152 // Handles for OpenGL constructs. 152 // Handles for OpenGL constructs.
153 GLuint _textures[kNumTextures]; 153 GLuint _textures[kNumTextures];
154 GLuint _program; 154 GLuint _program;
155 #if !TARGET_OS_IPHONE 155 #if !TARGET_OS_IPHONE
156 GLuint _vertexArray; 156 GLuint _vertexArray;
157 #endif 157 #endif
158 GLuint _vertexBuffer; 158 GLuint _vertexBuffer;
159 GLint _position; 159 GLint _position;
160 GLint _texcoord; 160 GLint _texcoord;
161 GLint _ySampler; 161 GLint _ySampler;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 return YES; 306 return YES;
307 } 307 }
308 308
309 - (BOOL)updateTextureSizesForFrame:(RTCVideoFrame *)frame { 309 - (BOOL)updateTextureSizesForFrame:(RTCVideoFrame *)frame {
310 if (frame.height == _lastDrawnFrame.height && 310 if (frame.height == _lastDrawnFrame.height &&
311 frame.width == _lastDrawnFrame.width && 311 frame.width == _lastDrawnFrame.width &&
312 frame.chromaWidth == _lastDrawnFrame.chromaWidth && 312 frame.chromaWidth == _lastDrawnFrame.chromaWidth &&
313 frame.chromaHeight == _lastDrawnFrame.chromaHeight) { 313 frame.chromaHeight == _lastDrawnFrame.chromaHeight) {
314 return YES; 314 return YES;
315 } 315 }
316 GLsizei lumaWidth = frame.width; 316 GLsizei lumaWidth = static_cast<GLsizei>(frame.width);
317 GLsizei lumaHeight = frame.height; 317 GLsizei lumaHeight = static_cast<GLsizei>(frame.height);
318 GLsizei chromaWidth = frame.chromaWidth; 318 GLsizei chromaWidth = static_cast<GLsizei>(frame.chromaWidth);
319 GLsizei chromaHeight = frame.chromaHeight; 319 GLsizei chromaHeight = static_cast<GLsizei>(frame.chromaHeight);
320 for (GLint i = 0; i < kNumTextureSets; i++) { 320 for (GLint i = 0; i < kNumTextureSets; i++) {
321 glActiveTexture(GL_TEXTURE0 + i * 3); 321 glActiveTexture(GL_TEXTURE0 + i * 3);
322 glTexImage2D(GL_TEXTURE_2D, 322 glTexImage2D(GL_TEXTURE_2D,
323 0, 323 0,
324 RTC_PIXEL_FORMAT, 324 RTC_PIXEL_FORMAT,
325 lumaWidth, 325 lumaWidth,
326 lumaHeight, 326 lumaHeight,
327 0, 327 0,
328 RTC_PIXEL_FORMAT, 328 RTC_PIXEL_FORMAT,
329 GL_UNSIGNED_BYTE, 329 GL_UNSIGNED_BYTE,
(...skipping 24 matching lines...) Expand all
354 (NSUInteger)frame.vPitch != frame.chromaWidth) { 354 (NSUInteger)frame.vPitch != frame.chromaWidth) {
355 _planeBuffer.reset(new uint8_t[frame.width * frame.height]); 355 _planeBuffer.reset(new uint8_t[frame.width * frame.height]);
356 } else { 356 } else {
357 _planeBuffer.reset(); 357 _planeBuffer.reset();
358 } 358 }
359 return YES; 359 return YES;
360 } 360 }
361 361
362 - (void)uploadPlane:(const uint8_t *)plane 362 - (void)uploadPlane:(const uint8_t *)plane
363 sampler:(GLint)sampler 363 sampler:(GLint)sampler
364 offset:(NSUInteger)offset 364 offset:(GLint)offset
365 width:(size_t)width 365 width:(size_t)width
366 height:(size_t)height 366 height:(size_t)height
367 stride:(int32_t)stride { 367 stride:(int32_t)stride {
368 glActiveTexture(GL_TEXTURE0 + offset); 368 glActiveTexture(static_cast<GLenum>(GL_TEXTURE0 + offset));
369 // When setting texture sampler uniforms, the texture index is used not 369 // When setting texture sampler uniforms, the texture index is used not
370 // the texture handle. 370 // the texture handle.
371 glUniform1i(sampler, offset); 371 glUniform1i(sampler, offset);
372 #if TARGET_OS_IPHONE 372 #if TARGET_OS_IPHONE
373 BOOL hasUnpackRowLength = _context.API == kEAGLRenderingAPIOpenGLES3; 373 BOOL hasUnpackRowLength = _context.API == kEAGLRenderingAPIOpenGLES3;
374 #else 374 #else
375 BOOL hasUnpackRowLength = YES; 375 BOOL hasUnpackRowLength = YES;
376 #endif 376 #endif
377 const uint8_t *uploadPlane = plane; 377 const uint8_t *uploadPlane = plane;
378 if ((size_t)stride != width) { 378 if ((size_t)stride != width) {
379 if (hasUnpackRowLength) { 379 if (hasUnpackRowLength) {
380 // GLES3 allows us to specify stride. 380 // GLES3 allows us to specify stride.
381 glPixelStorei(GL_UNPACK_ROW_LENGTH, stride); 381 glPixelStorei(GL_UNPACK_ROW_LENGTH, stride);
382 glTexImage2D(GL_TEXTURE_2D, 382 glTexImage2D(GL_TEXTURE_2D,
383 0, 383 0,
384 RTC_PIXEL_FORMAT, 384 RTC_PIXEL_FORMAT,
385 width, 385 static_cast<GLsizei>(width),
386 height, 386 static_cast<GLsizei>(height),
387 0, 387 0,
388 RTC_PIXEL_FORMAT, 388 RTC_PIXEL_FORMAT,
389 GL_UNSIGNED_BYTE, 389 GL_UNSIGNED_BYTE,
390 uploadPlane); 390 uploadPlane);
391 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 391 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
392 return; 392 return;
393 } else { 393 } else {
394 // Make an unpadded copy and upload that instead. Quick profiling showed 394 // Make an unpadded copy and upload that instead. Quick profiling showed
395 // that this is faster than uploading row by row using glTexSubImage2D. 395 // that this is faster than uploading row by row using glTexSubImage2D.
396 uint8_t *unpaddedPlane = _planeBuffer.get(); 396 uint8_t *unpaddedPlane = _planeBuffer.get();
397 for (size_t y = 0; y < height; ++y) { 397 for (size_t y = 0; y < height; ++y) {
398 memcpy(unpaddedPlane + y * width, plane + y * stride, width); 398 memcpy(unpaddedPlane + y * width, plane + y * stride, width);
399 } 399 }
400 uploadPlane = unpaddedPlane; 400 uploadPlane = unpaddedPlane;
401 } 401 }
402 } 402 }
403 glTexImage2D(GL_TEXTURE_2D, 403 glTexImage2D(GL_TEXTURE_2D,
404 0, 404 0,
405 RTC_PIXEL_FORMAT, 405 RTC_PIXEL_FORMAT,
406 width, 406 static_cast<GLsizei>(width),
407 height, 407 static_cast<GLsizei>(height),
408 0, 408 0,
409 RTC_PIXEL_FORMAT, 409 RTC_PIXEL_FORMAT,
410 GL_UNSIGNED_BYTE, 410 GL_UNSIGNED_BYTE,
411 uploadPlane); 411 uploadPlane);
412 } 412 }
413 413
414 - (BOOL)updateTextureDataForFrame:(RTCVideoFrame *)frame { 414 - (BOOL)updateTextureDataForFrame:(RTCVideoFrame *)frame {
415 NSUInteger textureOffset = _currentTextureSet * 3; 415 GLint textureOffset = _currentTextureSet * 3;
416 NSAssert(textureOffset + 3 <= kNumTextures, @"invalid offset"); 416 NSAssert(textureOffset + 3 <= kNumTextures, @"invalid offset");
417 417
418 [self uploadPlane:frame.yPlane 418 [self uploadPlane:frame.yPlane
419 sampler:_ySampler 419 sampler:_ySampler
420 offset:textureOffset 420 offset:textureOffset
421 width:frame.width 421 width:frame.width
422 height:frame.height 422 height:frame.height
423 stride:frame.yPitch]; 423 stride:frame.yPitch];
424 424
425 [self uploadPlane:frame.uPlane 425 [self uploadPlane:frame.uPlane
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 GL_FLOAT, 476 GL_FLOAT,
477 GL_FALSE, 477 GL_FALSE,
478 4 * sizeof(GLfloat), 478 4 * sizeof(GLfloat),
479 (void *)(2 * sizeof(GLfloat))); 479 (void *)(2 * sizeof(GLfloat)));
480 glEnableVertexAttribArray(_texcoord); 480 glEnableVertexAttribArray(_texcoord);
481 481
482 return YES; 482 return YES;
483 } 483 }
484 484
485 @end 485 @end
OLDNEW
« no previous file with comments | « webrtc/api/objc/RTCIceCandidate.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698