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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/Metal/RTCMTLNSVideoView.m

Issue 2784243003: iOS/MacOS:Refactor metal rendering by extracting common implementation (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 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
11 #import "WebRTC/RTCMTLNSVideoView.h" 11 #import "WebRTC/RTCMTLNSVideoView.h"
12 12
13 #import <Metal/Metal.h> 13 #import <Metal/Metal.h>
14 #import <MetalKit/MetalKit.h> 14 #import <MetalKit/MetalKit.h>
15 15
16 #import "WebRTC/RTCVideoFrame.h" 16 #import "WebRTC/RTCVideoFrame.h"
17 17
18 #import "RTCMTLI420Renderer.h" 18 #import "RTCMTLI420Renderer.h"
19 19
20 @interface RTCMTLNSVideoView () <MTKViewDelegate> 20 @interface RTCMTLNSVideoView ()<MTKViewDelegate>
21 @property(nonatomic) id<RTCMTLRenderer> renderer; 21 @property(nonatomic) id<RTCMTLRenderer> renderer;
22 @property(nonatomic, strong) MTKView *metalView; 22 @property(nonatomic, strong) MTKView *metalView;
23 @property(atomic, strong) RTCVideoFrame *videoFrame; 23 @property(atomic, strong) RTCVideoFrame *videoFrame;
24 @end 24 @end
25 25
26 @implementation RTCMTLNSVideoView { 26 @implementation RTCMTLNSVideoView {
27 id<RTCMTLRenderer> _renderer; 27 id<RTCMTLRenderer> _renderer;
28 } 28 }
29 29
30 @synthesize renderer = _renderer; 30 @synthesize renderer = _renderer;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[_metalView]-0-|" 83 [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[_metalView]-0-|"
84 options:0 84 options:0
85 metrics:nil 85 metrics:nil
86 views:views]; 86 views:views];
87 [self addConstraints:constraintsVertical]; 87 [self addConstraints:constraintsVertical];
88 [super updateConstraints]; 88 [super updateConstraints];
89 } 89 }
90 90
91 #pragma mark - MTKViewDelegate methods 91 #pragma mark - MTKViewDelegate methods
92 - (void)drawInMTKView:(nonnull MTKView *)view { 92 - (void)drawInMTKView:(nonnull MTKView *)view {
93 if (self.videoFrame == nil) {
94 return;
95 }
93 if (view == self.metalView) { 96 if (view == self.metalView) {
94 [_renderer drawFrame:self.videoFrame]; 97 [_renderer drawFrame:self.videoFrame];
95 } 98 }
96 } 99 }
97 100
98 - (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size { 101 - (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size {
99 } 102 }
100 103
101 #pragma mark - RTCVideoRenderer 104 #pragma mark - RTCVideoRenderer
102 105
103 - (void)setSize:(CGSize)size { 106 - (void)setSize:(CGSize)size {
104 _metalView.drawableSize = size; 107 _metalView.drawableSize = size;
105 [_metalView draw]; 108 [_metalView draw];
106 } 109 }
107 110
108 - (void)renderFrame:(nullable RTCVideoFrame *)frame { 111 - (void)renderFrame:(nullable RTCVideoFrame *)frame {
109 if (frame == nil) { 112 if (frame == nil) {
110 return; 113 return;
111 } 114 }
112 self.videoFrame = [frame newI420VideoFrame]; 115 self.videoFrame = [frame newI420VideoFrame];
113 } 116 }
114 117
115 @end 118 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698