OSDN Git Service

libhwc2on1adapter: avoid marking changes if visible regions unchanged
authorAdrian Salido <salidoa@google.com>
Tue, 19 Sep 2017 01:48:47 +0000 (18:48 -0700)
committerAdrian Salido <salidoa@google.com>
Wed, 20 Sep 2017 21:52:19 +0000 (14:52 -0700)
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

index 8c6ef69..e1b9a8a 100644 (file)
@@ -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;
 }