Browse Source

add GraphicsOutput::flip_ready

David Rose 22 năm trước cách đây
mục cha
commit
a39aa8f71c

+ 2 - 4
panda/src/display/graphicsEngine.cxx

@@ -775,15 +775,13 @@ flip_windows(const GraphicsEngine::Windows &wlist) {
   Windows::const_iterator wi;
   for (wi = wlist.begin(); wi != wlist.end(); ++wi) {
     GraphicsOutput *win = (*wi);
-    if (win->is_active() && win->get_gsg()->is_active() && 
-        !win->get_gsg()->get_properties().is_single_buffered()) {
+    if (win->flip_ready()) {
       win->begin_flip();
     }
   }
   for (wi = wlist.begin(); wi != wlist.end(); ++wi) {
     GraphicsOutput *win = (*wi);
-    if (win->is_active() && win->get_gsg()->is_active() && 
-        !win->get_gsg()->get_properties().is_single_buffered()) {
+    if (win->flip_ready()) {
       win->end_flip();
     }
   }

+ 11 - 0
panda/src/display/graphicsOutput.I

@@ -160,6 +160,17 @@ is_valid() const {
   return _is_valid;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsOutput::flip_ready
+//       Access: Published
+//  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::get_sort
 //       Access: Published

+ 7 - 0
panda/src/display/graphicsOutput.cxx

@@ -51,6 +51,7 @@ GraphicsOutput(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
   _has_size = false;
   _is_valid = false;
   _copy_texture = false;
+  _flip_ready = false;
   _sort = 0;
 
   int mode = gsg->get_properties().get_frame_buffer_mode();
@@ -542,6 +543,11 @@ end_frame() {
     TextureContext *tc = get_texture()->prepare_now(_gsg->get_prepared_objects(), _gsg);
     _gsg->copy_texture(tc, &dr, buffer);
   }
+
+  // If we're not single-buffered, we're now ready to flip.
+  if (!_gsg->get_properties().is_single_buffered()) {
+    _flip_ready = true;
+  }
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -599,6 +605,7 @@ begin_flip() {
 ////////////////////////////////////////////////////////////////////
 void GraphicsOutput::
 end_flip() {
+  _flip_ready = false;
 }
 
 ////////////////////////////////////////////////////////////////////

+ 2 - 0
panda/src/display/graphicsOutput.h

@@ -80,6 +80,7 @@ PUBLISHED:
   INLINE int get_y_size() const;
   INLINE bool has_size() const;
   INLINE bool is_valid() const;
+  INLINE bool flip_ready() const;
 
   virtual bool is_active() const;
 
@@ -149,6 +150,7 @@ protected:
   string _name;
   PT(Texture) _texture;
   bool _copy_texture;
+  bool _flip_ready;
 
 private:
   INLINE void determine_display_regions() const;

+ 1 - 0
panda/src/dxgsg7/wdxGraphicsWindow7.cxx

@@ -219,6 +219,7 @@ end_flip() {
   if (_dxgsg != (DXGraphicsStateGuardian7 *)NULL && is_active()) {
     _dxgsg->show_frame();
   }
+  GraphicsWindow::end_flip();
 }
 
 ////////////////////////////////////////////////////////////////////

+ 1 - 0
panda/src/dxgsg8/wdxGraphicsWindow8.cxx

@@ -258,6 +258,7 @@ end_flip() {
     //    wdxdisplay8_cat.debug() << "current swapchain from end_flip is " << _wcontext.pSwapChain << "\n";
     _dxgsg->show_frame();
   }
+  GraphicsWindow::end_flip();
 }
 
 ////////////////////////////////////////////////////////////////////

+ 1 - 0
panda/src/dxgsg9/wdxGraphicsWindow9.cxx

@@ -259,6 +259,7 @@ end_flip() {
     //wdxdisplay9_cat.debug() << "current swapchain from end_flip is " << _wcontext.pSwapChain << "\n";
     _dxgsg->show_frame();
   }
+  GraphicsWindow::end_flip();
 }
 
 ////////////////////////////////////////////////////////////////////

+ 1 - 1
panda/src/glxdisplay/glxGraphicsWindow.cxx

@@ -147,7 +147,7 @@ begin_flip() {
     // context is current before flipping the windows, and insisting
     // on doing so can be a significant performance hit.
 
-    //    make_current();
+    //make_current();
 
     glXSwapBuffers(_display, _xwindow);
   }