vvopensource
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
Instance Methods | Properties
VVBuffer Class Reference

VVBuffer represents a buffer- almost always in VRAM as a GL texture or renderbuffer- created and managed by VVBufferPool. Conceptually, it's safe to think of VVBuffers as "images" or "frames", as that is typically what they're used for. You should never alloc/init a VVBuffer- if you want a buffer, you need to get one by asking a VVBufferPool to create one for you. More...

#import <VVBuffer.h>

Inherits NSObject, and <NSCopying>.

Instance Methods

(VVBufferDescriptor *) - descriptorPtr
 Returns a ptr to the VVBufferDescriptor that describes this VVBuffer. This struct describes the basic underlying properties of the VVBuffer- its internal GL formats, and other attributes that are set on creation (and are beneficial to track for doing other image operations)
 
(struct timeval *) - contentTimestampPtr
 Returns a ptr to the VVBuffer's content timestamp. Content timestamps may be generated by +[VVBufferPool timestampThisBuffer:]. This is a ptr to a simple timeval struct- timestamps may be used to aid in differentiating between frames and checking for "new" content.
 
(void) - getContentTimestamp:
 Copies the values from the receiver's content timestamp into the passed timeval struct. Content timestamps may be generated by +[VVBufferPool timestampThisBuffer:]. This is a ptr to a simple timeval struct- timestamps may be used to aid in differentiating between frames and checking for "new" content.
 
(void) - setUserInfo:
 Not used by this framework- the "userInfo" is an arbitrary id that you can use to assign stuff to VVBuffers. The passed ptr is retained with the VVBuffer for the duration of its existence.
 
(id) - userInfo
 Returns the buffer's "userInfo" (if there is one).
 
(NSRect) - srcRectCroppedWith:takingFlipIntoAccount:
 The "srcRect" value in VVBuffer describes the region of the underlying texture to use as an image. This is essentially a zero-cost crop: you can change the dimensions and location of the "srcRect" to non-destructively change the "cropping" of the underlying image. This is cool, but it's a pain in the butt if you want to crop something that was already cropped and may or may not be flipped. This method simplifies the task of cropping an existing VVBuffer. More...
 
(BOOL) - isContentMatchToBuffer:
 Returns a YES if the passed buffer and the receiver have matching contentTimeStamps.
 
