瀏覽代碼

GraphicsEngine::get_render_lock()

David Rose 14 年之前
父節點
當前提交
f110a269c8
共有 3 個文件被更改,包括 18 次插入0 次删除
  1. 14 0
      panda/src/display/graphicsEngine.I
  2. 1 0
      panda/src/display/graphicsEngine.cxx
  3. 3 0
      panda/src/display/graphicsEngine.h

+ 14 - 0
panda/src/display/graphicsEngine.I

@@ -13,6 +13,20 @@
 ////////////////////////////////////////////////////////////////////
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsEngine::get_render_lock
+//       Access: Published
+//  Description: Returns a ReMutex object that is held by the
+//               GraphicsEngine during the entire call to
+//               render_frame().  While you hold this lock you can be
+//               confident that no part of the frame will be rendered
+//               (at least by the app thread).
+////////////////////////////////////////////////////////////////////
+INLINE const ReMutex &GraphicsEngine::
+get_render_lock() const {
+  return _public_lock;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsEngine::set_auto_flip
 //       Access: Published

+ 1 - 0
panda/src/display/graphicsEngine.cxx

@@ -645,6 +645,7 @@ get_window(int n) const {
 void GraphicsEngine::
 render_frame() {
   Thread *current_thread = Thread::get_current_thread();
+  ReMutexHolder public_holder(_public_lock);
 
   // Since this gets called every frame, we should take advantage of
   // the opportunity to flush the cache if necessary.

+ 3 - 0
panda/src/display/graphicsEngine.h

@@ -63,6 +63,8 @@ PUBLISHED:
   void set_threading_model(const GraphicsThreadingModel &threading_model);
   GraphicsThreadingModel get_threading_model() const;
 
+  INLINE const ReMutex &get_render_lock() const;
+
   INLINE void set_auto_flip(bool auto_flip);
   INLINE bool get_auto_flip() const;
 
@@ -325,6 +327,7 @@ private:
   bool _singular_warning_this_frame;
 
   ReMutex _lock;
+  ReMutex _public_lock;
 
   class LoadedTexture {
   public: