From f110a269c8e77cad74d6ae38b3d335d72e9ac119 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 3 Jan 2012 03:05:54 +0000 Subject: [PATCH] GraphicsEngine::get_render_lock() --- panda/src/display/graphicsEngine.I | 14 ++++++++++++++ panda/src/display/graphicsEngine.cxx | 1 + panda/src/display/graphicsEngine.h | 3 +++ 3 files changed, 18 insertions(+) diff --git a/panda/src/display/graphicsEngine.I b/panda/src/display/graphicsEngine.I index 3d11ab325d..a634c71ca7 100644 --- a/panda/src/display/graphicsEngine.I +++ b/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 diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 552f6b78bf..43156a37af 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/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. diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index 2a3a5233e3..7428a35da1 100644 --- a/panda/src/display/graphicsEngine.h +++ b/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: