@@ -129,13 +129,25 @@ - (void)setMultipleTouchEnabled:(BOOL)multipleTouchEnabled {
129129}
130130#endif
131131
132+ - (CGFloat)currentScaleFactor {
133+ CGFloat scale = 1.0 ;
134+ #if TARGET_OS_IPHONE
135+ scale = [UIScreen mainScreen ].scale ;
136+ #elif TARGET_OS_OSX
137+ scale = [NSScreen mainScreen ].backingScaleFactor ;
138+ #endif
139+ return MAX (scale, 1.0 );
140+ }
141+
132142- (void )performLayout {
133143 CGRect bounds = self.bounds ;
134144 self.metalView .frame = bounds;
135145 if (!CGSizeEqualToSize (self.videoFrameSize , CGSizeZero)) {
136146 self.metalView .drawableSize = [self drawableSize ];
137147 } else {
138- self.metalView .drawableSize = bounds.size ;
148+ // Apply scale factor for default size as well (when videoFrameSize is zero)
149+ CGFloat scale = [self currentScaleFactor ];
150+ self.metalView .drawableSize = CGSizeMake (bounds.size .width * scale, bounds.size .height * scale);
139151 }
140152}
141153
@@ -233,11 +245,16 @@ - (CGSize)drawableSize {
233245 BOOL sizeIsLandscape = (self.videoFrame .rotation == RTCVideoRotation_0) ||
234246 (self.videoFrame .rotation == RTCVideoRotation_180);
235247
248+ CGSize size;
236249 if (useLandscape == sizeIsLandscape) {
237- return videoFrameSize;
250+ size = videoFrameSize;
238251 } else {
239- return CGSizeMake (videoFrameSize.height , videoFrameSize.width );
252+ size = CGSizeMake (videoFrameSize.height , videoFrameSize.width );
240253 }
254+
255+ // Apply scale factor for retina displays
256+ CGFloat scale = [self currentScaleFactor ];
257+ return CGSizeMake (size.width * scale, size.height * scale);
241258}
242259
243260#pragma mark - RTC_OBJC_TYPE(RTCVideoRenderer)
0 commit comments