From a08e18b505c2f1baa1dcac76dae7991d304a878b Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 12 Dec 2020 20:04:18 +0100 Subject: [PATCH] TVScren: removed clanup() call from destructot. Some code cleanup --- sdrgui/gui/glshadertvarray.cpp | 79 +++++++++++++++++----------------- sdrgui/gui/glshadertvarray.h | 9 ++-- sdrgui/gui/tvscreen.cpp | 11 +++-- sdrgui/gui/tvscreenanalog.cpp | 2 +- 4 files changed, 50 insertions(+), 51 deletions(-) diff --git a/sdrgui/gui/glshadertvarray.cpp b/sdrgui/gui/glshadertvarray.cpp index e3375c46b..32771c57b 100644 --- a/sdrgui/gui/glshadertvarray.cpp +++ b/sdrgui/gui/glshadertvarray.cpp @@ -16,6 +16,7 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// +#include #include const QString GLShaderTVArray::m_strVertexShaderSourceArray = QString( @@ -39,24 +40,24 @@ GLShaderTVArray::GLShaderTVArray(bool blnColor) : m_blnColor(blnColor) { m_blnAlphaBlend = false; m_blnAlphaReset = false; - m_objProgram = 0; - m_objImage = 0; - m_objTexture = 0; + m_objProgram = nullptr; + m_objImage = nullptr; + m_objTexture = nullptr; m_intCols = 0; m_intRows = 0; m_blnInitialized = false; - m_objCurrentRow = 0; + m_objCurrentRow = nullptr; - m_objTextureLoc = 0; - m_objMatrixLoc = 0; + m_textureLoc = 0; + m_matrixLoc = 0; } GLShaderTVArray::~GLShaderTVArray() { - Cleanup(); + cleanup(); } -void GLShaderTVArray::InitializeGL(int intCols, int intRows) +void GLShaderTVArray::initializeGL(int intCols, int intRows) { QMatrix4x4 objQMatrix; @@ -65,9 +66,9 @@ void GLShaderTVArray::InitializeGL(int intCols, int intRows) m_intCols = 0; m_intRows = 0; - m_objCurrentRow = 0; + m_objCurrentRow = nullptr; - if (m_objProgram == 0) + if (!m_objProgram) { m_objProgram = new QOpenGLShaderProgram(); @@ -95,18 +96,18 @@ void GLShaderTVArray::InitializeGL(int intCols, int intRows) } m_objProgram->bind(); - m_objProgram->setUniformValue(m_objMatrixLoc, objQMatrix); - m_objProgram->setUniformValue(m_objTextureLoc, 0); + m_objProgram->setUniformValue(m_matrixLoc, objQMatrix); + m_objProgram->setUniformValue(m_textureLoc, 0); m_objProgram->release(); } - m_objMatrixLoc = m_objProgram->uniformLocation("uMatrix"); - m_objTextureLoc = m_objProgram->uniformLocation("uTexture"); + m_matrixLoc = m_objProgram->uniformLocation("uMatrix"); + m_textureLoc = m_objProgram->uniformLocation("uTexture"); - if (m_objTexture != 0) + if (m_objTexture) { delete m_objTexture; - m_objTexture = 0; + m_objTexture = nullptr; } //Image container @@ -133,7 +134,7 @@ QRgb * GLShaderTVArray::GetRowBuffer(int intRow) return 0; } - if (m_objImage == 0) + if (!m_objImage) { return 0; } @@ -170,13 +171,11 @@ void GLShaderTVArray::RenderPixels(unsigned char *chrData) QRgb *ptrLine; int intVal; - if (!m_blnInitialized) - { + if (!m_blnInitialized) { return; } - if (m_objImage == 0) - { + if (m_objImage) { return; } @@ -210,18 +209,22 @@ void GLShaderTVArray::RenderPixels(unsigned char *chrData) m_objProgram->bind(); - m_objProgram->setUniformValue(m_objMatrixLoc, objQMatrix); - m_objProgram->setUniformValue(m_objTextureLoc, 0); + m_objProgram->setUniformValue(m_matrixLoc, objQMatrix); + m_objProgram->setUniformValue(m_textureLoc, 0); - if (m_blnAlphaReset) { + if (m_blnAlphaReset) + { ptrF->glClear(GL_COLOR_BUFFER_BIT); m_blnAlphaReset = false; } - if (m_blnAlphaBlend) { + if (m_blnAlphaBlend) + { ptrF->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ptrF->glEnable(GL_BLEND); - } else { + } + else + { ptrF->glDisable(GL_BLEND); } @@ -250,45 +253,43 @@ void GLShaderTVArray::RenderPixels(unsigned char *chrData) void GLShaderTVArray::ResetPixels() { - if (m_objImage != 0) - { + if (m_objImage) { m_objImage->fill(0); } } void GLShaderTVArray::ResetPixels(int alpha) { - if (m_objImage != 0) - { + if (m_objImage) { m_objImage->fill(qRgba(0, 0, 0, alpha)); } } -void GLShaderTVArray::Cleanup() +void GLShaderTVArray::cleanup() { m_blnInitialized = false; m_intCols = 0; m_intRows = 0; - m_objCurrentRow = 0; + m_objCurrentRow = nullptr; if (m_objProgram) { delete m_objProgram; - m_objProgram = 0; + m_objProgram = nullptr; } - if (m_objTexture != 0) + if (m_objTexture) { delete m_objTexture; - m_objTexture = 0; + m_objTexture = nullptr; } - if (m_objImage != 0) + if (m_objImage) { delete m_objImage; - m_objImage = 0; + m_objImage = nullptr; } } @@ -305,7 +306,7 @@ bool GLShaderTVArray::SelectRow(int intLine) } else { - m_objCurrentRow = 0; + m_objCurrentRow = nullptr; } } @@ -318,7 +319,7 @@ bool GLShaderTVArray::SetDataColor(int intCol, QRgb objColor) if (m_blnInitialized) { - if ((intCol < m_intCols) && (intCol >= 0) && (m_objCurrentRow != 0)) + if ((intCol < m_intCols) && (intCol >= 0) && (m_objCurrentRow)) { m_objCurrentRow[intCol] = objColor; blnRslt = true; diff --git a/sdrgui/gui/glshadertvarray.h b/sdrgui/gui/glshadertvarray.h index 559a7351f..488acba3c 100644 --- a/sdrgui/gui/glshadertvarray.h +++ b/sdrgui/gui/glshadertvarray.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -46,8 +45,8 @@ public: void setColor(bool blnColor) { m_blnColor = blnColor; } void setAlphaBlend(bool blnAlphaBlend) { m_blnAlphaBlend = blnAlphaBlend; } void setAlphaReset() { m_blnAlphaReset = true; } - void InitializeGL(int intCols, int intRows); - void Cleanup(); + void initializeGL(int intCols, int intRows); + void cleanup(); QRgb *GetRowBuffer(int intRow); void RenderPixels(unsigned char *chrData); void ResetPixels(); @@ -60,8 +59,8 @@ public: protected: QOpenGLShaderProgram *m_objProgram; - int m_objMatrixLoc; - int m_objTextureLoc; + int m_matrixLoc; + int m_textureLoc; //int m_objColorLoc; static const QString m_strVertexShaderSourceArray; static const QString m_strFragmentShaderSourceColored; diff --git a/sdrgui/gui/tvscreen.cpp b/sdrgui/gui/tvscreen.cpp index 26ce7b490..6f51fc951 100644 --- a/sdrgui/gui/tvscreen.cpp +++ b/sdrgui/gui/tvscreen.cpp @@ -36,7 +36,7 @@ TVScreen::TVScreen(bool blnColor, QWidget* parent) : connect(&m_objTimer, SIGNAL(timeout()), this, SLOT(tick())); m_objTimer.start(40); // capped at 25 FPS - m_chrLastData = NULL; + m_chrLastData = nullptr; m_blnConfigChanged = false; m_blnDataChanged = false; m_blnGLContextInitialized = false; @@ -50,7 +50,6 @@ TVScreen::TVScreen(bool blnColor, QWidget* parent) : TVScreen::~TVScreen() { - cleanup(); } void TVScreen::setColor(bool blnColor) @@ -62,7 +61,7 @@ QRgb* TVScreen::getRowBuffer(int intRow) { if (!m_blnGLContextInitialized) { - return NULL; + return nullptr; } return m_objGLShaderArray.GetRowBuffer(intRow); @@ -127,7 +126,7 @@ void TVScreen::initializeGL() QSurface *objSurface = objGlCurrentContext->surface(); - if (objSurface == NULL) + if (objSurface == nullptr) { qCritical() << "TVScreen::initializeGL: no surface attached"; return; @@ -172,7 +171,7 @@ void TVScreen::paintGL() if ((m_intAskedCols != 0) && (m_intAskedRows != 0)) { - m_objGLShaderArray.InitializeGL(m_intAskedCols, m_intAskedRows); + m_objGLShaderArray.initializeGL(m_intAskedCols, m_intAskedRows); m_intAskedCols = 0; m_intAskedRows = 0; } @@ -206,7 +205,7 @@ void TVScreen::cleanup() { if (m_blnGLContextInitialized) { - m_objGLShaderArray.Cleanup(); + m_objGLShaderArray.cleanup(); } } diff --git a/sdrgui/gui/tvscreenanalog.cpp b/sdrgui/gui/tvscreenanalog.cpp index ffe31c2ce..6c196aead 100644 --- a/sdrgui/gui/tvscreenanalog.cpp +++ b/sdrgui/gui/tvscreenanalog.cpp @@ -112,7 +112,7 @@ TVScreenAnalogBuffer *TVScreenAnalog::getBackBuffer() void TVScreenAnalog::resizeTVScreen(int intCols, int intRows) { - qDebug("TVScreen::resizeTVScreen: cols: %d, rows: %d", intCols, intRows); + qDebug("TVScreenAnalog::resizeTVScreen: cols: %d, rows: %d", intCols, intRows); int colsAdj = intCols + 4; QMutexLocker lock(&m_buffersMutex);