hwc: Fix PTOR for overlapping PTOR regions.
If two PTOR layers are overlapping, remove overlapping
region from bottom PTOR layer if possible to reduce total
overlapping layers in a region.
Change-Id: I695c097360ac5a8fa123e014f21380169519eb32
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index 24fd771..8164fd3 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -597,6 +597,21 @@
for(int j = 0; j < ptorInfo->count; j++) {
int ovlapIndex = ptorInfo->layerIndex[j];
hwc_rect_t overlap = list->hwLayers[ovlapIndex].displayFrame;
+ if(j) {
+ /**
+ * It's possible that 2 PTOR layers might have overlapping.
+ * In such case, remove the intersection(again if peripheral)
+ * from the lower PTOR layer to avoid overlapping.
+ * If intersection is not on peripheral then compromise
+ * by reducing number of PTOR layers.
+ **/
+ int prevOvlapIndex = ptorInfo->layerIndex[0];
+ hwc_rect_t prevOvlap = list->hwLayers[prevOvlapIndex].displayFrame;
+ hwc_rect_t commonRect = getIntersection(prevOvlap, overlap);
+ if(isValidRect(commonRect)) {
+ overlap = deductRect(overlap, commonRect);
+ }
+ }
// Draw overlapped content of layers on render buffer
for (int i = 0; i <= ovlapIndex; i++) {