From e630a6be5583ceb38e806904a6aad1cebf493363 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 20 Dec 2015 14:42:18 -1000 Subject: [PATCH] blocking resize to keep OS in sync with boo buffers --- specter/include/Specter/DeferredWindowEvents.hpp | 2 ++ specter/lib/RootView.cpp | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/specter/include/Specter/DeferredWindowEvents.hpp b/specter/include/Specter/DeferredWindowEvents.hpp index 9af84ef93..1d14c4080 100644 --- a/specter/include/Specter/DeferredWindowEvents.hpp +++ b/specter/include/Specter/DeferredWindowEvents.hpp @@ -11,6 +11,7 @@ struct DeferredWindowEvents : public boo::IWindowCallback { Receiver& m_rec; std::mutex m_mt; + std::condition_variable m_resizeCv; DeferredWindowEvents(Receiver& rec) : m_rec(rec) {} bool m_destroyed = false; @@ -26,6 +27,7 @@ struct DeferredWindowEvents : public boo::IWindowCallback std::unique_lock lk(m_mt); m_latestResize = rect; m_hasResize = true; + m_resizeCv.wait_for(lk, std::chrono::milliseconds(500)); } struct Command diff --git a/specter/lib/RootView.cpp b/specter/lib/RootView.cpp index fb474402c..de44bc4f8 100644 --- a/specter/lib/RootView.cpp +++ b/specter/lib/RootView.cpp @@ -23,7 +23,6 @@ void RootView::destroyed() void RootView::resized(const boo::SWindowRect& root, const boo::SWindowRect&) { - boo::SWindowRect old = m_rootRect; m_rootRect = root; m_rootRect.location[0] = 0; m_rootRect.location[1] = 0; @@ -32,8 +31,7 @@ void RootView::resized(const boo::SWindowRect& root, const boo::SWindowRect&) m_view->resized(m_rootRect, m_rootRect); if (m_tooltip) m_tooltip->resized(m_rootRect, m_rootRect); - if (old != m_rootRect) - m_resizeRTDirty = true; + m_resizeRTDirty = true; } void RootView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mods) @@ -182,6 +180,7 @@ void RootView::draw(boo::IGraphicsCommandQueue* gfxQ) { gfxQ->resizeRenderTexture(m_renderTex, m_rootRect.size[0], m_rootRect.size[1]); m_resizeRTDirty = false; + gfxQ->schedulePostFrameHandler([&](){m_events.m_resizeCv.notify_one();}); } gfxQ->setRenderTarget(m_renderTex); gfxQ->setViewport(m_rootRect);