فهرست منبع

Buffer overhaul phase one

Josh Yelon 20 سال پیش
والد
کامیت
b665a3707d

+ 5 - 3
panda/src/osxdisplay/osxGraphicsBuffer.cxx

@@ -30,10 +30,12 @@ TypeHandle osxGraphicsBuffer::_type_handle;
 //  Description:
 ////////////////////////////////////////////////////////////////////
 osxGraphicsBuffer::
-osxGraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
+osxGraphicsBuffer(GraphicsPipe *pipe,
                   const string &name,
-                  int x_size, int y_size) :
-  GraphicsBuffer(pipe, gsg, name, x_size, y_size) 
+                  int x_size, int y_size, int flags,
+                  GraphicsStateGuardian *gsg,
+                  GraphicsOutput *host) :
+  GraphicsBuffer(pipe, name, x_size, y_size, flags, gsg, host)
 {
   osxGraphicsPipe *osx_pipe;
   DCAST_INTO_V(osx_pipe, _pipe);

+ 4 - 2
panda/src/osxdisplay/osxGraphicsBuffer.h

@@ -34,9 +34,11 @@
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDAGL osxGraphicsBuffer : public GraphicsBuffer {
 public:
-  osxGraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
+  osxGraphicsBuffer(GraphicsPipe *pipe, 
                     const string &name,
-                    int x_size, int y_size);
+                    int x_size, int y_size, int flags,
+                    GraphicsStateGuardian *gsg,
+                    GraphicsOutput *host);
   virtual ~osxGraphicsBuffer();
 
 

+ 65 - 15
panda/src/osxdisplay/osxGraphicsPipe.cxx

@@ -109,24 +109,74 @@ make_gsg(const FrameBufferProperties &properties,
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: osxGraphicsPipe::make_window
+//     Function: osxGraphicsPipe::make_output
 //       Access: Protected, Virtual
 //  Description: Creates a new window on the pipe, if possible.
 ////////////////////////////////////////////////////////////////////
-PT(GraphicsWindow) osxGraphicsPipe::
-make_window(GraphicsStateGuardian *gsg, const string &name) {
-  return new osxGraphicsWindow(this, gsg, name);
-}
+PT(GraphicsOutput) osxGraphicsPipe::
+make_output(const string &name,
+            int x_size, int y_size, int flags,
+            GraphicsStateGuardian *gsg,
+            GraphicsOutput *host,
+            int retry,
+            bool precertify) {
+  
+  if (!_is_valid) {
+    return NULL;
+  }
 
-////////////////////////////////////////////////////////////////////
-//     Function: osxGraphicsPipe::make_buffer
-//       Access: Protected, Virtual
-//  Description: Creates a new offscreen buffer on the pipe, if possible.
-////////////////////////////////////////////////////////////////////
-PT(GraphicsBuffer) osxGraphicsPipe::
-make_buffer(GraphicsStateGuardian *gsg, const string &name,
-            int x_size, int y_size) {
-  return new osxGraphicsBuffer(this, gsg, name, x_size, y_size);
-}
+  osxGraphicsStateGuardian *osxgsg;
+  DCAST_INTO_R(osxgsg, gsg, NULL);
 
+  // First thing to try: a osxGraphicsWindow
+
+  if (retry == 0) {
+    if (((flags&BF_require_parasite)!=0)||
+        ((flags&BF_refuse_window)!=0)||
+        ((flags&BF_need_aux_rgba_MASK)!=0)||
+        ((flags&BF_need_aux_hrgba_MASK)!=0)||
+        ((flags&BF_need_aux_float_MASK)!=0)||
+        ((flags&BF_size_track_host)!=0)||
+        ((flags&BF_can_bind_color)!=0)||
+        ((flags&BF_can_bind_every)!=0)) {
+      return NULL;
+    }
+    return new osxGraphicsWindow(this, name, x_size, y_size, flags, gsg, host);
+  }
+  
+  //  // Second thing to try: a glGraphicsBuffer
+  //  
+  //  if (retry == 1) {
+  //    if ((!support_render_texture)||
+  //        ((flags&BF_require_parasite)!=0)||
+  //        ((flags&BF_require_window)!=0)) {
+  //      return NULL;
+  //    }
+  //    if (precertify) {
+  //      if (!osxgsg->_supports_framebuffer_object) {
+  //        return NULL;
+  //      }
+  //    }
+  //    return new glGraphicsBuffer(this, name, x_size, y_size, flags, gsg, host);
+  //  }
+  
+  // Third thing to try: an osxGraphicsBuffer
+  
+  if (retry == 2) {
+    if ((!support_render_texture)||
+        ((flags&BF_require_parasite)!=0)||
+        ((flags&BF_require_window)!=0)||
+        ((flags&BF_need_aux_rgba_MASK)!=0)||
+        ((flags&BF_need_aux_hrgba_MASK)!=0)||
+        ((flags&BF_need_aux_float_MASK)!=0)||
+        ((flags&BF_size_track_host)!=0)||
+        ((flags&BF_can_bind_every)!=0)) {
+      return NULL;
+    }
+    return new osxGraphicsBuffer(this, name, x_size, y_size, flags, gsg, host);
+  }
+  
+  // Nothing else left to try.
+  return NULL;
+}
 

+ 7 - 5
panda/src/osxdisplay/osxGraphicsPipe.h

@@ -38,11 +38,13 @@ public:
 protected:
   virtual PT(GraphicsStateGuardian) make_gsg(const FrameBufferProperties &properties,
                                              GraphicsStateGuardian *share_with);
-  virtual PT(GraphicsWindow) make_window(GraphicsStateGuardian *gsg,
-                                         const string &name);
-  virtual PT(GraphicsBuffer) make_buffer(GraphicsStateGuardian *gsg, 
-                                         const string &name,
-                                         int x_size, int y_size);
+  virtual PT(GraphicsOutput) make_output(const string &name,
+                                         int x_size, int y_size, int flags,
+                                         GraphicsStateGuardian *gsg,
+                                         GraphicsOutput *host,
+                                         int retry,
+                                         bool precertify);
+
 private:
  public:
   static TypeHandle get_class_type() {

+ 7 - 3
panda/src/osxdisplay/osxGraphicsWindow.cxx

@@ -391,9 +391,13 @@ OSStatus osxGraphicsWindow::handleTextInput (EventHandlerCallRef myHandler, Even
 //       Access: Public
 //  Description:
 ////////////////////////////////////////////////////////////////////
-osxGraphicsWindow::osxGraphicsWindow(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
-                  const string &name) :
-  GraphicsWindow(pipe, gsg, name) ,
+osxGraphicsWindow::
+osxGraphicsWindow(GraphicsPipe *pipe, 
+                  const string &name,
+                  int x_size, int y_size, int flags,
+                  GraphicsStateGuardian *gsg,
+                  GraphicsOutput *host) :
+  GraphicsWindow(pipe, name, x_size, y_size, flags, gsg, host),
   _osx_window(NULL),
   _is_fullsreen(false),
 #ifdef HACK_SCREEN_HASH_CONTEXT  

+ 5 - 2
panda/src/osxdisplay/osxGraphicsWindow.h

@@ -39,8 +39,11 @@ OSStatus aglReportError (void);
 ////////////////////////////////////////////////////////////////////
 class osxGraphicsWindow : public GraphicsWindow {
 public:
-  osxGraphicsWindow(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
-                    const string &name);
+  osxGraphicsWindow(GraphicsPipe *pipe, 
+                    const string &name,
+                    int x_size, int y_size, int flags,
+                    GraphicsStateGuardian *gsg,
+                    GraphicsOutput *host);
   virtual ~osxGraphicsWindow();
 
   virtual bool move_pointer(int device, int x, int y);