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

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

Issue 2869143002: iOS: Add interface for injecting custom shaders (Closed)
Patch Set: Address comments. 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..0cccbface2122d3bb1c85eb872007610db778dc9 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 "RTCI420TextureCache.h"
+#import "RTCNV12TextureCache.h"
+#import "RTCDefaultShaderDelegate.h"
#import "WebRTC/RTCLogging.h"
#import "WebRTC/RTCVideoFrame.h"
@@ -97,8 +99,10 @@
// This flag should only be set and read on the main thread (e.g. by
// setNeedsDisplay)
BOOL _isDirty;
- id<RTCShader> _i420Shader;
- id<RTCShader> _nv12Shader;
+ RTCDefaultShaderDelegate *_defaultShaderDelegate;
daniela-webrtc 2017/05/11 17:31:20 I find this slightly confusing. When is the defau
magjed_webrtc 2017/05/25 14:26:45 I added a comment: |_defaultShaderDelegate| is use
+ __weak id<RTCVideoViewShaderDelegate> _shaderDelegate;
+ RTCNV12TextureCache* _nv12TextureCache;
+ RTCI420TextureCache* _i420TextureCache;
RTCVideoFrame *_lastDrawnFrame;
}
@@ -107,14 +111,28 @@
@synthesize glkView = _glkView;
- (instancetype)initWithFrame:(CGRect)frame {
+ _defaultShaderDelegate = [[RTCDefaultShaderDelegate alloc] init];
+ return [self initWithFrame:frame shaderDelegate:_defaultShaderDelegate];
+}
+
+- (instancetype)initWithCoder:(NSCoder *)aDecoder {
+ _defaultShaderDelegate = [[RTCDefaultShaderDelegate alloc] init];
+ return [self initWithCoder:aDecoder shaderDelegate:_defaultShaderDelegate];
+}
+
+- (instancetype)initWithFrame:(CGRect)frame
+ shaderDelegate:(id<RTCVideoViewShaderDelegate>)shaderDelegate {
if (self = [super initWithFrame:frame]) {
+ _shaderDelegate = shaderDelegate;
[self configure];
}
return self;
}
-- (instancetype)initWithCoder:(NSCoder *)aDecoder {
+- (instancetype)initWithCoder:(NSCoder *)aDecoder
+ shaderDelegate:(id<RTCVideoViewShaderDelegate>)shaderDelegate {
if (self = [super initWithCoder:aDecoder]) {
+ _shaderDelegate = shaderDelegate;
[self configure];
}
return self;
@@ -207,22 +225,28 @@
}
[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 videoView:self
daniela-webrtc 2017/05/11 17:31:20 What if this is nil? Shouldn't the defaultDelegate
+ didReceiveFrameWithRotation: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 videoView:self
+ didReceiveFrameWithRotation:frame.rotation
+ yPlane:_i420TextureCache.yTexture
+ uPlane:_i420TextureCache.uTexture
+ vPlane:_i420TextureCache.vTexture];
}
}
@@ -275,8 +299,9 @@
_timer.isPaused = YES;
[_glkView deleteDrawable];
[self ensureGLContext];
- _i420Shader = nil;
- _nv12Shader = nil;
+ _nv12TextureCache = nil;
+ _i420TextureCache = nil;
+ _defaultShaderDelegate = nil;
}
- (void)didBecomeActive {

Powered by Google App Engine
This is Rietveld 408576698