diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index 8b4c6d64c2..84c09d0a54 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -723,17 +723,6 @@ get_screenshot() { return _overlay_display_region->get_screenshot(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::flip_ready -// Access: Public -// Description: Returns true if a frame has been rendered and needs -// to be flipped, false otherwise. -//////////////////////////////////////////////////////////////////// -INLINE bool GraphicsOutput:: -flip_ready() const { - return _flip_ready; -} - //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::operator < // Access: Public diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index b01e382d2e..ff47ec31ca 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -1107,6 +1107,17 @@ void GraphicsOutput:: unshare_depth_buffer() { } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::flip_ready +// Access: Public, Virtual +// Description: Returns true if a frame has been rendered and needs +// to be flipped, false otherwise. +//////////////////////////////////////////////////////////////////// +bool GraphicsOutput:: +flip_ready() const { + return _flip_ready; +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::get_host // Access: Public, Virtual diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index 917187f703..ddb8f35782 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -210,7 +210,7 @@ PUBLISHED: public: // These are not intended to be called directly by the user. - INLINE bool flip_ready() const; + virtual bool flip_ready() const; INLINE bool operator < (const GraphicsOutput &other) const; diff --git a/panda/src/display/parasiteBuffer.cxx b/panda/src/display/parasiteBuffer.cxx index dcfc210a69..b90f76f070 100644 --- a/panda/src/display/parasiteBuffer.cxx +++ b/panda/src/display/parasiteBuffer.cxx @@ -68,6 +68,17 @@ ParasiteBuffer:: _is_valid = false; } +//////////////////////////////////////////////////////////////////// +// Function: ParasiteBuffer::is_active +// Access: Published, Virtual +// Description: Returns true if the window is ready to be rendered +// into, false otherwise. +//////////////////////////////////////////////////////////////////// +bool ParasiteBuffer:: +is_active() const { + return GraphicsOutput::is_active() && _host->is_active(); +} + //////////////////////////////////////////////////////////////////// // Function: ParasiteBuffer::set_size // Access: Public, Virtual @@ -107,28 +118,69 @@ set_size_and_recalc(int x, int y) { } //////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::is_active -// Access: Published, Virtual -// Description: Returns true if the window is ready to be rendered -// into, false otherwise. +// Function: ParasiteBuffer::flip_ready +// Access: Public, Virtual +// Description: Returns true if a frame has been rendered and needs +// to be flipped, false otherwise. //////////////////////////////////////////////////////////////////// bool ParasiteBuffer:: -is_active() const { - return GraphicsOutput::is_active() && _host->is_active(); +flip_ready() const { + nassertr(_host != NULL, false); + return _host->flip_ready(); } //////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::get_host +// Function: ParasiteBuffer::begin_flip // Access: Public, Virtual -// Description: This is normally called only from within -// make_texture_buffer(). When called on a -// ParasiteBuffer, it returns the host of that buffer; -// but when called on some other buffer, it returns the -// buffer itself. +// Description: This function will be called within the draw thread +// after end_frame() has been called on all windows, to +// initiate the exchange of the front and back buffers. +// +// This should instruct the window to prepare for the +// flip at the next video sync, but it should not wait. +// +// We have the two separate functions, begin_flip() and +// end_flip(), to make it easier to flip all of the +// windows at the same time. //////////////////////////////////////////////////////////////////// -GraphicsOutput *ParasiteBuffer:: -get_host() { - return _host; +void ParasiteBuffer:: +begin_flip() { + nassertv(_host != NULL); + _host->begin_flip(); +} + +//////////////////////////////////////////////////////////////////// +// Function: ParasiteBuffer::ready_flip +// Access: Public, Virtual +// Description: This function will be called within the draw thread +// after end_frame() has been called on all windows, to +// initiate the exchange of the front and back buffers. +// +// This should instruct the window to prepare for the +// flip when it is command but not actually flip +// +//////////////////////////////////////////////////////////////////// +void ParasiteBuffer:: +ready_flip() { + nassertv(_host != NULL); + _host->ready_flip(); +} + +//////////////////////////////////////////////////////////////////// +// Function: ParasiteBuffer::end_flip +// Access: Public, Virtual +// Description: This function will be called within the draw thread +// after begin_flip() has been called on all windows, to +// finish the exchange of the front and back buffers. +// +// This should cause the window to wait for the flip, if +// necessary. +//////////////////////////////////////////////////////////////////// +void ParasiteBuffer:: +end_flip() { + nassertv(_host != NULL); + _host->end_flip(); + _flip_ready = false; } //////////////////////////////////////////////////////////////////// @@ -192,3 +244,17 @@ end_frame(FrameMode mode, Thread *current_thread) { } } +//////////////////////////////////////////////////////////////////// +// Function: ParasiteBuffer::get_host +// Access: Public, Virtual +// Description: This is normally called only from within +// make_texture_buffer(). When called on a +// ParasiteBuffer, it returns the host of that buffer; +// but when called on some other buffer, it returns the +// buffer itself. +//////////////////////////////////////////////////////////////////// +GraphicsOutput *ParasiteBuffer:: +get_host() { + return _host; +} + diff --git a/panda/src/display/parasiteBuffer.h b/panda/src/display/parasiteBuffer.h index 4575140670..2b73440354 100644 --- a/panda/src/display/parasiteBuffer.h +++ b/panda/src/display/parasiteBuffer.h @@ -61,6 +61,11 @@ PUBLISHED: public: void set_size_and_recalc(int x, int y); + virtual bool flip_ready() const; + virtual void begin_flip(); + virtual void ready_flip(); + virtual void end_flip(); + virtual bool begin_frame(FrameMode mode, Thread *current_thread); virtual void end_frame(FrameMode mode, Thread *current_thread); virtual GraphicsOutput *get_host();