synchronized refresh timer at 30fps, remove osx frame limiter hack

- Tuning, Gain and Mode selector canvases no longer refresh unless
necessary
- Hopefully resolves refresh issues on El Capitan and others
This commit is contained in:
Charles J. Cliffe 2015-08-08 13:26:53 -04:00
parent bab2ad3780
commit 9d4f933758
12 changed files with 95 additions and 68 deletions

View File

@ -35,10 +35,11 @@ EVT_CLOSE(AppFrame::OnClose)
EVT_MENU(wxID_ANY, AppFrame::OnMenu) EVT_MENU(wxID_ANY, AppFrame::OnMenu)
EVT_COMMAND(wxID_ANY, wxEVT_THREAD, AppFrame::OnThread) EVT_COMMAND(wxID_ANY, wxEVT_THREAD, AppFrame::OnThread)
EVT_IDLE(AppFrame::OnIdle) EVT_IDLE(AppFrame::OnIdle)
EVT_TIMER(FRAME_TIMER_ID, AppFrame::OnTimer)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
AppFrame::AppFrame() : AppFrame::AppFrame() :
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL), frame_timer(this, FRAME_TIMER_ID) {
#ifdef __linux__ #ifdef __linux__
SetIcon(wxICON(cubicsdr)); SetIcon(wxICON(cubicsdr));
@ -350,6 +351,7 @@ AppFrame::AppFrame() :
wxAcceleratorTable accel(3, entries); wxAcceleratorTable accel(3, entries);
SetAcceleratorTable(accel); SetAcceleratorTable(accel);
frame_timer.Start(30);
// static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 }; // static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
// wxLogStatus("Double-buffered display %s supported", wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not"); // wxLogStatus("Double-buffered display %s supported", wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not");
// ShowFullScreen(true); // ShowFullScreen(true);
@ -561,6 +563,10 @@ void AppFrame::OnThread(wxCommandEvent& event) {
} }
void AppFrame::OnIdle(wxIdleEvent& event) { void AppFrame::OnIdle(wxIdleEvent& event) {
event.Skip();
}
void AppFrame::OnTimer(wxTimerEvent& event) {
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
@ -692,6 +698,26 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
dproc->run(); dproc->run();
scopeCanvas->Refresh();
waterfallCanvas->Refresh();
spectrumCanvas->Refresh();
demodWaterfallCanvas->Refresh();
demodSpectrumCanvas->Refresh();
demodSignalMeter->Refresh();
if (demodTuner->getMouseTracker()->mouseInView() || demodTuner->changed()) {
demodTuner->Refresh();
}
if (demodModeSelector->getMouseTracker()->mouseInView()) {
demodModeSelector->Refresh();
}
if (demodGainMeter->getMouseTracker()->mouseInView()) {
demodGainMeter->Refresh();
}
event.Skip(); event.Skip();
} }

View File

@ -50,7 +50,7 @@
#define wxID_AUDIO_BANDWIDTH_BASE 9000 #define wxID_AUDIO_BANDWIDTH_BASE 9000
#define wxID_AUDIO_DEVICE_MULTIPLIER 50 #define wxID_AUDIO_DEVICE_MULTIPLIER 50
#define FRAME_TIMER_ID 1000
// Define a new frame type // Define a new frame type
class AppFrame: public wxFrame { class AppFrame: public wxFrame {
@ -69,6 +69,7 @@ private:
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void OnNewWindow(wxCommandEvent& event); void OnNewWindow(wxCommandEvent& event);
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& event);
void OnTimer(wxTimerEvent& event);
ScopeCanvas *scopeCanvas; ScopeCanvas *scopeCanvas;
SpectrumCanvas *spectrumCanvas; SpectrumCanvas *spectrumCanvas;
@ -93,6 +94,7 @@ private:
wxMenuItem *iqSwapMenuItem; wxMenuItem *iqSwapMenuItem;
std::string currentSessionFile; std::string currentSessionFile;
wxTimer frame_timer;
wxDECLARE_EVENT_TABLE(); wxDECLARE_EVENT_TABLE();
}; };

View File

@ -36,9 +36,6 @@ UITestCanvas::~UITestCanvas() {
void UITestCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void UITestCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this); wxPaintDC dc(this);
#ifdef __APPLE__ // force half-rate?
glFinish();
#endif
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
glContext->SetCurrent(*this); glContext->SetCurrent(*this);

View File

