GPUImageTextureInput.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #import "GPUImageTextureInput.h"
  2. @implementation GPUImageTextureInput
  3. #pragma mark -
  4. #pragma mark Initialization and teardown
  5. - (id)initWithTexture:(GLuint)newInputTexture size:(CGSize)newTextureSize;
  6. {
  7. if (!(self = [super init]))
  8. {
  9. return nil;
  10. }
  11. runSynchronouslyOnVideoProcessingQueue(^{
  12. [GPUImageContext useImageProcessingContext];
  13. });
  14. textureSize = newTextureSize;
  15. runSynchronouslyOnVideoProcessingQueue(^{
  16. outputFramebuffer = [[GPUImageFramebuffer alloc] initWithSize:newTextureSize overriddenTexture:newInputTexture];
  17. });
  18. return self;
  19. }
  20. #pragma mark -
  21. #pragma mark Image rendering
  22. - (void)processTextureWithFrameTime:(CMTime)frameTime;
  23. {
  24. runAsynchronouslyOnVideoProcessingQueue(^{
  25. for (id<GPUImageInput> currentTarget in targets)
  26. {
  27. NSInteger indexOfObject = [targets indexOfObject:currentTarget];
  28. NSInteger targetTextureIndex = [[targetTextureIndices objectAtIndex:indexOfObject] integerValue];
  29. [currentTarget setInputSize:textureSize atIndex:targetTextureIndex];
  30. [currentTarget setInputFramebuffer:outputFramebuffer atIndex:targetTextureIndex];
  31. [currentTarget newFrameReadyAtTime:frameTime atIndex:targetTextureIndex];
  32. }
  33. });
  34. }
  35. @end