GPUImage源码解读(十六)

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];
        }
    });
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值