Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8d6cbcdd425f
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 56c99a5bcccf
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Sep 5, 2020

  1. Copy the full SHA
    8f36d81 View commit details
  2. Copy the full SHA
    56c99a5 View commit details
Showing with 42 additions and 27 deletions.
  1. +25 −27 src/glscopeclient/OscilloscopeWindow.cpp
  2. +11 −0 src/glscopeclient/OscilloscopeWindow.h
  3. +6 −0 src/glscopeclient/WaveformArea_rendering.cpp
52 changes: 25 additions & 27 deletions src/glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ OscilloscopeWindow::OscilloscopeWindow(vector<Oscilloscope*> scopes, bool nodigi
, m_haltConditionsDialog(this)
, m_triggerArmed(false)
, m_shuttingDown(false)
, m_loadInProgress(false)
{
SetTitle();

@@ -528,6 +529,8 @@ void OscilloscopeWindow::DoFileOpen(string filename, bool loadLayout, bool loadW
{
m_currentFileName = filename;

m_loadInProgress = true;

CloseSession();

//Clear performance counters
@@ -632,6 +635,10 @@ void OscilloscopeWindow::DoFileOpen(string filename, bool loadLayout, bool loadW

//Start threads to poll scopes etc
g_app->StartScopeThreads();

//Done loading, we can render everything for good now
m_loadInProgress = false;
ClearAllPersistence();
}

/**
@@ -772,42 +779,33 @@ void OscilloscopeWindow::LoadWaveformDataForScope(
unsigned char* buf = new unsigned char[len];
fread(buf, 1, len, fp);

for(long offset=0; offset<len; )
//Figure out how many samples we have
size_t samplesize = 2*sizeof(int64_t);
if(acap)
samplesize += sizeof(float);
else
samplesize += sizeof(bool);
size_t nsamples = len / samplesize;
cap->Resize(nsamples);

//TODO: AVX this?
for(size_t j=0; j<nsamples; j++)
{
long end = offset + 2*sizeof(int64_t);
if(end > len)
break;
size_t offset = j*samplesize;

//Read start time and duration
int64_t* stime = reinterpret_cast<int64_t*>(buf+offset);
offset = end;
offset += 2*sizeof(int64_t);

cap->m_offsets[j] = stime[0];
cap->m_durations[j] = stime[1];

//Read sample data
if(acap)
{
end = offset + sizeof(float);
if(end > len)
break;
float* f = reinterpret_cast<float*>(buf+offset);
offset = end;

acap->m_offsets.push_back(stime[0]);
acap->m_durations.push_back(stime[1]);
acap->m_samples.push_back(*f);
}
acap->m_samples[j] = *reinterpret_cast<float*>(buf+offset);

else
{
end = offset + sizeof(bool);
if(end > len)
break;
bool *b = reinterpret_cast<bool*>(buf+offset);
offset = end;

dcap->m_offsets.push_back(stime[0]);
dcap->m_durations.push_back(stime[1]);
dcap->m_samples.push_back(*b);
}
dcap->m_samples[j] = *reinterpret_cast<bool*>(buf+offset);
}

delete[] buf;
11 changes: 11 additions & 0 deletions src/glscopeclient/OscilloscopeWindow.h
Original file line number Diff line number Diff line change
@@ -116,6 +116,14 @@ class OscilloscopeWindow : public Gtk::Window
//Clean up the sync wizard
void OnSyncComplete();

/**
@brief Checks if a file load is in progress.
Spurious render etc events may be dispatched during loading and should be ignored for best performance
*/
bool IsLoadInProgress()
{ return m_loadInProgress; }

protected:
void SetTitle();

@@ -276,6 +284,9 @@ class OscilloscopeWindow : public Gtk::Window

//True if shutting down (don't process any more updates after this point
bool m_shuttingDown;

//True if file load is in progress
bool m_loadInProgress;
};

#endif
6 changes: 6 additions & 0 deletions src/glscopeclient/WaveformArea_rendering.cpp
Original file line number Diff line number Diff line change
@@ -319,6 +319,12 @@ void WaveformArea::UnmapAllBuffers()

bool WaveformArea::on_render(const Glib::RefPtr<Gdk::GLContext>& /*context*/)
{
//If a file load is in progress don't waste time on expensive render calls.
//Many render events get dispatched as various parts of the UI config and waveform data load,
//and we only want to actually draw on the very last one.
if(m_parent->IsLoadInProgress())
return true;

LogIndenter li;

double start = GetTime();