This is a special class that is designed to faciliate SubprocessWindow. More...
#include "subprocessWindowBuffer.h"
Classes | |
class | Event |
Public Member Functions | |
bool | add_event (const Event &event) |
Adds a new Event to the queue. More... | |
void | close_read_framebuffer () |
Releases the framebuffer after a previous call to open_read_framebuffer(). More... | |
void | close_write_framebuffer () |
Releases the framebuffer after a previous call to open_write_framebuffer(). More... | |
bool | get_event (Event &event) |
If the queue is nonempty, fills event with the first Event on the queue and returns true. More... | |
size_t | get_framebuffer_size () const |
Returns the total number of bytes in the framebuffer. More... | |
size_t | get_row_size () const |
Returns the length of a row of the framebuffer, in bytes. More... | |
int | get_x_size () const |
Returns the width of the framebuffer in pixels. More... | |
int | get_y_size () const |
Returns the height of the framebuffer in pixels. More... | |
bool | has_event () const |
Returns true if the queue has at least one Event to extract, false if it is empty. More... | |
const void * | open_read_framebuffer () |
Returns a read-only pointer to the framebuffer. More... | |
void * | open_write_framebuffer () |
Returns a writable pointer to the framebuffer. More... | |
bool | ready_for_read () const |
Returns true if the framebuffer data has been updated since open_read_framebuffer() was last called. More... | |
bool | ready_for_write () const |
Returns true if the framebuffer data has been read since open_write_framebuffer() was last called. More... | |
bool | verify_magic_number () const |
Returns true if the buffer's magic number matches, false otherwise. More... | |
Static Public Member Functions | |
static void | close_buffer (int fd, size_t mmap_size, const std::string &filename, SubprocessWindowBuffer *buffer) |
Closes a buffer object created via a previous call to open_buffer(). More... | |
static void | destroy_buffer (int fd, size_t mmap_size, const std::string &filename, SubprocessWindowBuffer *buffer) |
Destroys a buffer object created via a previous call to new_buffer(). More... | |
static SubprocessWindowBuffer * | new_buffer (int &fd, size_t &mmap_size, std::string &filename, int x_size, int y_size) |
Call this method to create a new buffer in shared memory space. More... | |
static SubprocessWindowBuffer * | open_buffer (int &fd, size_t &mmap_size, const std::string &filename) |
Call this method to open a reference to an existing buffer in shared memory space. More... | |
This is a special class that is designed to faciliate SubprocessWindow.
It's intended to be allocated within a shared memory buffer, and it contains space for a framebuffer image to be stored for transferring between processes, as well as appropriate synchronization primitives.
It's designed to be compiled outside of Panda, so that code that doesn't link with Panda (in particular, the Panda3D plugin core API) may still link with this and use it.
At the moment, and maybe indefinitely, it is only compiled on OSX, and only when we are building support for the plugin; because it is only needed then.
Definition at line 35 of file subprocessWindowBuffer.h.
|
inline |
Adds a new Event to the queue.
Returns false if the queue was full.
Definition at line 110 of file subprocessWindowBuffer.I.
|
static |
Closes a buffer object created via a previous call to open_buffer().
This unmaps the shared memory and closes the file descriptor, but does not molest the shared buffer itself.
Definition at line 237 of file subprocessWindowBuffer.cxx.
Referenced by destroy_buffer().
|
inline |
Releases the framebuffer after a previous call to open_read_framebuffer().
Definition at line 81 of file subprocessWindowBuffer.I.
|
inline |
Releases the framebuffer after a previous call to open_write_framebuffer().
Definition at line 102 of file subprocessWindowBuffer.I.
|
static |
Destroys a buffer object created via a previous call to new_buffer().
This destructs objects within the buffer, unmaps the shared memory, and closes the file descriptor.
Definition at line 140 of file subprocessWindowBuffer.cxx.
References close_buffer().
|
inline |
If the queue is nonempty, fills event with the first Event on the queue and returns true.
If the queue is empty, returns false.
Definition at line 134 of file subprocessWindowBuffer.I.
|
inline |
Returns the total number of bytes in the framebuffer.
Definition at line 42 of file subprocessWindowBuffer.I.
|
inline |
Returns the length of a row of the framebuffer, in bytes.
Definition at line 34 of file subprocessWindowBuffer.I.
|
inline |
Returns the width of the framebuffer in pixels.
Definition at line 18 of file subprocessWindowBuffer.I.
|
inline |
Returns the height of the framebuffer in pixels.
Definition at line 26 of file subprocessWindowBuffer.I.
|
inline |
Returns true if the queue has at least one Event to extract, false if it is empty.
Definition at line 125 of file subprocessWindowBuffer.I.
|
static |
Call this method to create a new buffer in shared memory space.
Supply the desired size of the window.
This method will create the required shared-memory buffer and return a SubprocessWindowBuffer allocated within that shared memory, or NULL if there is a failure allocating sufficient shared memory.
It also creates a temporary file on disk and returns fd, mmap_size, and filename, which the caller must retain and eventually pass to destroy_buffer(). The filename should be passed to the child process to open with open_buffer().
Definition at line 95 of file subprocessWindowBuffer.cxx.
|
static |
Call this method to open a reference to an existing buffer in shared memory space.
Supply the temporary filename returned by new_buffer(), above (presumably from the parent process).
This method will mmap the required shared-memory buffer and return a SubprocessWindowBuffer allocated within that shared memory, or NULL if there is some failure. The caller must retain fd, mmap_size, and filename and eventually pass all three to close_buffer().
Definition at line 160 of file subprocessWindowBuffer.cxx.
References verify_magic_number().
|
inline |
Returns a read-only pointer to the framebuffer.
It is only valid to call this if ready_for_read() has returned true.
You must call close_read_framebuffer() to indicate you have finished reading.
Definition at line 72 of file subprocessWindowBuffer.I.
References ready_for_read().
|
inline |
Returns a writable pointer to the framebuffer.
It is only valid to call this if ready_for_write() has returned true.
You must call close_write_framebuffer() to indicate you have finished writing.
Definition at line 93 of file subprocessWindowBuffer.I.
References ready_for_write().
|
inline |
Returns true if the framebuffer data has been updated since open_read_framebuffer() was last called.
Definition at line 51 of file subprocessWindowBuffer.I.
Referenced by open_read_framebuffer().
|
inline |
Returns true if the framebuffer data has been read since open_write_framebuffer() was last called.
Definition at line 60 of file subprocessWindowBuffer.I.
Referenced by open_write_framebuffer().
bool SubprocessWindowBuffer::verify_magic_number | ( | ) | const |
Returns true if the buffer's magic number matches, false otherwise.
Definition at line 247 of file subprocessWindowBuffer.cxx.
Referenced by open_buffer().