@ -60,9 +60,6 @@ float MeterCanvas::getInputValue() {
void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this); wxPaintDC dc(this);
#ifdef __APPLE__ // force half-rate?
glFinish();
#endif
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
glContext->SetCurrent(*this); glContext->SetCurrent(*this);
@ -82,7 +79,7 @@ void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
} }
void MeterCanvas::OnIdle(wxIdleEvent &event) { void MeterCanvas::OnIdle(wxIdleEvent &event) {
Refresh(false); event.Skip();
} }
void MeterCanvas::OnMouseMoved(wxMouseEvent& event) { void MeterCanvas::OnMouseMoved(wxMouseEvent& event) {
@ -115,6 +112,7 @@ void MeterCanvas::OnMouseReleased(wxMouseEvent& event) {
void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) { void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
InteractiveCanvas::OnMouseLeftWindow(event); InteractiveCanvas::OnMouseLeftWindow(event);
SetCursor(wxCURSOR_CROSS); SetCursor(wxCURSOR_CROSS);
Refresh();
} }
void MeterCanvas::OnMouseEnterWindow(wxMouseEvent& event) { void MeterCanvas::OnMouseEnterWindow(wxMouseEvent& event) {

View File

@ -47,9 +47,6 @@ int ModeSelectorCanvas::getHoveredSelection() {
void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this); wxPaintDC dc(this);
#ifdef __APPLE__ // force half-rate?
glFinish();
#endif
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
glContext->SetCurrent(*this); glContext->SetCurrent(*this);
@ -75,7 +72,7 @@ void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
} }
void ModeSelectorCanvas::OnIdle(wxIdleEvent &event) { void ModeSelectorCanvas::OnIdle(wxIdleEvent &event) {
Refresh(false); event.Skip();
} }
void ModeSelectorCanvas::OnMouseMoved(wxMouseEvent& event) { void ModeSelectorCanvas::OnMouseMoved(wxMouseEvent& event) {
@ -109,6 +106,7 @@ void ModeSelectorCanvas::OnMouseReleased(wxMouseEvent& event) {
void ModeSelectorCanvas::OnMouseLeftWindow(wxMouseEvent& event) { void ModeSelectorCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
InteractiveCanvas::OnMouseLeftWindow(event); InteractiveCanvas::OnMouseLeftWindow(event);
SetCursor (wxCURSOR_CROSS); SetCursor (wxCURSOR_CROSS);
Refresh();
} }
void ModeSelectorCanvas::OnMouseEnterWindow(wxMouseEvent& event) { void ModeSelectorCanvas::OnMouseEnterWindow(wxMouseEvent& event) {

View File

@ -50,9 +50,6 @@ bool ScopeCanvas::getPPMMode() {
void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this); wxPaintDC dc(this);
#ifdef __APPLE__ // force half-rate?
glFinish();
#endif
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
wxGetApp().getScopeProcessor()->run(); wxGetApp().getScopeProcessor()->run();
@ -94,7 +91,7 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
} }
void ScopeCanvas::OnIdle(wxIdleEvent &event) { void ScopeCanvas::OnIdle(wxIdleEvent &event) {
Refresh(false); event.Skip();
} }
ScopeRenderDataQueue *ScopeCanvas::getInputQueue() { ScopeRenderDataQueue *ScopeCanvas::getInputQueue() {

View File

@ -42,15 +42,9 @@ SpectrumCanvas::~SpectrumCanvas() {
void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this); wxPaintDC dc(this);
#ifdef __APPLE__ // force half-rate?
glFinish();
#endif
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
if (visualDataQueue.empty()) { if (!visualDataQueue.empty()) {
return;
}
SpectrumVisualData *vData; SpectrumVisualData *vData;
visualDataQueue.pop(vData); visualDataQueue.pop(vData);
@ -62,6 +56,8 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
spectrum_points.assign(vData->spectrum_points.begin(),vData->spectrum_points.end()); spectrum_points.assign(vData->spectrum_points.begin(),vData->spectrum_points.end());
vData->decRefCount(); vData->decRefCount();
}
glContext->SetCurrent(*this); glContext->SetCurrent(*this);
initGLExtensions(); initGLExtensions();
@ -84,7 +80,7 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
void SpectrumCanvas::OnIdle(wxIdleEvent &event) { void SpectrumCanvas::OnIdle(wxIdleEvent &event) {
Refresh(false); event.Skip();
} }

View File

@ -31,7 +31,7 @@ EVT_KEY_UP(TuningCanvas::OnKeyUp)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) : TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) :
InteractiveCanvas(parent, attribList), dragAccum(0), uxDown(0), top(false), bottom(false) { InteractiveCanvas(parent, attribList), dragAccum(0), uxDown(0), top(false), bottom(false), freq(-1), bw(-1), center(-1) {
glContext = new TuningContext(this, &wxGetApp().GetContext(this)); glContext = new TuningContext(this, &wxGetApp().GetContext(this));
@ -57,11 +57,25 @@ TuningCanvas::~TuningCanvas() {
} }
bool TuningCanvas::changed() {
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
long long current_freq = 0;
if (activeDemod != NULL) {
freq = activeDemod->getFrequency();
}
long long current_bw = wxGetApp().getDemodMgr().getLastBandwidth();
long long current_center = wxGetApp().getFrequency();
if (current_freq != freq || current_bw != bw || current_center != center) {
return true;
}
return false;
}
void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this); wxPaintDC dc(this);
#ifdef __APPLE__ // force half-rate?
glFinish();
#endif
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
glContext->SetCurrent(*this); glContext->SetCurrent(*this);
@ -72,12 +86,12 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
long long freq = 0; freq = 0;
if (activeDemod != NULL) { if (activeDemod != NULL) {
freq = activeDemod->getFrequency(); freq = activeDemod->getFrequency();
} }
long long bw = wxGetApp().getDemodMgr().getLastBandwidth(); bw = wxGetApp().getDemodMgr().getLastBandwidth();
long long center = wxGetApp().getFrequency(); center = wxGetApp().getFrequency();
if (mouseTracker.mouseDown()) { if (mouseTracker.mouseDown()) {
glContext->Draw(ThemeMgr::mgr.currentTheme->tuningBarDark.r, ThemeMgr::mgr.currentTheme->tuningBarDark.g, ThemeMgr::mgr.currentTheme->tuningBarDark.b, glContext->Draw(ThemeMgr::mgr.currentTheme->tuningBarDark.r, ThemeMgr::mgr.currentTheme->tuningBarDark.g, ThemeMgr::mgr.currentTheme->tuningBarDark.b,
@ -238,8 +252,6 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) {
dragging = false; dragging = false;
} }
} }
Refresh(false);
} }
void TuningCanvas::OnMouseMoved(wxMouseEvent& event) { void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
@ -373,6 +385,7 @@ void TuningCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
if (currentPPM != lastPPM) { if (currentPPM != lastPPM) {
wxGetApp().saveConfig(); wxGetApp().saveConfig();
} }
Refresh();
} }
void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) { void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) {

View File

@ -22,6 +22,7 @@ public:
~TuningCanvas(); ~TuningCanvas();
void setHelpTip(std::string tip); void setHelpTip(std::string tip);
bool changed();
private: private:
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
@ -66,6 +67,7 @@ private:
int currentPPM; int currentPPM;
int lastPPM; int lastPPM;
long long freq, bw, center;
// //
wxDECLARE_EVENT_TABLE(); wxDECLARE_EVENT_TABLE();
}; };

