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

Unified Diff: webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m

Issue 2869143002: iOS: Add interface for injecting custom shaders (Closed)
Patch Set: Simplify previous delegate protocol Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m b/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m
index 1fb03bc909e27305eee7eb41bd9f6066983f7e3e..8d070fab9bfe09073c5e587fb2c2913d3a6f3eb4 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m
+++ b/webrtc/sdk/objc/Framework/Classes/RTCEAGLVideoView.m
@@ -12,7 +12,9 @@
#import <GLKit/GLKit.h>
-#import "RTCShader+Private.h"
+#import "RTCDefaultShader.h"
+#import "RTCI420TextureCache.h"
+#import "RTCNV12TextureCache.h"
#import "WebRTC/RTCLogging.h"
#import "WebRTC/RTCVideoFrame.h"
@@ -97,8 +99,9 @@
// This flag should only be set and read on the main thread (e.g. by
// setNeedsDisplay)
BOOL _isDirty;
- id<RTCShader> _i420Shader;
- id<RTCShader> _nv12Shader;
+ id<RTCVideoViewShader> _shaderDelegate;
+ RTCNV12TextureCache *_nv12TextureCache;
+ RTCI420TextureCache *_i420TextureCache;
RTCVideoFrame *_lastDrawnFrame;
}
@@ -107,14 +110,25 @@
@synthesize glkView = _glkView;
- (instancetype)initWithFrame:(CGRect)frame {
+ return [self initWithFrame:frame shaderDelegate:[[RTCDefaultShader alloc] init]];
+}
+
+- (instancetype)initWithCoder:(NSCoder *)aDecoder {
+ return [self initWithCoder:aDecoder shaderDelegate:[[RTCDefaultShader alloc] init]];
+}
+
+- (instancetype)initWithFrame:(CGRect)frame shaderDelegate:(id<RTCVideoViewShader>)shaderDelegate {
daniela-webrtc 2017/05/26 13:48:28 The Delegate pre/suffix is not relevant any more.
magjed_webrtc 2017/05/28 10:26:07 Done.
if (self = [super initWithFrame:frame]) {
+ _shaderDelegate = shaderDelegate;
[self configure];
}
return self;
}
-- (instancetype)initWithCoder:(NSCoder *)aDecoder {
+- (instancetype)initWithCoder:(NSCoder *)aDecoder
+ shaderDelegate:(id<RTCVideoViewShader>)shaderDelegate {
if (self = [super initWithCoder:aDecoder]) {
+ _shaderDelegate = shaderDelegate;
[self configure];
}
return self;
@@ -207,22 +221,26 @@
}
[self ensureGLContext];
glClear(GL_COLOR_BUFFER_BIT);
- id<RTCShader> shader = nil;
if (frame.nativeHandle) {
- if (!_nv12Shader) {
- _nv12Shader = [[RTCNativeNV12Shader alloc] initWithContext:_glContext];
+ if (!_nv12TextureCache) {
+ _nv12TextureCache = [[RTCNV12TextureCache alloc] initWithContext:_glContext];
}
- shader = _nv12Shader;
- } else {
- if (!_i420Shader) {
- _i420Shader = [[RTCI420Shader alloc] initWithContext:_glContext];
+ if (_nv12TextureCache) {
+ [_nv12TextureCache uploadFrameToTextures:frame];
+ [_shaderDelegate applyShadingForFrameWithRotation:frame.rotation
+ yPlane:_nv12TextureCache.yTexture
+ uvPlane:_nv12TextureCache.uvTexture];
+ [_nv12TextureCache releaseTextures];
}
- shader = _i420Shader;
- }
- if (shader && [shader drawFrame:frame]) {
- _lastDrawnFrame = frame;
} else {
- RTCLog(@"Failed to draw frame.");
+ if (!_i420TextureCache) {
+ _i420TextureCache = [[RTCI420TextureCache alloc] initWithContext:_glContext];
+ }
+ [_i420TextureCache uploadFrameToTextures:frame];
+ [_shaderDelegate applyShadingForFrameWithRotation:frame.rotation
+ yPlane:_i420TextureCache.yTexture
+ uPlane:_i420TextureCache.uTexture
+ vPlane:_i420TextureCache.vTexture];
}
}
@@ -275,8 +293,8 @@
_timer.isPaused = YES;
[_glkView deleteDrawable];
[self ensureGLContext];
- _i420Shader = nil;
- _nv12Shader = nil;
+ _nv12TextureCache = nil;
+ _i420TextureCache = nil;
}
- (void)didBecomeActive {

Powered by Google App Engine
This is Rietveld 408576698