mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-08 16:50:44 +00:00
Reference count FrameCapturers. Closes #108
This commit is contained in:
+41
-3
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user