Commit a5d3a9cf authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

ozone: Disable overlays on HDC::Disable.

HDC::Disable currently calls drmModeSetCrtc, that disable the primary
plane, but not additional overlays.

This means that when disabling an HDC and then re-enabling, after the
new modeset, and before a new pageflip, you can see an overlay that was
set with the old pageflip.

This CL makes sure to disable all planes when disabling an HDC.

Bug: 763736
Change-Id: I30ec7eb9ec1323474c21335aaadd1ce2bb250a89
Reviewed-on: https://chromium-review.googlesource.com/680476
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504094}
parent 1834a592
...@@ -69,6 +69,12 @@ bool HardwareDisplayController::Enable(const OverlayPlane& primary) { ...@@ -69,6 +69,12 @@ bool HardwareDisplayController::Enable(const OverlayPlane& primary) {
void HardwareDisplayController::Disable() { void HardwareDisplayController::Disable() {
TRACE_EVENT0("drm", "HDC::Disable"); TRACE_EVENT0("drm", "HDC::Disable");
// Disable all the planes by scheduling a pageflip with an empty plane_list.
// This is necessary since drmModeSetCrtc, that is called by
// controller->Disable(), will not disable overlays.
const OverlayPlaneList plane_list;
ActualSchedulePageFlip(plane_list, false, base::BindOnce(&EmptyFlipCallback));
for (const auto& controller : crtc_controllers_) for (const auto& controller : crtc_controllers_)
controller->Disable(); controller->Disable();
...@@ -96,18 +102,12 @@ bool HardwareDisplayController::ActualSchedulePageFlip( ...@@ -96,18 +102,12 @@ bool HardwareDisplayController::ActualSchedulePageFlip(
DCHECK(!is_disabled_); DCHECK(!is_disabled_);
// Ignore requests with no planes to schedule.
if (plane_list.empty()) {
std::move(callback).Run(gfx::SwapResult::SWAP_ACK);
return true;
}
OverlayPlaneList pending_planes = plane_list; OverlayPlaneList pending_planes = plane_list;
std::sort(pending_planes.begin(), pending_planes.end(), std::sort(pending_planes.begin(), pending_planes.end(),
[](const OverlayPlane& l, const OverlayPlane& r) { [](const OverlayPlane& l, const OverlayPlane& r) {
return l.z_order < r.z_order; return l.z_order < r.z_order;
}); });
if (pending_planes.front().z_order < 0) { if (pending_planes.size() && pending_planes.front().z_order < 0) {
std::move(callback).Run(gfx::SwapResult::SWAP_FAILED); std::move(callback).Run(gfx::SwapResult::SWAP_FAILED);
return false; return false;
} }
......
...@@ -452,3 +452,43 @@ TEST_F(HardwareDisplayControllerTest, RemoveCrtcMidPageFlip) { ...@@ -452,3 +452,43 @@ TEST_F(HardwareDisplayControllerTest, RemoveCrtcMidPageFlip) {
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_); EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_); EXPECT_EQ(1, page_flips_);
} }
TEST_F(HardwareDisplayControllerTest, EmptyPageFlip) {
ui::OverlayPlane plane1(new ui::MockScanoutBuffer(kDefaultModeSize));
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
std::vector<ui::OverlayPlane> planes(1, plane1);
controller_->SchedulePageFlip(
planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
}
TEST_F(HardwareDisplayControllerTest, Disable) {
ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>(
new ui::MockScanoutBuffer(kDefaultModeSize)));
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
ui::OverlayPlane plane2(new ui::MockScanoutBuffer(kOverlaySize), 1,
gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kOverlaySize),
gfx::RectF(kDefaultModeSizeF));
std::vector<ui::OverlayPlane> planes;
planes.push_back(plane1);
planes.push_back(plane2);
controller_->SchedulePageFlip(
planes, base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
base::Unretained(this)));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
controller_->Disable();
const ui::HardwareDisplayPlane* owned_plane = nullptr;
for (const auto& plane : drm_->plane_manager()->planes())
if (plane->in_use())
owned_plane = plane.get();
ASSERT_FALSE(owned_plane);
}
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