Panda3D
Loading...
Searching...
No Matches
subprocessWindowBuffer.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file subprocessWindowBuffer.I
10 * @author drose
11 * @date 2009-07-11
12 */
13
14/**
15 * Returns the width of the framebuffer in pixels.
16 */
18get_x_size() const {
19 return _x_size;
20}
21
22/**
23 * Returns the height of the framebuffer in pixels.
24 */
26get_y_size() const {
27 return _y_size;
28}
29
30/**
31 * Returns the length of a row of the framebuffer, in bytes.
32 */
34get_row_size() const {
35 return _row_size;
36}
37
38/**
39 * Returns the total number of bytes in the framebuffer.
40 */
43 return _framebuffer_size;
44}
45
46/**
47 * Returns true if the framebuffer data has been updated since
48 * open_read_framebuffer() was last called.
49 */
51ready_for_read() const {
52 return (_last_written != _last_read);
53}
54
55/**
56 * Returns true if the framebuffer data has been read since
57 * open_write_framebuffer() was last called.
58 */
60ready_for_write() const {
61 return (_last_written == _last_read);
62}
63
64/**
65 * Returns a read-only pointer to the framebuffer. It is only valid to call
66 * this if ready_for_read() has returned true.
67 *
68 * You must call close_read_framebuffer() to indicate you have finished
69 * reading.
70 */
71inline const void *SubprocessWindowBuffer::
73 assert(ready_for_read());
74 return (void *)(this + 1);
75}
76
77/**
78 * Releases the framebuffer after a previous call to open_read_framebuffer().
79 */
82 _last_read = _last_written;
83}
84
85/**
86 * Returns a writable pointer to the framebuffer. It is only valid to call
87 * this if ready_for_write() has returned true.
88 *
89 * You must call close_write_framebuffer() to indicate you have finished
90 * writing.
91 */
94 assert(ready_for_write());
95 return (void *)(this + 1);
96}
97
98/**
99 * Releases the framebuffer after a previous call to open_write_framebuffer().
100 */
103 ++_last_written;
104}
105
106/**
107 * Adds a new Event to the queue. Returns false if the queue was full.
108 */
111 if (((_event_in + 1) % max_events) == _event_out) {
112 // The queue is full.
113 return false;
114 }
115 _events[_event_in] = event;
116 _event_in = (_event_in + 1) % max_events;
117 return true;
118}
119
120/**
121 * Returns true if the queue has at least one Event to extract, false if it is
122 * empty.
123 */
125has_event() const {
126 return (_event_in != _event_out);
127}
128
129/**
130 * If the queue is nonempty, fills event with the first Event on the queue and
131 * returns true. If the queue is empty, returns false.
132 */
135 if (_event_in == _event_out) {
136 return false;
137 }
138 event = _events[_event_out];
139 _event_out = (_event_out + 1) % max_events;
140 return true;
141}
size_t get_framebuffer_size() const
Returns the total number of bytes in the framebuffer.
bool has_event() const
Returns true if the queue has at least one Event to extract, false if it is empty.
int get_y_size() const
Returns the height of the framebuffer in pixels.
bool ready_for_write() const
Returns true if the framebuffer data has been read since open_write_framebuffer() was last called.
bool get_event(Event &event)
If the queue is nonempty, fills event with the first Event on the queue and returns true.
const void * open_read_framebuffer()
Returns a read-only pointer to the framebuffer.
int get_x_size() const
Returns the width of the framebuffer in pixels.
bool ready_for_read() const
Returns true if the framebuffer data has been updated since open_read_framebuffer() was last called.
void * open_write_framebuffer()
Returns a writable pointer to the framebuffer.
void close_write_framebuffer()
Releases the framebuffer after a previous call to open_write_framebuffer().
bool add_event(const Event &event)
Adds a new Event to the queue.
void close_read_framebuffer()
Releases the framebuffer after a previous call to open_read_framebuffer().
size_t get_row_size() const
Returns the length of a row of the framebuffer, in bytes.