Reference count FrameCapturers. Closes #108

This commit is contained in:
baldurk
2014-11-18 21:49:29 +00:00
parent ea9a81e44f
commit dea6b64e0b
2 changed files with 51 additions and 6 deletions
+41 -3
View File
@@ -282,7 +282,7 @@ void RenderDoc::StartFrameCapture(void *wnd)
return;
}
it->second->StartFrameCapture(wnd);
it->second.FrameCapturer->StartFrameCapture(wnd);
}
void RenderDoc::SetActiveWindow(void *wnd)
@@ -294,7 +294,7 @@ void RenderDoc::SetActiveWindow(void *wnd)
return;
}
it->second->SetActiveWindow(wnd);
it->second.FrameCapturer->SetActiveWindow(wnd);
}
bool RenderDoc::EndFrameCapture(void *wnd)
@@ -306,7 +306,7 @@ bool RenderDoc::EndFrameCapture(void *wnd)
return false;
}
return it->second->EndFrameCapture(wnd);
return it->second.FrameCapturer->EndFrameCapture(wnd);
}
void RenderDoc::Tick()
@@ -661,3 +661,41 @@ void RenderDoc::SuccessfullyWrittenLog()
m_Captures.push_back(cap);
}
}
void RenderDoc::AddFrameCapturer(void *wnd, IFrameCapturer *cap)
{
if(wnd == NULL || cap == NULL)
{
RDCERR("Invalid FrameCapturer combination: %#p / %#p", wnd, cap);
return;
}
auto it = m_WindowFrameCapturers.find(wnd);
if(it != m_WindowFrameCapturers.end())
{
if(it->second.FrameCapturer != cap)
RDCERR("New different FrameCapturer being registered for known window!");
it->second.RefCount++;
}
else
{
m_WindowFrameCapturers[wnd].FrameCapturer = cap;
}
}
void RenderDoc::RemoveFrameCapturer(void *wnd)
{
auto it = m_WindowFrameCapturers.find(wnd);
if(it != m_WindowFrameCapturers.end())
{
it->second.RefCount--;
if(it->second.RefCount <= 0)
m_WindowFrameCapturers.erase(it);
}
else
{
RDCERR("Removing FrameCapturer for unknown window!");
}
}
+10 -3
View File
@@ -232,8 +232,8 @@ class RenderDoc
void Tick();
void AddFrameCapturer(void *wnd, IFrameCapturer *cap) { if(wnd != NULL && cap != NULL) m_WindowFrameCapturers[wnd] = cap; }
void RemoveFrameCapturer(void *wnd) { m_WindowFrameCapturers.erase(wnd); }
void AddFrameCapturer(void *wnd, IFrameCapturer *cap);
void RemoveFrameCapturer(void *wnd);
void StartFrameCapture(void *wnd);
void SetActiveWindow(void *wnd);
@@ -306,7 +306,14 @@ class RenderDoc
map<RDCDriver, ReplayDriverProvider> m_ReplayDriverProviders;
map<RDCDriver, RemoteDriverProvider> m_RemoteDriverProviders;
map<void*, IFrameCapturer*> m_WindowFrameCapturers;
struct FrameCap
{
FrameCap() : FrameCapturer(NULL), RefCount(1) {}
IFrameCapturer *FrameCapturer;
int RefCount;
};
map<void*, FrameCap> m_WindowFrameCapturers;
volatile bool m_RemoteServerThreadShutdown;
volatile bool m_RemoteClientThreadShutdown;