Change by-ref passed float or bool parameters to callbacks in public API

* Mostly used for passing a progress float back during a long blocking
  call like opening a capture or doing a copy.
* This is much more feasible for python to bind to.
* In several cases we just use a tiny lambda that updates a float anyway
  since we can't push the progress directly into a progress dialog, but
  need to let it query from a temporary in-between float.
This commit is contained in:
baldurk
2018-01-01 17:31:23 +00:00
parent 2e74989b69
commit 7a2305ae31
24 changed files with 212 additions and 154 deletions
@@ -27,7 +27,7 @@
#include "serialise/rdcfile.h"
ReplayStatus exportChrome(const char *filename, const RDCFile &rdc, const SDFile &structData,
float *progress)
RENDERDOC_ProgressCallback progress)
{
FILE *f = FileIO::fopen(filename, "w");
@@ -46,6 +46,9 @@ ReplayStatus exportChrome(const char *filename, const RDCFile &rdc, const SDFile
// stupid JSON not allowing trailing ,s :(
bool first = true;
int i = 0;
int numChunks = structData.chunks.count();
for(const SDChunk *chunk : structData.chunks)
{
if(chunk->metadata.chunkID == (uint32_t)SystemChunk::FirstDriverChunk + 1)
@@ -69,8 +72,16 @@ ReplayStatus exportChrome(const char *filename, const RDCFile &rdc, const SDFile
str += StringFormat::Fmt(
fmt, chunk->name.c_str(), category, chunk->metadata.timestampMicro, chunk->metadata.threadID,
chunk->metadata.timestampMicro + chunk->metadata.durationMicro, chunk->metadata.threadID);
if(progress)
progress(float(i) / float(numChunks));
i++;
}
if(progress)
progress(1.0f);
// end trace events
str += "\n ]\n}";