OLD | NEW |
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 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 self = [super initWithCoder:aCoder]; | 43 self = [super initWithCoder:aCoder]; |
44 if (self) { | 44 if (self) { |
45 [self configure]; | 45 [self configure]; |
46 } | 46 } |
47 return self; | 47 return self; |
48 } | 48 } |
49 | 49 |
50 #pragma mark - Private | 50 #pragma mark - Private |
51 | 51 |
52 + (BOOL)isMetalAvailable { | 52 + (BOOL)isMetalAvailable { |
53 return YES; | 53 return [MTLCopyAllDevices() count] > 0; |
54 } | 54 } |
55 | 55 |
56 - (void)configure { | 56 - (void)configure { |
57 if ([[self class] isMetalAvailable]) { | 57 if ([[self class] isMetalAvailable]) { |
58 _metalView = [[MTKView alloc] initWithFrame:self.bounds]; | 58 _metalView = [[MTKView alloc] initWithFrame:self.bounds]; |
59 [self addSubview:_metalView]; | 59 [self addSubview:_metalView]; |
60 _metalView.layerContentsPlacement = NSViewLayerContentsPlacementScaleProport
ionallyToFit; | 60 _metalView.layerContentsPlacement = NSViewLayerContentsPlacementScaleProport
ionallyToFit; |
61 _metalView.translatesAutoresizingMaskIntoConstraints = NO; | 61 _metalView.translatesAutoresizingMaskIntoConstraints = NO; |
62 _metalView.framebufferOnly = YES; | 62 _metalView.framebufferOnly = YES; |
63 _metalView.delegate = self; | 63 _metalView.delegate = self; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 - (void)renderFrame:(nullable RTCVideoFrame *)frame { | 111 - (void)renderFrame:(nullable RTCVideoFrame *)frame { |
112 if (frame == nil) { | 112 if (frame == nil) { |
113 return; | 113 return; |
114 } | 114 } |
115 self.videoFrame = [frame newI420VideoFrame]; | 115 self.videoFrame = [frame newI420VideoFrame]; |
116 } | 116 } |
117 | 117 |
118 @end | 118 @end |
OLD | NEW |