MGOpenGLRenderer.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. File: RosyWriterOpenGLRenderer.h
  3. Abstract: The RosyWriter OpenGL effect renderer
  4. Version: 2.1
  5. Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
  6. Inc. ("Apple") in consideration of your agreement to the following
  7. terms, and your use, installation, modification or redistribution of
  8. this Apple software constitutes acceptance of these terms. If you do
  9. not agree with these terms, please do not use, install, modify or
  10. redistribute this Apple software.
  11. In consideration of your agreement to abide by the following terms, and
  12. subject to these terms, Apple grants you a personal, non-exclusive
  13. license, under Apple's copyrights in this original Apple software (the
  14. "Apple Software"), to use, reproduce, modify and redistribute the Apple
  15. Software, with or without modifications, in source and/or binary forms;
  16. provided that if you redistribute the Apple Software in its entirety and
  17. without modifications, you must retain this notice and the following
  18. text and disclaimers in all such redistributions of the Apple Software.
  19. Neither the name, trademarks, service marks or logos of Apple Inc. may
  20. be used to endorse or promote products derived from the Apple Software
  21. without specific prior written permission from Apple. Except as
  22. expressly stated in this notice, no other rights or licenses, express or
  23. implied, are granted by Apple herein, including but not limited to any
  24. patent rights that may be infringed by your derivative works or by other
  25. works in which the Apple Software may be incorporated.
  26. The Apple Software is provided by Apple on an "AS IS" basis. APPLE
  27. MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
  28. THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
  29. FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
  30. OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
  31. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
  32. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  33. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  34. INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
  35. MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
  36. AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
  37. STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
  38. POSSIBILITY OF SUCH DAMAGE.
  39. Copyright (C) 2014 Apple Inc. All Rights Reserved.
  40. */
  41. #import <Foundation/Foundation.h>
  42. #import <AVFoundation/AVFoundation.h>
  43. #import "MGOpenGLConfig.h"
  44. @class MGFaceModelArray;
  45. @interface MGOpenGLRenderer : NSObject
  46. /* Format/Processing Requirements */
  47. @property(nonatomic, readonly) BOOL operatesInPlace; // When YES the input pixel buffer is written to by the renderer instead of writing the result to a new pixel buffer.
  48. @property(nonatomic, readonly) FourCharCode inputPixelFormat; // One of 420f, 420v, or BGRA
  49. /* Resource Lifecycle */
  50. // Prepare and destroy expensive resources inside these callbacks.
  51. // The outputRetainedBufferCountHint tells out of place renderers how many of their output buffers will be held onto by the downstream pipeline at one time.
  52. // This can be used by the renderer to size and preallocate their pools.
  53. - (void)prepareForInputWithFormatDescription:(CMFormatDescriptionRef)inputFormatDescription
  54. outputRetainedBufferCountHint:(size_t)outputRetainedBufferCountHint;
  55. - (void)reset;
  56. /* Rendering */
  57. // Renderers which operate in place should return the input pixel buffer with a +1 retain count.
  58. // Renderers which operate out of place should create a pixel buffer to return from a pool they own.
  59. // When rendering to a pixel buffer with the GPU it is not necessary to block until rendering has completed before returning.
  60. // It is sufficient to call glFlush() to ensure that the commands have been flushed to the GPU.
  61. //- (CVPixelBufferRef )copyRenderedPixelBuffer:(CMSampleBufferRef)sampleBufferRef faceModelArray:(MGFaceModelArray *)modelArray drawLandmark:(BOOL)drawLandmark;
  62. @property(nonatomic, assign) BOOL show3DView;
  63. // This property must be implemented if operatesInPlace is NO and the output pixel buffers have a different format description than the input.
  64. // If implemented a non-NULL value must be returned once the renderer has been prepared (can be NULL after being reset).
  65. @property(nonatomic, readonly) CMFormatDescriptionRef __attribute__((NSObject)) outputFormatDescription;
  66. - (void)setUpOutSampleBuffer:(CGSize)outSize devicePosition:(AVCaptureDevicePosition)devicePosition;
  67. - (CVPixelBufferRef )drawPixelBuffer:(CMSampleBufferRef)sampleBufferRef custumDrawing:(void (^)(void))draw;
  68. - (void)drawFaceLandMark:(MGFaceModelArray *)faces;
  69. - (void)drawRect:(CGRect)rect;
  70. - (void)drawFaceWithRect:(CGRect)rect;
  71. @end