Revert of Add unit tests for RTCMTLVideoView. (patchset #6 id:100001 of https://codereview.webrtc.org/2723903003/ )
Reason for revert:
This CL depends on a reverted CL.
Original issue's description:
> Add unit tests for RTCMTLVideoView.
>
> To properly test the functionality, following changes were needed
> - Make RTCMTLVideoView compiliable for all cpu architectures not just arm64.
> This is needed so that the test can run on any device and on simulator as well.
> - Refactor RTCMTLVideoView to have mockable class methods.
> The unittest class, RTCMTLVideoViewTests was designed to provide easy transition
> to XCTest when the time comes for that.
> To transition to XCTest it would suffice to inherit from XCTestCase and remove
> the gtest methods.
>
> BUG=webrtc:7079
>
> Review-Url: https://codereview.webrtc.org/2723903003
> Cr-Commit-Position: refs/heads/master@{#17014}
> Committed: 0ebe0199ac
TBR=magjed@webrtc.org,denicija@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7079
Review-Url: https://codereview.webrtc.org/2733953006
Cr-Commit-Position: refs/heads/master@{#17118}
This commit is contained in:
@ -24,15 +24,6 @@
|
||||
* @param frame The frame to be rendered.
|
||||
*/
|
||||
- (void)drawFrame:(RTCVideoFrame *)frame;
|
||||
|
||||
/**
|
||||
* Sets the provided view as rendering destination if possible.
|
||||
*
|
||||
* If not possible method returns NO and callers of the method are responisble for performing
|
||||
* cleanups.
|
||||
*/
|
||||
- (BOOL)addRenderingDestination:(__kindof UIView *)view;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
@ -40,4 +31,11 @@
|
||||
*/
|
||||
@interface RTCMTLNV12Renderer : NSObject <RTCMTLRenderer>
|
||||
|
||||
/**
|
||||
* Sets the provided view as rendering destination if possible.
|
||||
*
|
||||
* If not possible method returns NO and callers of the method are responisble for performing
|
||||
* cleanups.
|
||||
*/
|
||||
- (BOOL)addRenderingDestination:(__kindof MTKView *)view;
|
||||
@end
|
||||
|
||||
@ -18,18 +18,15 @@
|
||||
|
||||
#import "RTCMTLNV12Renderer.h"
|
||||
|
||||
// To avoid unreconized symbol linker errors, we're taking advantage of the objc runtime.
|
||||
// Linking errors occur when compiling for architectures that don't support Metal.
|
||||
#define MTKViewClass NSClassFromString(@"MTKView")
|
||||
#define RTCMTLNV12RendererClass NSClassFromString(@"RTCMTLNV12Renderer")
|
||||
|
||||
@interface RTCMTLVideoView () <MTKViewDelegate>
|
||||
@property(nonatomic, strong) RTCMTLNV12Renderer *renderer;
|
||||
@property(nonatomic, strong) id<RTCMTLRenderer> renderer;
|
||||
@property(nonatomic, strong) MTKView *metalView;
|
||||
@property(atomic, strong) RTCVideoFrame *videoFrame;
|
||||
@end
|
||||
|
||||
@implementation RTCMTLVideoView
|
||||
@implementation RTCMTLVideoView {
|
||||
id<RTCMTLRenderer> _renderer;
|
||||
}
|
||||
|
||||
@synthesize renderer = _renderer;
|
||||
@synthesize metalView = _metalView;
|
||||
@ -61,41 +58,11 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (MTKView *)createMetalView:(CGRect)frame {
|
||||
MTKView *view = [[MTKViewClass alloc] initWithFrame:frame];
|
||||
return view;
|
||||
}
|
||||
|
||||
+ (RTCMTLNV12Renderer *)createMetalRenderer {
|
||||
RTCMTLNV12Renderer *renderer = [[RTCMTLNV12RendererClass alloc] init];
|
||||
return renderer;
|
||||
}
|
||||
|
||||
- (void)configure {
|
||||
if (![RTCMTLVideoView isMetalAvailable]) {
|
||||
RTCLog("Metal unavailable");
|
||||
return;
|
||||
}
|
||||
|
||||
_metalView = [RTCMTLVideoView createMetalView:self.bounds];
|
||||
_renderer = [RTCMTLVideoView createMetalRenderer];
|
||||
|
||||
if ([self configureMetalRenderer]) {
|
||||
[self configureMetalView];
|
||||
} else {
|
||||
_renderer = nil;
|
||||
RTCLogError("Metal configuration falied.");
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)configureMetalRenderer {
|
||||
return [_renderer addRenderingDestination:_metalView];
|
||||
}
|
||||
|
||||
- (void)configureMetalView {
|
||||
if (_metalView) {
|
||||
_metalView.delegate = self;
|
||||
if ([RTCMTLVideoView isMetalAvailable]) {
|
||||
_metalView = [[MTKView alloc] initWithFrame:self.bounds];
|
||||
[self addSubview:_metalView];
|
||||
_metalView.delegate = self;
|
||||
_metalView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
_metalView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
UILayoutGuide *margins = self.layoutMarginsGuide;
|
||||
@ -103,14 +70,20 @@
|
||||
[_metalView.bottomAnchor constraintEqualToAnchor:margins.bottomAnchor].active = YES;
|
||||
[_metalView.leftAnchor constraintEqualToAnchor:margins.leftAnchor].active = YES;
|
||||
[_metalView.rightAnchor constraintEqualToAnchor:margins.rightAnchor].active = YES;
|
||||
|
||||
_renderer = [[RTCMTLNV12Renderer alloc] init];
|
||||
if (![(RTCMTLNV12Renderer *)_renderer addRenderingDestination:_metalView]) {
|
||||
_renderer = nil;
|
||||
};
|
||||
} else {
|
||||
RTCLogError("Metal configuration falied.");
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - MTKViewDelegate methods
|
||||
|
||||
- (void)drawInMTKView:(nonnull MTKView *)view {
|
||||
NSAssert(view == self.metalView, @"Receiving draw callbacks from foreign instance.");
|
||||
[self.renderer drawFrame:self.videoFrame];
|
||||
[_renderer drawFrame:self.videoFrame];
|
||||
}
|
||||
|
||||
- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size {
|
||||
@ -119,8 +92,8 @@
|
||||
#pragma mark - RTCVideoRenderer
|
||||
|
||||
- (void)setSize:(CGSize)size {
|
||||
self.metalView.drawableSize = size;
|
||||
[self.metalView draw];
|
||||
_metalView.drawableSize = size;
|
||||
[_metalView draw];
|
||||
}
|
||||
|
||||
- (void)renderFrame:(nullable RTCVideoFrame *)frame {
|
||||
|
||||
Reference in New Issue
Block a user