Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
Only remove/add targets to new filter group if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-smule committed Aug 2, 2017
1 parent fd31a9c commit 856d7a8
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Source/PBJVision.m
Original file line number Diff line number Diff line change
Expand Up @@ -2795,21 +2795,24 @@ - (void)_renderSampleBuffer:(CMSampleBufferRef)sampleBuffer
// Update current filter group if needed
if ((int)self.currentFilterType != _lastFilterType || self.airbrushFilterType != _lastAirbrushFilterType)
{
[_movieDataInput removeTarget:_currentFilterGroup];
[_currentFilterGroup removeAllTargets];
GPUImageOutput<GPUImageInput> *newFilterGroup = [_filterManager filterWithType:self.currentFilterType airbrushFilterType:self.airbrushFilterType];

_currentFilterGroup = [_filterManager filterWithType:self.currentFilterType airbrushFilterType:self.airbrushFilterType];

[_movieDataInput addTarget:_currentFilterGroup];
[_currentFilterGroup addTarget:_filteredPreviewView];
// Check if the filter needs to be changed
if (![[_movieDataInput targets] containsObject:newFilterGroup])
{
[_movieDataInput removeTarget:_currentFilterGroup];
[_currentFilterGroup removeAllTargets];

_currentFilterGroup = newFilterGroup;

[_movieDataInput addTarget:_currentFilterGroup];
[_currentFilterGroup addTarget:_filteredPreviewView];
}

_lastFilterType = self.currentFilterType;
_lastAirbrushFilterType = self.airbrushFilterType;



}


[_currentFilterGroup setInputRotation:rotation atIndex:0];
}
else
Expand Down

0 comments on commit 856d7a8

Please sign in to comment.