View File

@ -70,9 +70,6 @@ void WaterfallCanvas::attachSpectrumCanvas(SpectrumCanvas *canvas_in) {
void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this); wxPaintDC dc(this);
#ifdef __APPLE__ // force half-rate?
glFinish();
#endif
const wxSize ClientSize = GetClientSize(); const wxSize ClientSize = GetClientSize();
long double currentZoom = zoom; long double currentZoom = zoom;
@ -139,10 +136,8 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
} }
} }
if (visualDataQueue.empty()) { bool step = false;
return; if (!visualDataQueue.empty()) {
}
SpectrumVisualData *vData; SpectrumVisualData *vData;
visualDataQueue.pop(vData); visualDataQueue.pop(vData);
@ -154,13 +149,16 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
spectrum_points.assign(vData->spectrum_points.begin(),vData->spectrum_points.end()); spectrum_points.assign(vData->spectrum_points.begin(),vData->spectrum_points.end());
vData->decRefCount(); vData->decRefCount();
step = true;
}
glContext->SetCurrent(*this); glContext->SetCurrent(*this);
initGLExtensions(); initGLExtensions();
glViewport(0, 0, ClientSize.x, ClientSize.y); glViewport(0, 0, ClientSize.x, ClientSize.y);
glContext->BeginDraw(0,0,0); glContext->BeginDraw(0,0,0);
glContext->Draw(spectrum_points); glContext->Draw(spectrum_points, step);
std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators(); std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators();
@ -352,7 +350,7 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
} }
} }
void WaterfallCanvas::OnIdle(wxIdleEvent &event) { void WaterfallCanvas::OnIdle(wxIdleEvent &event) {
Refresh(false); event.Skip();
} }
void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) { void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {

View File

@ -36,7 +36,7 @@ void WaterfallContext::refreshTheme() {
} }
} }
void WaterfallContext::Draw(std::vector<float> &points) { void WaterfallContext::Draw(std::vector<float> &points, bool step) {
int half_fft_size = fft_size / 2; int half_fft_size = fft_size / 2;

View File

@ -10,7 +10,7 @@ class WaterfallContext: public PrimaryGLContext {
public: public:
WaterfallContext(WaterfallCanvas *canvas, wxGLContext *sharedContext); WaterfallContext(WaterfallCanvas *canvas, wxGLContext *sharedContext);
void Draw(std::vector<float> &points); void Draw(std::vector<float> &points, bool step);
void Setup(int fft_size_in, int num_waterfall_lines_in); void Setup(int fft_size_in, int num_waterfall_lines_in);
void refreshTheme(); void refreshTheme();