From d902ea5ce4e084c8dd39d2bd781a463893ba12fa Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 19 Nov 2018 22:13:07 +0100 Subject: [PATCH] display: don't render window if all its DRs are inactive This is an optimization, which will skip begin_frame/end_frame for a buffer that isn't going to have anything rendered to it. Affects the RenderPipeline. --- panda/src/display/graphicsOutput.cxx | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 33bfddb79f..d473b4bee2 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -412,15 +412,38 @@ is_active() const { return false; } - CDReader cdata(_cycler); + CDLockedReader cdata(_cycler); + if (!cdata->_active) { + return false; + } + if (cdata->_one_shot_frame != -1) { // If one_shot is in effect, then we are active only for the one indicated // frame. if (cdata->_one_shot_frame != ClockObject::get_global_clock()->get_frame_count()) { return false; + } else { + return true; } } - return cdata->_active; + + // If the window has a clear value set, it is active. + if (is_any_clear_active()) { + return true; + } + + // If we triggered a copy operation, it is also active. + if (_trigger_copy) { + return true; + } + + // The window is active if at least one display region is active. + if (cdata->_active_display_regions_stale) { + CDWriter cdataw(((GraphicsOutput *)this)->_cycler, cdata, false); + ((GraphicsOutput *)this)->do_determine_display_regions(cdataw); + } + + return !cdata->_active_display_regions.empty(); } /**