ObjC: Pass in frame resolution to GL shaders

Frame resolution might be interesting for a shader implementation.

Bug: webrtc:7473
Change-Id: If19278b3babe2e5bab1a1f7562fa8b06ab840517
Reviewed-on: https://chromium-review.googlesource.com/524452
Reviewed-by: Daniela Jovanoska Petrenko <denicija@webrtc.org>
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#18466}
This commit is contained in:
Magnus Jedvert
2017-06-05 17:58:34 +02:00
committed by Commit Bot
parent f53c4cd867
commit 6b9653e63b
4 changed files with 39 additions and 25 deletions

View File

@ -226,9 +226,11 @@
} }
if (_nv12TextureCache) { if (_nv12TextureCache) {
[_nv12TextureCache uploadFrameToTextures:frame]; [_nv12TextureCache uploadFrameToTextures:frame];
[_shader applyShadingForFrameWithRotation:frame.rotation [_shader applyShadingForFrameWithWidth:frame.width
yPlane:_nv12TextureCache.yTexture height:frame.height
uvPlane:_nv12TextureCache.uvTexture]; rotation:frame.rotation
yPlane:_nv12TextureCache.yTexture
uvPlane:_nv12TextureCache.uvTexture];
[_nv12TextureCache releaseTextures]; [_nv12TextureCache releaseTextures];
} }
} else { } else {
@ -236,10 +238,12 @@
_i420TextureCache = [[RTCI420TextureCache alloc] initWithContext:_glContext]; _i420TextureCache = [[RTCI420TextureCache alloc] initWithContext:_glContext];
} }
[_i420TextureCache uploadFrameToTextures:frame]; [_i420TextureCache uploadFrameToTextures:frame];
[_shader applyShadingForFrameWithRotation:frame.rotation [_shader applyShadingForFrameWithWidth:frame.width
yPlane:_i420TextureCache.yTexture height:frame.height
uPlane:_i420TextureCache.uTexture rotation:frame.rotation
vPlane:_i420TextureCache.vTexture]; yPlane:_i420TextureCache.yTexture
uPlane:_i420TextureCache.uTexture
vPlane:_i420TextureCache.vTexture];
} }
} }

View File

@ -141,10 +141,12 @@ static CVReturn OnDisplayLinkFired(CVDisplayLinkRef displayLink,
RTCI420TextureCache *i420TextureCache = self.i420TextureCache; RTCI420TextureCache *i420TextureCache = self.i420TextureCache;
if (i420TextureCache) { if (i420TextureCache) {
[i420TextureCache uploadFrameToTextures:frame]; [i420TextureCache uploadFrameToTextures:frame];
[_shader applyShadingForFrameWithRotation:frame.rotation [_shader applyShadingForFrameWithWidth:frame.width
yPlane:i420TextureCache.yTexture height:frame.height
uPlane:i420TextureCache.uTexture rotation:frame.rotation
vPlane:i420TextureCache.vTexture]; yPlane:i420TextureCache.yTexture
uPlane:i420TextureCache.uTexture
vPlane:i420TextureCache.vTexture];
[context flushBuffer]; [context flushBuffer];
_lastDrawnFrame = frame; _lastDrawnFrame = frame;
} }

View File

@ -150,10 +150,12 @@ static const char kNV12FragmentShaderSource[] =
return YES; return YES;
} }
- (void)applyShadingForFrameWithRotation:(RTCVideoRotation)rotation - (void)applyShadingForFrameWithWidth:(int)width
yPlane:(GLuint)yPlane height:(int)height
uPlane:(GLuint)uPlane rotation:(RTCVideoRotation)rotation
vPlane:(GLuint)vPlane { yPlane:(GLuint)yPlane
uPlane:(GLuint)uPlane
vPlane:(GLuint)vPlane {
if (![self prepareVertexBufferWithRotation:rotation]) { if (![self prepareVertexBufferWithRotation:rotation]) {
return; return;
} }
@ -177,9 +179,11 @@ static const char kNV12FragmentShaderSource[] =
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
} }
- (void)applyShadingForFrameWithRotation:(RTCVideoRotation)rotation - (void)applyShadingForFrameWithWidth:(int)width
yPlane:(GLuint)yPlane height:(int)height
uvPlane:(GLuint)uvPlane { rotation:(RTCVideoRotation)rotation
yPlane:(GLuint)yPlane
uvPlane:(GLuint)uvPlane {
if (![self prepareVertexBufferWithRotation:rotation]) { if (![self prepareVertexBufferWithRotation:rotation]) {
return; return;
} }

View File

@ -22,15 +22,19 @@ RTC_EXPORT
@protocol RTCVideoViewShading <NSObject> @protocol RTCVideoViewShading <NSObject>
/** Callback for I420 frames. Each plane is given as a texture. */ /** Callback for I420 frames. Each plane is given as a texture. */
- (void)applyShadingForFrameWithRotation:(RTCVideoRotation)rotation - (void)applyShadingForFrameWithWidth:(int)width
yPlane:(GLuint)yPlane height:(int)height
uPlane:(GLuint)uPlane rotation:(RTCVideoRotation)rotation
vPlane:(GLuint)vPlane; yPlane:(GLuint)yPlane
uPlane:(GLuint)uPlane
vPlane:(GLuint)vPlane;
/** Callback for NV12 frames. Each plane is given as a texture. */ /** Callback for NV12 frames. Each plane is given as a texture. */
- (void)applyShadingForFrameWithRotation:(RTCVideoRotation)rotation - (void)applyShadingForFrameWithWidth:(int)width
yPlane:(GLuint)yPlane height:(int)height
uvPlane:(GLuint)uvPlane; rotation:(RTCVideoRotation)rotation
yPlane:(GLuint)yPlane
uvPlane:(GLuint)uvPlane;
@end @end