GPUImage源码解读(十九)

GPUImageFilterGroup继承自GPUImageOutput ,实现了GPUImageInput协议。因此,可以自身可以作为独立的滤镜参与响应链中。相比GPUImageFilterPipeline,GPUImageFilterGroup功能更强大。

  • 属性

//滤镜链最后一个效果
@property(readwrite, nonatomic, strong) GPUImageOutput<GPUImageInput> *terminalFilter;
//滤镜链头效果 可以是多少
@property(readwrite, nonatomic, strong) NSArray *initialFilters;
//当前忽略处理的Target
@property(readwrite, nonatomic, strong) GPUImageOutput<GPUImageInput> *inputFilterToIgnoreForUpdates;
  • 方法

// Filter management
// 增加滤镜
- (void)addFilter:(GPUImageOutput<GPUImageInput> *)newFilter;
//取到指定滤镜
- (GPUImageOutput<GPUImageInput> *)filterAtIndex:(NSUInteger)filterIndex;
//滤镜总个数
- (NSUInteger)filterCount;
  • 其它代码

// 增加滤镜
- (void)addFilter:(GPUImageOutput<GPUImageInput> *)newFilter;
- (GPUImageOutput<GPUImageInput> *)filterAtIndex:(NSUInteger)filterIndex;
- (NSUInteger)filterCount;

// 增加滤镜
- (void)addFilter:(GPUImageOutput<GPUImageInput> *)newFilter;
{
    [filters addObject:newFilter];
}

// 获取滤镜
- (GPUImageOutput<GPUImageInput> *)filterAtIndex:(NSUInteger)filterIndex;
{
    return [filters objectAtIndex:filterIndex];
}

// 滤镜数量
- (NSUInteger)filterCount;
{
    return [filters count];
}

//
- (void)newFrameReadyAtTime:(CMTime)frameTime atIndex:(NSInteger)textureIndex;
{
    for (GPUImageOutput<GPUImageInput> *currentFilter in _initialFilters)
    {
        if (currentFilter != self.inputFilterToIgnoreForUpdates)
        {
            [currentFilter newFrameReadyAtTime:frameTime atIndex:textureIndex];
        }
    }
}

// 设置帧缓存对象
- (void)setInputFramebuffer:(GPUImageFramebuffer *)newInputFramebuffer atIndex:(NSInteger)textureIndex;
{
    for (GPUImageOutput<GPUImageInput> *currentFilter in _initialFilters)
    {
        [currentFilter setInputFramebuffer:newInputFramebuffer atIndex:textureIndex];
    }
}

Last updated