Skip to content

Commit

Permalink
libmythtv: Fix some lingering issues with visualiser rendering
Browse files Browse the repository at this point in the history
- in MythPlayerVisualiserUI, don't try and optimise away the visualiser
rendering when we are entirely obscured - we still need to drain the
buffers
- in the visualisers, if obscured, don't actually render
  • Loading branch information
mark-kendall committed Oct 10, 2020
1 parent f7a38b9 commit b115356
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
8 changes: 6 additions & 2 deletions mythtv/libs/libmythtv/mythplayervisualiserui.cpp
Expand Up @@ -26,15 +26,19 @@ void MythPlayerVisualiserUI::UIScreenRectChanged(const QRect& Rect)

void MythPlayerVisualiserUI::PrepareVisualiser()
{
if (!(m_visual && m_painter) || (m_embedding && m_embedRect.isEmpty()))
// Note - we must call the visualiser to drain its buffers even if it is not
// to be displayed (otherwise it fails). So do not check for output rect
// size (embedding) etc
if (!m_visual)
return;
if (m_visual->NeedsPrepare())
m_visual->Prepare(m_embedding ? m_embedRect : m_uiScreenRect);
}

void MythPlayerVisualiserUI::RenderVisualiser()
{
if (!(m_visual && m_painter) || (m_embedding && m_embedRect.isEmpty()))
// As for PrepareVisualiser - always call the visualiser if it is present
if (!m_visual)
return;
m_visual->Draw(m_embedding ? m_embedRect : m_uiScreenRect, m_painter, nullptr);
}
Expand Down
Expand Up @@ -61,19 +61,28 @@ void MythVisualMonoScopeOpenGL::Draw(const QRect& Area, MythPainter* /*Painter*/
vbo.second[1] = 1.0;
vbo.second[2] = 1.0;

bool updated = false;
vbo.first->bind();
if (m_bufferMaps)
{
void* buffer = vbo.first->map(QOpenGLBuffer::WriteOnly);
UpdateVertices(static_cast<float*>(buffer));
updated = UpdateVertices(static_cast<float*>(buffer));
vbo.first->unmap();
}
else
{
UpdateVertices(m_vertices.data());
updated = UpdateVertices(m_vertices.data());
vbo.first->write(0, m_vertices.data(), static_cast<int>(m_vertices.size() * sizeof(GLfloat)));
}

if (!updated)
{
// this is generally when the visualiser is embedding and hidden. We must
// still drain the buffers but don't actually draw
render->doneCurrent();
return;
}

// Common calls
render->glEnableVertexAttribArray(0);
QPointF center { m_area.left() + static_cast<qreal>(m_area.width()) / 2,
Expand Down
7 changes: 4 additions & 3 deletions mythtv/libs/libmythtv/visualisations/videovisualmonoscope.cpp
Expand Up @@ -28,16 +28,16 @@ void VideoVisualMonoScope::InitCommon(const QRect& Area)
m_lineWidth = qMax(1.0F, m_area.height() * 0.004F);
}

void VideoVisualMonoScope::UpdateVertices(float* Buffer)
bool VideoVisualMonoScope::UpdateVertices(float* Buffer)
{
if (!Buffer)
return;
return false;

QMutexLocker locker(mutex());
auto * node = GetNode();

if (m_area.isEmpty() || !node)
return;
return false;

float y = (static_cast<float>(m_area.height()) / 2.0F) + m_area.top();
float x = m_area.left();
Expand Down Expand Up @@ -65,6 +65,7 @@ void VideoVisualMonoScope::UpdateVertices(float* Buffer)
Buffer[i * 2 + 1] = y + static_cast<float>(value);
x += xstep;
}
return true;
}

void VideoVisualMonoScope::UpdateTime()
Expand Down
Expand Up @@ -17,7 +17,7 @@ class VideoVisualMonoScope : public VideoVisual
protected:
Q_DISABLE_COPY(VideoVisualMonoScope)
void InitCommon (const QRect& Area);
void UpdateVertices (float* Buffer);
bool UpdateVertices (float* Buffer);
void UpdateTime ();

int64_t m_lastTime { 0 };
Expand Down
Expand Up @@ -229,7 +229,8 @@ void MythVisualMonoScopeVulkan::Prepare(const QRect &Area)
vertex.second[1] = 1.0;
vertex.second[2] = 1.0;
auto * buffer = vertex.first->GetMappedMemory();
UpdateVertices(static_cast<float*>(buffer));
if (!UpdateVertices(static_cast<float*>(buffer)))
return;
vertex.first->Update(nullptr);
}

Expand All @@ -238,6 +239,9 @@ void MythVisualMonoScopeVulkan::Draw(const QRect& Area, MythPainter* /*Painter*/
if (!InitialiseVulkan(Area))
return;

if (Area.isEmpty())
return;

// Retrieve current command buffer
auto *currentcmdbuf = m_vulkanWindow->currentCommandBuffer();

Expand Down

0 comments on commit b115356

Please sign in to comment.