Commit 04771ef7 authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

ozone/drm: Disable planes when removing a crtc.

When HardwareDisplayController::RemoveCrtc is called, planes in old_plane_list,
that is the list of planes last committed for scanout, should be disabled.

Before this patch the planes would not be disabled and would unexpectedly show up
on displays where the old crtc would get reassigned.

Bug: b/72749390
Test: plugged in a secondary monitor while an overlay is displayed on the primary.
Change-Id: I76675a765d0ed9572baaf457060c2d7dac619614
Reviewed-on: https://chromium-review.googlesource.com/924347
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537491}
parent ff4fe2c4
...@@ -224,39 +224,51 @@ void HardwareDisplayController::AddCrtc( ...@@ -224,39 +224,51 @@ void HardwareDisplayController::AddCrtc(
std::unique_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( std::unique_ptr<CrtcController> HardwareDisplayController::RemoveCrtc(
const scoped_refptr<DrmDevice>& drm, const scoped_refptr<DrmDevice>& drm,
uint32_t crtc) { uint32_t crtc) {
for (auto it = crtc_controllers_.begin(); it != crtc_controllers_.end(); auto controller_it = std::find_if(
++it) { crtc_controllers_.begin(), crtc_controllers_.end(),
if ((*it)->drm() == drm && (*it)->crtc() == crtc) { [drm, crtc](const std::unique_ptr<CrtcController>& crtc_controller) {
std::unique_ptr<CrtcController> controller(std::move(*it)); return crtc_controller->drm() == drm && crtc_controller->crtc() == crtc;
crtc_controllers_.erase(it); });
if (controller_it == crtc_controllers_.end())
// Remove entry from |owned_hardware_planes_| iff no other crtcs share it. return nullptr;
bool found = false;
for (auto it = crtc_controllers_.begin(); it != crtc_controllers_.end(); std::unique_ptr<CrtcController> controller(std::move(*controller_it));
++it) { crtc_controllers_.erase(controller_it);
if ((*it)->drm() == controller->drm()) {
found = true; // Remove and disable only the planes owned by the CRTC we just
break; // removed.
} std::vector<HardwareDisplayPlane*>& old_plane_list =
} owned_hardware_planes_[drm.get()]->old_plane_list;
if (found) {
std::vector<HardwareDisplayPlane*> all_planes; // Move all the planes that have been committed in the last pageflip for this
HardwareDisplayPlaneList* plane_list = // CRTC at the end of the collection.
owned_hardware_planes_[drm.get()].get(); auto first_plane_to_disable_it =
all_planes.swap(plane_list->old_plane_list); std::partition(old_plane_list.begin(), old_plane_list.end(),
for (auto* plane : all_planes) { [crtc](const HardwareDisplayPlane* plane) {
if (plane->owning_crtc() != crtc) return plane->owning_crtc() != crtc;
plane_list->old_plane_list.push_back(plane); });
}
} else { // Disable the planes enabled with the last commit on |crtc|, otherwise
owned_hardware_planes_.erase(controller->drm().get()); // the planes will be visible if the crtc is reassigned to another connector.
} HardwareDisplayPlaneList hardware_plane_list;
std::copy(first_plane_to_disable_it, old_plane_list.end(),
return controller; std::back_inserter(hardware_plane_list.old_plane_list));
} drm->plane_manager()->DisableOverlayPlanes(&hardware_plane_list);
// If it was the only CRTC for this drm device, we can remove the hardware
// planes list in |owned_hardware_planes_|.
if (std::find_if(crtc_controllers_.begin(), crtc_controllers_.end(),
[drm](const std::unique_ptr<CrtcController>& crtc) {
return crtc->drm() == drm;
}) == crtc_controllers_.end()) {
owned_hardware_planes_.erase(controller->drm().get());
} else {
// Otherwise we can remove the planes assigned to |crtc| but we can't
// remove the entry in |owned_hardware_planes_|.
old_plane_list.erase(first_plane_to_disable_it, old_plane_list.end());
} }
return nullptr; return controller;
} }
bool HardwareDisplayController::HasCrtc(const scoped_refptr<DrmDevice>& drm, bool HardwareDisplayController::HasCrtc(const scoped_refptr<DrmDevice>& drm,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment