锁屏仅绘制一帧然后停止绘制
This commit is contained in:
parent
fb54be25ec
commit
8ee653e1a6
|
|
@ -37,6 +37,7 @@ VulkanWidget::VulkanWidget(QWidget *parent)
|
|||
, m_initialized(false)
|
||||
, m_renderingEnabled(false)
|
||||
, m_needsResize(false)
|
||||
, m_needsLockedFrameUpdate(false)
|
||||
, m_frameCount(0)
|
||||
, m_queueFamilyIndex(0)
|
||||
, m_currentFrame(0)
|
||||
|
|
@ -915,9 +916,10 @@ void VulkanWidget::setRenderingEnabled(bool enabled)
|
|||
|
||||
if (m_renderingEnabled) {
|
||||
qDebug() << "Vulkan rendering ENABLED - Resuming animations";
|
||||
// 定时器始终运行,无需重新启动
|
||||
// 恢复渲染时,重新启动定时器(锁屏时已停止)
|
||||
if (!m_renderTimer->isActive()) {
|
||||
m_renderTimer->start(16); // ~60 FPS
|
||||
qDebug() << "Render timer restarted";
|
||||
}
|
||||
|
||||
// Unlocked: calculate lock duration
|
||||
|
|
@ -933,8 +935,8 @@ void VulkanWidget::setRenderingEnabled(bool enabled)
|
|||
m_startTime = QDateTime::currentDateTime();
|
||||
} else {
|
||||
qDebug() << "Vulkan rendering DISABLED - Showing locked state";
|
||||
// 关键修复:不停止定时器,继续渲染以显示锁屏界面
|
||||
// 只是不更新动画参数(在 onRenderTimer 中处理)
|
||||
// 关键修复:渲染一帧锁屏界面后停止定时器
|
||||
m_needsLockedFrameUpdate = true; // 标记需要渲染锁屏帧
|
||||
|
||||
// Locked: record lock time
|
||||
m_pauseTime = QDateTime::currentDateTime();
|
||||
|
|
@ -1016,9 +1018,19 @@ void VulkanWidget::onRenderTimer()
|
|||
if (m_wavePhase >= 2 * M_PI) {
|
||||
m_wavePhase -= 2 * M_PI;
|
||||
}
|
||||
}
|
||||
|
||||
// 正常渲染
|
||||
renderFrame();
|
||||
} else if (m_needsLockedFrameUpdate) {
|
||||
// 锁屏状态:只渲染一帧显示锁屏界面
|
||||
m_needsLockedFrameUpdate = false;
|
||||
renderFrame();
|
||||
|
||||
// 渲染完锁屏帧后停止定时器,避免浪费资源
|
||||
m_renderTimer->stop();
|
||||
qDebug() << "Locked frame rendered, timer stopped";
|
||||
}
|
||||
// 否则:锁屏状态且已渲染锁屏帧,不做任何事
|
||||
}
|
||||
|
||||
void VulkanWidget::setError(const QString &error)
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ private:
|
|||
bool m_initialized;
|
||||
bool m_renderingEnabled;
|
||||
bool m_needsResize;
|
||||
bool m_needsLockedFrameUpdate; // 是否需要渲染锁屏帧(锁屏时只渲染一帧)
|
||||
int m_frameCount;
|
||||
uint32_t m_queueFamilyIndex;
|
||||
uint32_t m_currentFrame;
|
||||
|
|
|
|||
Loading…
Reference in New Issue