mirror of https://git.suyu.dev/suyu/suyu
nvnflinger: check for layers before compose
This commit is contained in:
parent
a07f0883b9
commit
940a71422e
|
@ -44,6 +44,10 @@ struct Display {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasLayers() {
|
||||||
|
return !stack.layers.empty();
|
||||||
|
}
|
||||||
|
|
||||||
u64 id;
|
u64 id;
|
||||||
LayerStack stack;
|
LayerStack stack;
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,16 +33,17 @@ void SurfaceFlinger::RemoveDisplay(u64 display_id) {
|
||||||
std::erase_if(m_displays, [&](auto& display) { return display.id == display_id; });
|
std::erase_if(m_displays, [&](auto& display) { return display.id == display_id; });
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceFlinger::ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale,
|
bool SurfaceFlinger::ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale,
|
||||||
u64 display_id) {
|
u64 display_id) {
|
||||||
auto* const display = this->FindDisplay(display_id);
|
auto* const display = this->FindDisplay(display_id);
|
||||||
if (!display) {
|
if (!display || !display->HasLayers()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_swap_interval =
|
*out_swap_interval =
|
||||||
m_composer.ComposeLocked(out_compose_speed_scale, *display,
|
m_composer.ComposeLocked(out_compose_speed_scale, *display,
|
||||||
*nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>(disp_fd));
|
*nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>(disp_fd));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceFlinger::AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id) {
|
void SurfaceFlinger::AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
|
|
||||||
void AddDisplay(u64 display_id);
|
void AddDisplay(u64 display_id);
|
||||||
void RemoveDisplay(u64 display_id);
|
void RemoveDisplay(u64 display_id);
|
||||||
void ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id);
|
bool ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id);
|
||||||
|
|
||||||
void AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id);
|
void AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id);
|
||||||
void RemoveLayerFromDisplayStack(u64 display_id, s32 consumer_binder_id);
|
void RemoveLayerFromDisplayStack(u64 display_id, s32 consumer_binder_id);
|
||||||
|
|
|
@ -218,10 +218,11 @@ void Container::DestroyBufferQueueLocked(Layer* layer) {
|
||||||
layer->GetProducerBinderId());
|
layer->GetProducerBinderId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale,
|
bool Container::ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale,
|
||||||
u64 display_id) {
|
u64 display_id) {
|
||||||
std::scoped_lock lk{m_lock};
|
std::scoped_lock lk{m_lock};
|
||||||
m_surface_flinger->ComposeDisplay(out_swap_interval, out_compose_speed_scale, display_id);
|
return m_surface_flinger->ComposeDisplay(out_swap_interval, out_compose_speed_scale,
|
||||||
|
display_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
|
@ -76,7 +76,7 @@ private:
|
||||||
void DestroyBufferQueueLocked(Layer* layer);
|
void DestroyBufferQueueLocked(Layer* layer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id);
|
bool ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::mutex m_lock{};
|
std::mutex m_lock{};
|
||||||
|
|
Loading…
Reference in New Issue