fix parasite buffer clear problem

This commit is contained in:
David Rose 2011-10-06 21:39:19 +00:00
parent 72f97c2107
commit 3e89b7a4e8
5 changed files with 98 additions and 27 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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();