@@ -232,15 +232,21 @@ - (void)presentFramebuffer;
232232
233233- (void )recalculateViewGeometry ;
234234{
235+ NSLog (@" Is main thread: %@ " , [NSThread isMainThread ] ? @" YES" : @" NO" );
236+
237+ __block CGRect currentBounds;
238+
239+ runOnMainQueueWithoutDeadlocking (^{
240+ currentBounds = self.bounds ;
241+ });
242+
235243 runSynchronouslyOnVideoProcessingQueue (^{
236244 CGFloat heightScaling, widthScaling;
237-
238- CGSize currentViewSize = self.bounds .size ;
239-
245+
240246 // CGFloat imageAspectRatio = inputImageSize.width / inputImageSize.height;
241247 // CGFloat viewAspectRatio = currentViewSize.width / currentViewSize.height;
242-
243- CGRect insetRect = AVMakeRectWithAspectRatioInsideRect (inputImageSize, self. bounds );
248+
249+ CGRect insetRect = AVMakeRectWithAspectRatioInsideRect (inputImageSize, currentBounds );
244250
245251 switch (_fillMode)
246252 {
@@ -251,14 +257,14 @@ - (void)recalculateViewGeometry;
251257 }; break ;
252258 case kGPUImageFillModePreserveAspectRatio :
253259 {
254- widthScaling = insetRect.size .width / currentViewSize .width ;
255- heightScaling = insetRect.size .height / currentViewSize .height ;
260+ widthScaling = insetRect.size .width / currentBounds. size .width ;
261+ heightScaling = insetRect.size .height / currentBounds. size .height ;
256262 }; break ;
257263 case kGPUImageFillModePreserveAspectRatioAndFill :
258264 {
259- // CGFloat widthHolder = insetRect.size.width / currentViewSize .width;
260- widthScaling = currentViewSize .height / insetRect.size .height ;
261- heightScaling = currentViewSize .width / insetRect.size .width ;
265+ // CGFloat widthHolder = insetRect.size.width / currentBounds.size .width;
266+ widthScaling = currentBounds. size .height / insetRect.size .height ;
267+ heightScaling = currentBounds. size .width / insetRect.size .width ;
262268 }; break ;
263269 }
264270
0 commit comments