|
| 1 | +diff --git a/src/rviz_rendering/ogre_render_window_impl.cpp b/src/rviz_rendering/ogre_render_window_impl.cpp |
| 2 | +index 466e1d1e4..8fcd56d57 100644 |
| 3 | +--- a/src/rviz_rendering/ogre_render_window_impl.cpp |
| 4 | ++++ b/src/rviz_rendering/ogre_render_window_impl.cpp |
| 5 | +@@ -235,12 +235,21 @@ void |
| 6 | + RenderWindowImpl::resize(size_t width, size_t height) |
| 7 | + { |
| 8 | + if (ogre_render_window_) { |
| 9 | +- this->setCameraAspectRatio(); |
| 10 | +- ogre_render_window_->resize( |
| 11 | +- static_cast<unsigned int>(width), // NOLINT |
| 12 | +- static_cast<unsigned int>(height) // NOLINT |
| 13 | +- ); |
| 14 | +- ogre_render_window_->windowMovedOrResized(); |
| 15 | ++ // Skip the costly Ogre resize / windowMovedOrResized when the size has |
| 16 | ++ // not actually changed. On macOS Sonoma+, windowMovedOrResized triggers |
| 17 | ++ // [NSOpenGLContext update] -> CGLSetVirtualScreen, which is hundreds of |
| 18 | ++ // ms per call under the OpenGL-on-Metal compatibility path; each call |
| 19 | ++ // also re-fires an expose event, so calling it on every expose creates |
| 20 | ++ // a positive-feedback loop that makes the splash screen never progress. |
| 21 | ++ const auto w = static_cast<unsigned int>(width); |
| 22 | ++ const auto h = static_cast<unsigned int>(height); |
| 23 | ++ if (w != last_resize_width_ || h != last_resize_height_) { |
| 24 | ++ last_resize_width_ = w; |
| 25 | ++ last_resize_height_ = h; |
| 26 | ++ this->setCameraAspectRatio(); |
| 27 | ++ ogre_render_window_->resize(w, h); |
| 28 | ++ ogre_render_window_->windowMovedOrResized(); |
| 29 | ++ } |
| 30 | + } |
| 31 | + this->renderLater(); |
| 32 | + } |
| 33 | +diff --git a/src/rviz_rendering/ogre_render_window_impl.hpp b/src/rviz_rendering/ogre_render_window_impl.hpp |
| 34 | +index 7bd7b2238..8391498fe 100644 |
| 35 | +--- a/src/rviz_rendering/ogre_render_window_impl.hpp |
| 36 | ++++ b/src/rviz_rendering/ogre_render_window_impl.hpp |
| 37 | +@@ -150,6 +150,9 @@ protected: |
| 38 | + |
| 39 | + bool animating_; |
| 40 | + |
| 41 | ++ unsigned int last_resize_width_{0}; |
| 42 | ++ unsigned int last_resize_height_{0}; |
| 43 | ++ |
| 44 | + Ogre::Viewport * ogre_viewport_; |
| 45 | + |
| 46 | + // std::function<void()> pre_render_callback_; ///< Functor which is called before each render |
0 commit comments