From d4ca64ef756f255d76b00964e24f24bcbebb56df Mon Sep 17 00:00:00 2001 From: Adrian Salido Date: Mon, 18 Sep 2017 18:48:47 -0700 Subject: [PATCH] libhwc2on1adapter: avoid marking changes if visible regions unchanged The function setVisibleRegions is always called as part of composition, shouldn't mark geometry changed if there are no changes in the visible regions. Bug: 65019874 Test: run cts -m CtsViewTestCases -t android.view.cts.DisplayRefreshRateTest#testRefreshRate Change-Id: I3f93431002fc4b691c799f4ae91aa1488849e4a6 --- libs/hwc2on1adapter/HWC2On1Adapter.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libs/hwc2on1adapter/HWC2On1Adapter.cpp b/libs/hwc2on1adapter/HWC2On1Adapter.cpp index 8c6ef691a2..e1b9a8a6f1 100644 --- a/libs/hwc2on1adapter/HWC2On1Adapter.cpp +++ b/libs/hwc2on1adapter/HWC2On1Adapter.cpp @@ -2005,10 +2005,21 @@ Error HWC2On1Adapter::Layer::setTransform(Transform transform) { return Error::None; } +static bool compareRects(const hwc_rect_t& rect1, const hwc_rect_t& rect2) { + return rect1.left == rect2.left && + rect1.right == rect2.right && + rect1.top == rect2.top && + rect1.bottom == rect2.bottom; +} + Error HWC2On1Adapter::Layer::setVisibleRegion(hwc_region_t visible) { - mVisibleRegion.resize(visible.numRects); - std::copy_n(visible.rects, visible.numRects, mVisibleRegion.begin()); - mDisplay.markGeometryChanged(); + if ((getNumVisibleRegions() != visible.numRects) || + !std::equal(mVisibleRegion.begin(), mVisibleRegion.end(), visible.rects, + compareRects)) { + mVisibleRegion.resize(visible.numRects); + std::copy_n(visible.rects, visible.numRects, mVisibleRegion.begin()); + mDisplay.markGeometryChanged(); + } return Error::None; } -- 2.11.0