GPUImageTextureInput继承自GPUImageOutput,可以用传入的纹理生成帧缓存对象。因此,可以作为响应链源使用。
- 构造方法。构造方法只有一个,接收的参数是纹理对象和纹理大小
- (id)initWithTexture:(GLuint)newInputTexture size:(CGSize)newTextureSize;
- 构造的时候,主要是用传入的纹理生成帧缓存对象。
- (id)initWithTexture:(GLuint)newInputTexture size:(CGSize)newTextureSize;
{
if (!(self = [super init]))
{
return nil;
}
runSynchronouslyOnVideoProcessingQueue(^{
[GPUImageContext useImageProcessingContext];
});
textureSize = newTextureSize;
runSynchronouslyOnVideoProcessingQueue(^{
//分配一个GPUImageFramebuffer,缓存纹理单元的信息
outputFramebuffer = [[GPUImageFramebuffer alloc] initWithSize:newTextureSize overriddenTexture:newInputTexture];
});
return self;
}
- 其它方法。出去父类的方法,它只提供了一个数据处理的方法
- (void)processTextureWithFrameTime:(CMTime)frameTime;
- 处理数据的过程就是将帧缓存对象传递给所有targets,驱动所有targets处理。
- (void)processTextureWithFrameTime:(CMTime)frameTime;
{
runAsynchronouslyOnVideoProcessingQueue(^{
// 遍历所有targets,驱动各个target处理数据
for (id<GPUImageInput> currentTarget in targets)
{
NSInteger indexOfObject = [targets indexOfObject:currentTarget];
NSInteger targetTextureIndex = [[targetTextureIndices objectAtIndex:indexOfObject] integerValue];
[currentTarget setInputSize:textureSize atIndex:targetTextureIndex];
[currentTarget setInputFramebuffer:outputFramebuffer atIndex:targetTextureIndex];
[currentTarget newFrameReadyAtTime:frameTime atIndex:targetTextureIndex];
}
});
}