(CVPixelBufferRef) - cvPixBuf
 If the receiver was created from a CVPixelBufferRef, this will return the CVPixelBufferRef (which is retained by the buffer until it's freed). Returns nil if the buffer wasn't created from a CVPixelBuffer.
 
(CVOpenGLTextureRef) - cvTexRef
 If the receiver was created by "wrapping" a CVOpenGLTextureRef, this will return the CVOpenGLTextureRef (which is retained by the buffer until it's freed). Returns nil if the buffer wasn't created from a CVOpenGLTextureRef.
 
(NSBitmapImageRep *) - bitmapRep
 If the receiver was created from a CVPixelBufferRef, this will return the NSBitmapImageRep (which is retained by the buffer until it's freed). Returns nil if the buffer wasn't created from a NSBitmapImageRep.
 
(void *) - cpuBackingPtr
 If a VVBuffer was created from a CPU-based resource, this will always return a ptr to the raw pixels used in the underlying image. For example, if you make a VVBuffer/GL texture from an NSBitmapImageRep, the "cpuBackingPtr" will point to the bitmap rep's "pixelData".
 
(void) - setBackingReleaseCallback:
 Should only be used when extending VVBufferPool to work with other drawing APIs. The "backingReleaseCallback" is a function pointer that gets called when the VVBuffer is being freed. If you make a VVBuffer that "wraps" another graphic resource (retaining it with the VVBuffer), this function is where you want to free the graphic resource. You probably don't want to go changing this in VVBuffers- this is the sort of thing that is best set when the VVBuffer is created, and then left alone. More...
 
(void) - setBackingReleaseCallbackContext:
 Should only be used when extending VVBufferPool to work with other drawing APIs. The "backingReleaseCallbackContext" is a pointer passed to the "backingReleaseCallback", which gets called when the VVBuffer is being freed. If you make a VVBuffer that "wraps" another graphic resource (retaining it with the VVBuffer), the callback context is where you want to store and retain the underlying graphic resource. You probably don't want to go changing this in VVBuffers- this is the sort of thing that is best set when the VVBuffer is created, and then left alone. More...
 
(IOSurfaceRef) - localSurfaceRef
 If the receiver is a GL texture backed by an IOSurfaceRef, this returns the IOSurfaceRef. If you want to send a texture to another process, you want to call -[VVBufferPool allocBufferForTexBackedIOSurfaceSized:], render into the returned buffer, and then call "localSurfaceRef" to retrieve the IOSurface to be sent to another process.
 

Properties

NSSize size
 This returns the size of the underlying GL resource. The value returned by this method is always using pixels as the base unit of measurement. This value should be set by the buffer pool. If you want to retrieve the size of the image/frame represented by the VVBuffer, get the "size" member of the "srcRect"!
 
NSRect srcRect
 The "srcRect" is the region of the GL resource that contains an image- this value is always measured in pixels, and measures from the bottom-left corner of the texture. It's safe to both set and get this value, because it's non-destructive: the "srcRect" is only used when you want to do something with the VVBuffer (draw it, pass it to another object for copying/etc).
 
BOOL flipped
 Whether or not the image represented by this buffer is flipped vertically. Like "srcRect", it's safe and quick to both set and get this value- changing it does not cause any graphic operatings to occur, the value is only used when you want to do something with this VVBuffer.
 
NSSize backingSize
 If the buffer has some kind of backing, these are its dimensions. Stored here as a different size to deal with situations where the backing has different dimensions than the GL resource created from it. Set when the buffer is created, you probably shouldn't change this.
 
NSRect normalizedSrcRect
 Takes "srcRect", and then divides its members by the size of the GL resource to normalize them.
 
NSRect glReadySrcRect
 If you want to draw a texture, you need to know what the texture coordinates are so you can specify where to draw the texture on your triangles/quads. Texture coordinates depend on what "type" of texture you're working with (GL_TEXTURE_2D tex coords are always normalized, GL_TEXTURE_RECTANGLE_EXT coords are never normalized). This method returns an NSRect populated with the texture coords you should use to draw the contents of this buffer. This method/this value is useful if you're writing your own GL drawing code- if you're working exclusively with VVBufferPool objects, you probably won't need this as much.
 
BOOL isFullFrame
 Returns YES if "srcRect" has an origin at 0,0 and a size that matches the texture size!
 
GLuint name
 The actual name of the underlying GL resource- when you want to draw a texture, this is what you bind. You'll probably only need to use this if you're writing your own GL drawing commands.
 
GLuint target
 If this VVBuffer has an underlying GL resource, this returns the target of the resource. By default, this is usually GL_TEXTURE_RECTANGLE_EXT, though it may also be GL_TEXTURE_2D.
 
BOOL safeToPublishToSyphon
 Returns a YES if this VVBuffer is safe to publish to syphon- in order to be safe to publish via Syphon, a VVBuffer must be a rectangular texture using 8 bits per channel (32bits per pixel) backed by an IOSurface. If the VVBuffer is flipped, or isn't full-frame, this will return a NO.
 
VVBufferBackID backingID
 The VVBufferBackID doesn't play a functional role in the processing of VVBuffer- it's an enum that exists so you can flag what this buffer was created from. This variable exists to make it easier to retrieve the underlying resource wrapped by the VVBuffer (for example, retrieving a CVOpenGLTextureRef, NSBitmapImageRep, etc) or determining the provenance of a buffer.
 

Detailed Description

VVBuffer represents a buffer- almost always in VRAM as a GL texture or renderbuffer- created and managed by VVBufferPool. Conceptually, it's safe to think of VVBuffers as "images" or "frames", as that is typically what they're used for. You should never alloc/init a VVBuffer- if you want a buffer, you need to get one by asking a VVBufferPool to create one for you.

VVBuffers are the basic unit produced by VVBufferPool- each buffer typically represents an image of some sort- usually a GL texture. VVBuffers are almost always pooled as they are freed so they may be re-used to minimize having to delete/recreate GL-related resources.

VVBuffers conform to the NSCopying protocol, but this behavior isn't straightforward- while calling "copy" on an instance of VVBuffer will result in the creation of another VVBuffer instance, both buffers refer to the same underlying GL resource (the same texture, for example). If you want to actually duplicate a VVBuffer- if you want to create another GL texture with the same contents- you need to use the VVBufferCopier class.

Method Documentation

- (void) setBackingReleaseCallback: (VVBufferBackingReleaseCallback n

Should only be used when extending VVBufferPool to work with other drawing APIs. The "backingReleaseCallback" is a function pointer that gets called when the VVBuffer is being freed. If you make a VVBuffer that "wraps" another graphic resource (retaining it with the VVBuffer), this function is where you want to free the graphic resource. You probably don't want to go changing this in VVBuffers- this is the sort of thing that is best set when the VVBuffer is created, and then left alone.

Parameters
nasdfasdfasdf
- (void) setBackingReleaseCallbackContext: (void *)  n

Should only be used when extending VVBufferPool to work with other drawing APIs. The "backingReleaseCallbackContext" is a pointer passed to the "backingReleaseCallback", which gets called when the VVBuffer is being freed. If you make a VVBuffer that "wraps" another graphic resource (retaining it with the VVBuffer), the callback context is where you want to store and retain the underlying graphic resource. You probably don't want to go changing this in VVBuffers- this is the sort of thing that is best set when the VVBuffer is created, and then left alone.

Parameters
nAn arbitrary pointer to a resource that is assumed to be required by this VVBuffer. VVBuffer doesn't explicitly retain anything passed to this method (because it's unknown if it will even be a void* or an id)- you are responsible for ensuring that whatever you pass here is retained, and freed later in the backingReleaseCallback.
- (NSRect) srcRectCroppedWith: (NSRect)  cropRect
takingFlipIntoAccount: (BOOL)  f 

The "srcRect" value in VVBuffer describes the region of the underlying texture to use as an image. This is essentially a zero-cost crop: you can change the dimensions and location of the "srcRect" to non-destructively change the "cropping" of the underlying image. This is cool, but it's a pain in the butt if you want to crop something that was already cropped and may or may not be flipped. This method simplifies the task of cropping an existing VVBuffer.

Parameters
cropRectA normalized NSRect describing the crop rect you want to apply to the existing image
fYES if you want this operating to take the VVBuffer's flippedness into account
Returns
Returns an NSRect with the new srcRect that you can apply to the receiver or do further calculations with.

The documentation for this class was generated from the following files: