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_COMMAND(wxID_ANY, wxEVT_THREAD, AppFrame::OnThread)
EVT_IDLE(AppFrame::OnIdle)
EVT_TIMER(FRAME_TIMER_ID, AppFrame::OnTimer)
wxEND_EVENT_TABLE()
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__
SetIcon(wxICON(cubicsdr));
@ -350,6 +351,7 @@ AppFrame::AppFrame() :
wxAcceleratorTable accel(3, entries);
SetAcceleratorTable(accel);
frame_timer.Start(30);
// static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
// wxLogStatus("Double-buffered display %s supported", wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not");
// ShowFullScreen(true);
@ -561,6 +563,10 @@ void AppFrame::OnThread(wxCommandEvent& event) {
}
void AppFrame::OnIdle(wxIdleEvent& event) {
event.Skip();
}
void AppFrame::OnTimer(wxTimerEvent& event) {
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
@ -692,6 +698,26 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
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();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,7 +31,7 @@ EVT_KEY_UP(TuningCanvas::OnKeyUp)
wxEND_EVENT_TABLE()
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));
@ -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)) {
wxPaintDC dc(this);
#ifdef __APPLE__ // force half-rate?
glFinish();
#endif
const wxSize ClientSize = GetClientSize();
glContext->SetCurrent(*this);
@ -72,12 +86,12 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
long long freq = 0;
freq = 0;
if (activeDemod != NULL) {
freq = activeDemod->getFrequency();
}
long long bw = wxGetApp().getDemodMgr().getLastBandwidth();
long long center = wxGetApp().getFrequency();
bw = wxGetApp().getDemodMgr().getLastBandwidth();
center = wxGetApp().getFrequency();
if (mouseTracker.mouseDown()) {
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;
}
}
Refresh(false);
}
void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
@ -373,6 +385,7 @@ void TuningCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
if (currentPPM != lastPPM) {
wxGetApp().saveConfig();
}
Refresh();
}
void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) {

View File

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

View File

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

View File

@ -10,7 +10,7 @@ class WaterfallContext: public PrimaryGLContext {
public:
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 refreshTheme();